Sha256: 7c25cc6e4404a5a74fc7edccb8a729086727eae74e0bbddeebd1adc2c4c629ac

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

share_examples_for 'a Result' do

  include DataObjectsSpecHelpers

  before :all do
    setup_test_environment
  end

  before :each do
    @connection = DataObjects::Connection.new(CONFIG.uri)
    @result    = @connection.create_command("INSERT INTO users (name) VALUES (?)").execute_non_query("monkey")
  end

  after :each do
    @connection.close
  end

  it { @result.should respond_to(:affected_rows) }

  describe 'affected_rows' do

    it 'should return the number of affected rows' do
      @result.affected_rows.should == 1
    end

  end

end

share_examples_for 'a Result which returns inserted keys' do

  include DataObjectsSpecHelpers

  before :all do
    setup_test_environment
  end

  before :each do
    @connection = DataObjects::Connection.new(CONFIG.uri)
    command = @connection.create_command("INSERT INTO users (name) VALUES (?)")
    # execute the command twice and expose the second result
    command.execute_non_query("monkey")
    @result = command.execute_non_query("monkey")
  end

  after :each do
    @connection.close
  end

  it { @result.should respond_to(:affected_rows) }

  describe 'insert_id' do

    it 'should return the number of affected rows' do
      # This is actually the 2nd record inserted
      @result.insert_id.should == 2
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
data_objects-0.10.0 lib/data_objects/spec/result_spec.rb