spec/model/queries_spec.rb in architect4r-0.3.3.1 vs spec/model/queries_spec.rb in architect4r-0.3.4
- old
+ new
@@ -20,10 +20,23 @@
it "should not instatiate the node if it is of the wrong type" do
ship = Ship.create(:name => 'Brahama', :crew_size => 1)
Person.find_by_id(ship.id).should be_nil
end
+ it "should return nil when the node is not found" do
+ Person.find_by_id(-1).should be_nil
+ end
+
+ it "should raise an exception when banged finder is used an no record found" do
+ lambda { Person.find_by_id!(-1) }.should raise_error(Architect4r::RecordNotFound)
+ end
+
+ it "should not raise an exception when banged finder is used an a record is found" do
+ person = Person.create(:name => 'The Architect', :human => false)
+ lambda { Person.find_by_id!(person.id) }.should_not raise_error(Architect4r::RecordNotFound)
+ end
+
end
describe "counting records" do
it "should count the number of records" do
@@ -38,10 +51,10 @@
it "should only return the first two records" do
Person.create(:name => 'Neo', :human => true)
Person.create(:name => 'Trinity', :human => true)
Person.create(:name => 'Morpheus', :human => true)
- results = Person.find_by_cypher("start s=node(#{Person.model_root.id}) match s<-[:model_type]-d return d limit 2", 'd')
+ results = Person.find_by_cypher("start s=node(:person_root) match s<-[:model_type]-d return d limit 2", 'd')
results.size.should == 2
results.first.should be_a(Person)
end
end