Skip to content

Commit

Permalink
fix: allow to use ActiveSupport::Multibyte::Chars in to_b
Browse files Browse the repository at this point in the history
  • Loading branch information
artofhuman committed Apr 3, 2017
1 parent 97b86c6 commit 334ca54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/string_tools/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class String
TRUE_VALUES = %w(1 t T true TRUE on ON).to_set

def initialize(string)
@string = string
@string = string.to_s
end

# Public: cast string value to boolean
Expand Down
5 changes: 5 additions & 0 deletions spec/string_tools/string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@
expect(described_class.new(val).to_b).to be true
end
end

it 'allows to pass object responded to_s' do
expect(described_class.new(ActiveSupport::Multibyte::Chars.new('t')).to_b).to be true
expect(described_class.new(ActiveSupport::Multibyte::Chars.new('f')).to_b).to be false
end
end

0 comments on commit 334ca54

Please sign in to comment.