main
 1require "integration_helper"
 2
 3describe "orm" do
 4  include_context "orm"
 5
 6  context "when inserting a new record" do
 7    let(:movie) { Movie.new.tap { |x| x.name = 'oop' } }
 8
 9    before :each do
10      session.begin_transaction do |session|
11        session.save(movie)
12      end
13    end
14
15    let(:results) { connection[:movies].all }
16
17    it "should insert the correct number of records" do
18      expect(results.count).to eql(1)
19    end
20
21    it "should insert the record with the a new id" do
22      expect(results.first[:id]).to_not eql(-1)
23      expect(results.first[:id]).to be > 0
24    end
25
26    it "should insert the name" do
27      expect(results.first[:name]).to eql('oop')
28    end
29
30    it "should update the new item with the new id" do
31      expect(movie.id).to_not eql(-1)
32    end
33  end
34end