Hi all I'm having problems with data in my specs - i'm probably just going about things the wrong way though.
I'm testing a model (called Property) that uses acts_as_tree, and for now have just done some specs for the basic acts_as_tree functionality - just as a sanity check, i thought, but i'm getting fails. In a before(:all) block, i'm creating a bunch of objects and saving them to the database - like this: describe Property, "with a fresh property tree" do before(:all) do @root = Property.new(:name => "Root") @root.id = 0 #root.id must be 0 for acts as tree to work properly @root.save @role = @root.children.create(:name => "Job Role") @dept = @root.children.create(:name => "Department") ...etc end describe ",standard acts_as_tree methods," do #this test is failing it "class.root" do Property.root.should eql(@root) end end and the fail report from the above test: 'Property with a fresh property tree ,standard acts_as_tree methods, class.root' FAILED expected #<Property id: 0, parent_id: nil, name: "Root">, got #<Property id: 976, parent_id: nil, name: "Root"> (using .eql?) ./spec/models/property_spec.rb:50: script/spec:4: My problems seem to be arising from the fact that when i run the test, the objects i created last time are still in the database. Shouldn't they be cleared out automatically? This in turn is preventing me from saving root with an id of 0. If i test all of this stuff in the console it works fine, but it's failing in my tests, suggesting that my tests are broken. Am i setting up my data in the wrong way?
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users