do_postgres 0.10.3-x86-mingw32 → 0.10.4.rc1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
data/lib/do_postgres.rb CHANGED
@@ -3,9 +3,14 @@ if RUBY_PLATFORM =~ /java/
3
3
  require 'do_jdbc'
4
4
  require 'java'
5
5
 
6
- driver = 'org.postgresql.Driver'
6
+ module DataObjects
7
+ module Postgres
8
+ JDBC_DRIVER = 'org.postgresql.Driver'
9
+ end
10
+ end
11
+
7
12
  begin
8
- java.lang.Thread.currentThread.getContextClassLoader().loadClass(driver, true)
13
+ java.lang.Thread.currentThread.getContextClassLoader().loadClass(DataObjects::Postgres::JDBC_DRIVER, true)
9
14
  rescue
10
15
  require 'jdbc/postgres' # the JDBC driver, packaged as a gem
11
16
  end
@@ -13,7 +18,7 @@ if RUBY_PLATFORM =~ /java/
13
18
  # Another way of loading the JDBC Class. This seems to be more reliable
14
19
  # than Class.forName() within the data_objects.Connection Java class,
15
20
  # which is currently not working as expected.
16
- java_import driver
21
+ java_import DataObjects::Postgres::JDBC_DRIVER
17
22
 
18
23
  end
19
24
 
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  module DataObjects
2
2
  module Postgres
3
- VERSION = '0.10.3'
3
+ VERSION = '0.10.4.rc1'
4
4
  end
5
5
  end
data/spec/command_spec.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
- require 'data_objects/spec/command_spec'
4
+ require 'data_objects/spec/shared/command_spec'
5
5
 
6
6
  describe DataObjects::Postgres::Command do
7
- behaves_like 'a Command'
8
- behaves_like 'a Command with async'
7
+ it_should_behave_like 'a Command'
8
+ it_should_behave_like 'a Command with async'
9
9
  end
@@ -1,24 +1,33 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
- require 'data_objects/spec/connection_spec'
4
+ require 'data_objects/spec/shared/connection_spec'
5
5
 
6
6
  describe DataObjects::Postgres::Connection do
7
7
 
8
- before do
9
- @driver = CONFIG.scheme
10
- @user = CONFIG.user
8
+ before :all do
9
+ @driver = CONFIG.scheme
10
+ @user = CONFIG.user
11
11
  @password = CONFIG.pass
12
- @host = CONFIG.host
13
- @port = CONFIG.port
12
+ @host = CONFIG.host
13
+ @port = CONFIG.port
14
14
  @database = CONFIG.database
15
15
  end
16
16
 
17
- behaves_like 'a Connection'
18
- behaves_like 'a Connection with authentication support'
19
- # FIXME: behaves_like 'a Connection with JDBC URL support' if JRUBY
17
+ it_should_behave_like 'a Connection'
18
+ it_should_behave_like 'a Connection with authentication support'
19
+ it_should_behave_like 'a Connection with JDBC URL support' if JRUBY
20
20
 
21
21
  describe 'byte array quoting' do
22
+
23
+ before do
24
+ @connection = DataObjects::Connection.new(CONFIG.uri)
25
+ end
26
+
27
+ after do
28
+ @connection.close
29
+ end
30
+
22
31
  # There are two possible byte array quotings available: hex or escape.
23
32
  # The default changed from escape to hex in version 9, so these specs
24
33
  # check for either.
@@ -26,15 +35,15 @@ describe DataObjects::Postgres::Connection do
26
35
  # http://developer.postgresql.org/pgdocs/postgres/datatype-binary.html
27
36
  # http://developer.postgresql.org/pgdocs/postgres/release-9-0.html (E.3.2.3.)
28
37
  it 'should properly escape non-printable ASCII characters' do
29
- ["'\\001'", "'\\x01'"].should.include @connection.quote_byte_array("\001")
38
+ ["'\\001'", "'\\x01'"].should include @connection.quote_byte_array("\001")
30
39
  end
31
40
 
32
41
  it 'should properly escape bytes with the high bit set' do
33
- ["'\\210'", "'\\x88'"].should.include @connection.quote_byte_array("\210")
42
+ ["'\\210'", "'\\x88'"].should include @connection.quote_byte_array("\210")
34
43
  end
35
44
 
36
45
  it 'should not escape printable ASCII characters' do
37
- ["'a'", "'\\x61'"].should.include @connection.quote_byte_array("a")
46
+ ["'a'", "'\\x61'"].should include @connection.quote_byte_array("a")
38
47
  end
39
48
  end
40
49
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
- require 'data_objects/spec/encoding_spec'
4
+ require 'data_objects/spec/shared/encoding_spec'
5
5
 
6
6
  describe DataObjects::Postgres::Connection do
7
7
  unless JRUBY
@@ -14,8 +14,8 @@ describe DataObjects::Postgres::Connection do
14
14
  # handles setting the internal client_encoding setting appropriately. It
15
15
  # can be overridden -- but for now, we won't support doing this.
16
16
  #
17
- behaves_like 'a driver supporting different encodings'
18
- behaves_like 'returning correctly encoded strings for the default database encoding'
19
- behaves_like 'returning correctly encoded strings for the default internal encoding'
17
+ it_should_behave_like 'a driver supporting different encodings'
18
+ it_should_behave_like 'returning correctly encoded strings for the default database encoding'
19
+ it_should_behave_like 'returning correctly encoded strings for the default internal encoding'
20
20
  end
21
21
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/error/sql_error_spec'
4
+ require 'data_objects/spec/shared/error/sql_error_spec'
5
5
 
6
6
  describe 'DataObjects::Postgres raising SQLError' do
7
- behaves_like 'raising a SQLError'
7
+ it_should_behave_like 'raising a SQLError'
8
8
  end
data/spec/reader_spec.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
- require 'data_objects/spec/reader_spec'
4
+ require 'data_objects/spec/shared/reader_spec'
5
5
 
6
6
  describe DataObjects::Postgres::Reader do
7
- behaves_like 'a Reader'
7
+ it_should_behave_like 'a Reader'
8
8
  end
data/spec/result_spec.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
4
- require 'data_objects/spec/result_spec'
4
+ require 'data_objects/spec/shared/result_spec'
5
5
 
6
6
  describe DataObjects::Postgres::Result do
7
- behaves_like 'a Result'
7
+ it_should_behave_like 'a Result'
8
8
 
9
- after do
9
+ before do
10
10
  setup_test_environment
11
11
  end
12
12
 
@@ -21,7 +21,7 @@ describe DataObjects::Postgres::Result do
21
21
  @connection.close
22
22
  end
23
23
 
24
- it 'should respond to #affected_rows' do @result.should.respond_to(:affected_rows) end
24
+ it { @result.should respond_to(:affected_rows) }
25
25
 
26
26
  describe 'affected_rows' do
27
27
 
@@ -31,18 +31,19 @@ describe DataObjects::Postgres::Result do
31
31
 
32
32
  end
33
33
 
34
- it 'should respond to #insert_id' do @result.should.respond_to(:insert_id) end
34
+ it { @result.should respond_to(:insert_id) }
35
35
 
36
36
  describe 'insert_id' do
37
37
 
38
38
  it 'should return nil' do
39
- @result.insert_id.should.be.nil
39
+ @result.insert_id.should be_nil
40
40
  end
41
41
 
42
42
  it 'should be retrievable through curr_val' do
43
+ # This is actually the 4th record inserted
43
44
  reader = @connection.create_command("SELECT currval('users_id_seq')").execute_reader
44
45
  reader.next!
45
- reader.values.first.should == 2
46
+ reader.values.first.should == 1
46
47
  end
47
48
 
48
49
  end
@@ -60,7 +61,7 @@ describe DataObjects::Postgres::Result do
60
61
  @connection.close
61
62
  end
62
63
 
63
- it 'should respond to #affected_rows' do @result.should.respond_to(:affected_rows) end
64
+ it { @result.should respond_to(:affected_rows) }
64
65
 
65
66
  describe 'affected_rows' do
66
67
 
@@ -70,12 +71,12 @@ describe DataObjects::Postgres::Result do
70
71
 
71
72
  end
72
73
 
73
- it 'should respond to #insert_id' do @result.should.respond_to(:insert_id) end
74
+ it { @result.should respond_to(:insert_id) }
74
75
 
75
76
  describe 'insert_id' do
76
77
 
77
78
  it 'should return the generated key value' do
78
- @result.insert_id.should == 2
79
+ @result.insert_id.should == 1
79
80
  end
80
81
 
81
82
  end
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,7 @@ $TESTING=true
2
2
  JRUBY = RUBY_PLATFORM =~ /java/
3
3
 
4
4
  require 'rubygems'
5
+ require 'rspec'
5
6
  require 'date'
6
7
  require 'ostruct'
7
8
  require 'fileutils'
@@ -19,12 +20,14 @@ repo_root = File.expand_path('../../..', __FILE__)
19
20
  end
20
21
 
21
22
  require 'data_objects'
22
- require 'data_objects/spec/bacon'
23
+ require 'data_objects/spec/setup'
24
+ require 'data_objects/spec/lib/pending_helpers'
23
25
  require 'do_postgres'
24
26
 
25
27
  DataObjects::Postgres.logger = DataObjects::Logger.new(STDOUT, :off)
26
28
  at_exit { DataObjects.logger.flush }
27
29
 
30
+
28
31
  CONFIG = OpenStruct.new
29
32
  CONFIG.scheme = 'postgres'
30
33
  CONFIG.user = ENV['DO_POSTGRES_USER'] || 'postgres'
@@ -38,9 +41,11 @@ CONFIG.host = ENV['DO_POSTGRES_HOST'] || 'localhost'
38
41
  CONFIG.port = ENV['DO_POSTGRES_PORT'] || '5432'
39
42
  CONFIG.database = ENV['DO_POSTGRES_DATABASE'] || '/do_test'
40
43
 
41
- CONFIG.uri = ENV["DO_POSTGRES_SPEC_URI"] ||"#{CONFIG.scheme}://#{CONFIG.user_info}#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}"
42
- CONFIG.jdbc_uri = CONFIG.uri.sub(/postgres/,"jdbc:postgresql")
43
- CONFIG.sleep = "SELECT pg_sleep(1)"
44
+ CONFIG.driver = 'postgres'
45
+ CONFIG.jdbc_driver = DataObjects::Postgres.const_get('JDBC_DRIVER') rescue nil
46
+ CONFIG.uri = ENV["DO_POSTGRES_SPEC_URI"] ||"#{CONFIG.scheme}://#{CONFIG.user_info}#{CONFIG.host}:#{CONFIG.port}#{CONFIG.database}"
47
+ CONFIG.jdbc_uri = CONFIG.uri.sub(/postgres/,"jdbc:postgresql")
48
+ CONFIG.sleep = "SELECT pg_sleep(1)"
44
49
 
45
50
  module DataObjectsSpecHelpers
46
51
 
@@ -149,4 +154,7 @@ module DataObjectsSpecHelpers
149
154
 
150
155
  end
151
156
 
152
- include DataObjectsSpecHelpers
157
+ RSpec.configure do |config|
158
+ config.include(DataObjectsSpecHelpers)
159
+ config.include(DataObjects::Spec::PendingHelpers)
160
+ end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/array_spec'
4
+ require 'data_objects/spec/shared/typecast/array_spec'
5
5
 
6
6
  describe 'DataObjects::Postgres with Array' do
7
- behaves_like 'supporting Array'
7
+ it_should_behave_like 'supporting Array'
8
8
  end
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/bigdecimal_spec'
4
+ require 'data_objects/spec/shared/typecast/bigdecimal_spec'
5
5
 
6
6
  describe 'DataObjects::Postgres with BigDecimal' do
7
- behaves_like 'supporting BigDecimal'
8
- behaves_like 'supporting BigDecimal autocasting'
7
+ it_should_behave_like 'supporting BigDecimal'
8
+ it_should_behave_like 'supporting BigDecimal autocasting'
9
9
  end
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/boolean_spec'
4
+ require 'data_objects/spec/shared/typecast/boolean_spec'
5
5
 
6
6
  describe 'DataObjects::Postgres with Boolean' do
7
- behaves_like 'supporting Boolean'
8
- behaves_like 'supporting Boolean autocasting'
7
+ it_should_behave_like 'supporting Boolean'
8
+ it_should_behave_like 'supporting Boolean autocasting'
9
9
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/byte_array_spec'
4
+ require 'data_objects/spec/shared/typecast/byte_array_spec'
5
5
 
6
6
  describe 'DataObjects::Postgres with ByteArray' do
7
- behaves_like 'supporting ByteArray'
7
+ it_should_behave_like 'supporting ByteArray'
8
8
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/class_spec'
4
+ require 'data_objects/spec/shared/typecast/class_spec'
5
5
 
6
6
  describe 'DataObjects::Postgres with Class' do
7
- behaves_like 'supporting Class'
7
+ it_should_behave_like 'supporting Class'
8
8
  end
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/date_spec'
4
+ require 'data_objects/spec/shared/typecast/date_spec'
5
5
 
6
6
  describe 'DataObjects::Postgres with Date' do
7
- behaves_like 'supporting Date'
8
- behaves_like 'supporting Date autocasting'
7
+ it_should_behave_like 'supporting Date'
8
+ it_should_behave_like 'supporting Date autocasting'
9
9
  end
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/datetime_spec'
4
+ require 'data_objects/spec/shared/typecast/datetime_spec'
5
5
 
6
6
  describe 'DataObjects::Postgres with DateTime' do
7
- behaves_like 'supporting DateTime'
8
- behaves_like 'supporting DateTime autocasting'
7
+ it_should_behave_like 'supporting DateTime'
8
+ it_should_behave_like 'supporting DateTime autocasting'
9
9
  end
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/float_spec'
4
+ require 'data_objects/spec/shared/typecast/float_spec'
5
5
 
6
6
  describe 'DataObjects::Postgres with Float' do
7
- behaves_like 'supporting Float'
8
- behaves_like 'supporting Float autocasting'
7
+ it_should_behave_like 'supporting Float'
8
+ it_should_behave_like 'supporting Float autocasting'
9
9
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/integer_spec'
4
+ require 'data_objects/spec/shared/typecast/integer_spec'
5
5
 
6
6
  describe 'DataObjects::Postgres with Integer' do
7
- behaves_like 'supporting Integer'
7
+ it_should_behave_like 'supporting Integer'
8
8
  end
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/nil_spec'
4
+ require 'data_objects/spec/shared/typecast/nil_spec'
5
5
 
6
6
  describe 'DataObjects::Postgres with Nil' do
7
- behaves_like 'supporting Nil'
8
- # behaves_like 'supporting writing an Nil'
9
- behaves_like 'supporting Nil autocasting'
7
+ it_should_behave_like 'supporting Nil'
8
+ # it_should_behave_like 'supporting writing an Nil'
9
+ it_should_behave_like 'supporting Nil autocasting'
10
10
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/other_spec'
4
+ require 'data_objects/spec/shared/typecast/other_spec'
5
5
 
6
6
  describe 'DataObjects::H2 with other (unknown) type' do
7
- behaves_like 'supporting other (unknown) type'
7
+ it_should_behave_like 'supporting other (unknown) type'
8
8
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/range_spec'
4
+ require 'data_objects/spec/shared/typecast/range_spec'
5
5
 
6
6
  describe 'DataObjects::Postgres with Range' do
7
- behaves_like 'supporting Range'
7
+ it_should_behave_like 'supporting Range'
8
8
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
- require 'data_objects/spec/typecast/string_spec'
4
+ require 'data_objects/spec/shared/typecast/string_spec'
5
5
 
6
6
  describe 'DataObjects::Postgres with String' do
7
- behaves_like 'supporting String'
7
+ it_should_behave_like 'supporting String'
8
8
  end