Skip to content

Commit

Permalink
make sure boolean filters work with implicit strings
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronLasseigne committed Jan 10, 2021
1 parent d39ae5a commit b4fa18f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/active_interaction/filters/boolean_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@
expect(filter.cast(value, nil)).to be_falsey
end
end

context 'with an implicit string' do
let(:value) do
Class.new do
def to_str
'false'
end
end.new
end

it 'returns false' do
expect(filter.cast(value, nil)).to be_falsey
end
end
end

context 'truthy' do
Expand All @@ -19,6 +33,20 @@
expect(filter.cast(value, nil)).to be_truthy
end
end

context 'with an implicit string' do
let(:value) do
Class.new do
def to_str
'true'
end
end.new
end

it 'returns true' do
expect(filter.cast(value, nil)).to be_truthy
end
end
end
end

Expand Down

0 comments on commit b4fa18f

Please sign in to comment.