Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed spec

  • Loading branch information...
commit 50e209f10c37ab5685e5880cbfd301d4315a5dbf 1 parent cfae36c
@dim dim authored
View
5 lib/bsm/constrainable/field/common.rb
@@ -52,13 +52,14 @@ def _convert(v)
class Boolean < Base
self.operators = [:eq, :not_eq]
- TRUE_VALUES = ["true", "1"]
+ TRUE_VALUES = ["true", "TRUE", "t", "T", "1", 1].to_set.freeze
+ FALSE_VALUES = ["false", "FALSE", "f", "F", "0", 0].to_set.freeze
protected
def _convert(v)
result = super
- result.blank? ? nil : TRUE_VALUES.include?(result)
+ TRUE_VALUES.include?(result) || (FALSE_VALUES.include?(result) ? false : nil)
end
end
View
2  spec/bsm/constrainable/field/common_spec.rb
@@ -58,7 +58,9 @@
describe Bsm::Constrainable::Field::Boolean do
it { subject.class.should have(2).operators }
it { subject.convert("true").should == true }
+ it { subject.convert("t").should == true }
it { subject.convert("1").should == true }
+ it { subject.convert(1).should == true }
it { subject.convert("false").should == false }
it { subject.convert("0").should == false }
it { subject.convert("").should == nil }
View
2  spec/bsm/constrainable/field_spec.rb
@@ -5,7 +5,7 @@
it { should be_a(Bsm::Constrainable::Registry) }
it 'should have a registry' do
- described_class.registry.should have(7).items
+ described_class.registry.should have(8).items
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.