Commit 14efe1a
Changed files (1)
spec
integration
spec/integration/example_spec.rb
@@ -15,9 +15,6 @@ describe "orm" do
end
configuration.add(MovieMapping.new)
- session.begin_transaction do |session|
- session.save(Movie.new(:name => 'monsters inc'))
- end
end
after :each do
@@ -25,6 +22,10 @@ describe "orm" do
end
context "when fetching all items" do
+ before :each do
+ connection[:movies].insert(:name => 'monsters inc')
+ end
+
let(:results) { session.find_all Movie }
it "should return the correct number of movies" do
@@ -40,4 +41,27 @@ describe "orm" do
end
end
+ context "when inserting a new record" do
+ before :each do
+ session.begin_transaction do |session|
+ session.save(Movie.new(:name => 'oop'))
+ end
+ end
+
+ let(:results) { connection[:movies].all }
+
+ it "should insert the correct number of records" do
+ results.count.should == 1
+ end
+
+ it "should insert the record with the a new id" do
+ results.first[:id].should_not == -1
+ results.first[:id].should > 0
+ end
+
+ it "should insert the name" do
+ results.first[:name].should == 'oop'
+ end
+ end
+
end