File: sql_error_spec.rb

package info (click to toggle)
ruby-dataobjects 0.10.8-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 416 kB
  • sloc: ruby: 2,917; makefile: 4
file content (30 lines) | stat: -rw-r--r-- 836 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
shared_examples_for 'raising a SQLError' do

  before :all do
    setup_test_environment
  end

  describe "an invalid query" do

    it 'should raise an error' do
      @connection = DataObjects::Connection.new(CONFIG.uri)
      invalid_query = @connection.create_command("SLCT * FROM widgets WHERE ad_description = ? order by id")
      expect { invalid_query.execute_reader('Buy this product now!') }.to raise_error(DataObjects::SQLError)
      @connection.close
    end

  end


  describe "an invalid result set" do

    it 'should raise an error' do
      @connection = DataObjects::Connection.new(CONFIG.uri)
      invalid_result = @connection.create_command("SELECT MAX((SELECT 1 UNION SELECT 2))")
      expect { invalid_result.execute_reader }.to raise_error(DataObjects::SQLError)
      @connection.close
    end

  end

end