Skip to content
This repository has been archived by the owner on May 18, 2018. It is now read-only.

Commit

Permalink
Fixed spec
Browse files Browse the repository at this point in the history
  • Loading branch information
dim committed Jan 23, 2012
1 parent cfae36c commit 50e209f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/bsm/constrainable/field/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions spec/bsm/constrainable/field/common_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion spec/bsm/constrainable/field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 50e209f

Please sign in to comment.