Cleaned boolean tests
This commit is contained in:
parent
5b048c2280
commit
c06907fe58
|
@ -578,10 +578,6 @@ describe "ExtendedDocument properties" do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'when type primitive is a Boolean' do
|
describe 'when type primitive is a Boolean' do
|
||||||
class RootBeerFloat < CouchRest::ExtendedDocument
|
|
||||||
use_database DB
|
|
||||||
property :tasty, TrueClass
|
|
||||||
end
|
|
||||||
|
|
||||||
[ true, 'true', 'TRUE', '1', 1, 't', 'T' ].each do |value|
|
[ true, 'true', 'TRUE', '1', 1, 't', 'T' ].each do |value|
|
||||||
it "returns true when value is #{value.inspect}" do
|
it "returns true when value is #{value.inspect}" do
|
||||||
|
@ -605,26 +601,20 @@ describe "ExtendedDocument properties" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should respond to requests with ? modifier" do
|
it "should respond to requests with ? modifier" do
|
||||||
@course.active = 'false'
|
@course.active = nil
|
||||||
@course.active?.should be_false
|
@course.active?.should be_false
|
||||||
|
@course.active = false
|
||||||
|
@course.active?.should be_false
|
||||||
|
@course.active = true
|
||||||
|
@course.active?.should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should add an accessor with a '?' for boolean attributes that returns true or false" do
|
it "should respond to requests with ? modifier on TrueClass" do
|
||||||
RootBeerFloat.new(:tasty => true).tasty?.should == true
|
@course.very_active = nil
|
||||||
RootBeerFloat.new(:tasty => 'you bet').tasty?.should == true
|
@course.very_active?.should be_false
|
||||||
RootBeerFloat.new(:tasty => 123).tasty?.should == true
|
@course.very_active = false
|
||||||
|
@course.very_active?.should be_false
|
||||||
RootBeerFloat.new(:tasty => false).tasty?.should == false
|
@course.very_active = true
|
||||||
RootBeerFloat.new(:tasty => 'false').tasty?.should == false
|
|
||||||
RootBeerFloat.new(:tasty => 'FaLsE').tasty?.should == false
|
|
||||||
RootBeerFloat.new(:tasty => nil).tasty?.should == false
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'when type primitive is a TrueClass' do
|
|
||||||
it "should respond to requests with ? modifier" do
|
|
||||||
@course.very_active = 'true'
|
|
||||||
@course.very_active?.should be_true
|
@course.very_active?.should be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue