data_objects 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/ChangeLog.markdown +20 -0
  2. data/LICENSE +1 -29
  3. data/README.markdown +16 -2
  4. data/Rakefile +41 -7
  5. data/lib/data_objects.rb +3 -2
  6. data/lib/data_objects/byte_array.rb +6 -0
  7. data/lib/data_objects/connection.rb +21 -9
  8. data/lib/data_objects/logger.rb +15 -15
  9. data/lib/data_objects/pooling.rb +250 -0
  10. data/lib/data_objects/reader.rb +16 -0
  11. data/lib/data_objects/spec/bacon.rb +9 -0
  12. data/lib/data_objects/spec/command_spec.rb +54 -47
  13. data/lib/data_objects/spec/connection_spec.rb +119 -30
  14. data/lib/data_objects/spec/encoding_spec.rb +64 -6
  15. data/lib/data_objects/spec/helpers/immediate_red_green_output.rb +59 -0
  16. data/lib/data_objects/spec/helpers/pending.rb +22 -0
  17. data/lib/data_objects/spec/helpers/ssl.rb +21 -0
  18. data/lib/data_objects/spec/reader_spec.rb +47 -24
  19. data/lib/data_objects/spec/result_spec.rb +10 -19
  20. data/lib/data_objects/spec/typecast/array_spec.rb +16 -20
  21. data/lib/data_objects/spec/typecast/bigdecimal_spec.rb +16 -24
  22. data/lib/data_objects/spec/typecast/boolean_spec.rb +16 -24
  23. data/lib/data_objects/spec/typecast/byte_array_spec.rb +11 -15
  24. data/lib/data_objects/spec/typecast/class_spec.rb +7 -11
  25. data/lib/data_objects/spec/typecast/date_spec.rb +17 -25
  26. data/lib/data_objects/spec/typecast/datetime_spec.rb +18 -26
  27. data/lib/data_objects/spec/typecast/float_spec.rb +19 -27
  28. data/lib/data_objects/spec/typecast/integer_spec.rb +10 -14
  29. data/lib/data_objects/spec/typecast/nil_spec.rb +18 -30
  30. data/lib/data_objects/spec/typecast/other_spec.rb +45 -0
  31. data/lib/data_objects/spec/typecast/range_spec.rb +16 -20
  32. data/lib/data_objects/spec/typecast/string_spec.rb +72 -13
  33. data/lib/data_objects/spec/typecast/time_spec.rb +11 -15
  34. data/lib/data_objects/utilities.rb +18 -0
  35. data/lib/data_objects/version.rb +1 -2
  36. data/spec/command_spec.rb +2 -2
  37. data/spec/connection_spec.rb +7 -5
  38. data/spec/do_mock2.rb +31 -0
  39. data/spec/pooling_spec.rb +162 -0
  40. data/spec/reader_spec.rb +7 -4
  41. data/spec/result_spec.rb +2 -2
  42. data/spec/spec_helper.rb +26 -5
  43. data/spec/transaction_spec.rb +11 -9
  44. data/tasks/metrics.rake +36 -0
  45. data/tasks/release.rake +10 -70
  46. data/tasks/spec.rake +16 -14
  47. data/tasks/yard.rake +9 -0
  48. data/tasks/yardstick.rake +19 -0
  49. metadata +53 -27
  50. data/HISTORY.markdown +0 -7
  51. data/Manifest.txt +0 -44
  52. data/spec/lib/pending_helpers.rb +0 -11
  53. data/spec/lib/rspec_immediate_feedback_formatter.rb +0 -53
  54. data/spec/lib/ssl_helpers.rb +0 -20
  55. data/tasks/gem.rake +0 -8
  56. data/tasks/install.rake +0 -13
@@ -1,16 +1,12 @@
1
- share_examples_for 'supporting BigDecimal' do
1
+ shared 'supporting BigDecimal' do
2
2
 
3
- include DataObjectsSpecHelpers
3
+ setup_test_environment
4
4
 
5
- before :all do
6
- setup_test_environment
7
- end
8
-
9
- before :each do
5
+ before do
10
6
  @connection = DataObjects::Connection.new(CONFIG.uri)
11
7
  end
12
8
 
13
- after :each do
9
+ after do
14
10
  @connection.close
15
11
  end
16
12
 
@@ -18,7 +14,7 @@ share_examples_for 'supporting BigDecimal' do
18
14
 
19
15
  describe 'with manual typecasting' do
20
16
 
21
- before do
17
+ before do
22
18
  @command = @connection.create_command("SELECT cost1 FROM widgets WHERE ad_description = ?")
23
19
  @command.set_types(BigDecimal)
24
20
  @reader = @command.execute_reader('Buy this product now!')
@@ -31,7 +27,7 @@ share_examples_for 'supporting BigDecimal' do
31
27
  end
32
28
 
33
29
  it 'should return the correctly typed result' do
34
- @values.first.should be_kind_of(BigDecimal)
30
+ @values.first.should.be.kind_of(BigDecimal)
35
31
  end
36
32
 
37
33
  it 'should return the correct result' do
@@ -43,7 +39,7 @@ share_examples_for 'supporting BigDecimal' do
43
39
 
44
40
  describe 'with manual typecasting a nil value' do
45
41
 
46
- before do
42
+ before do
47
43
  @command = @connection.create_command("SELECT cost2 FROM widgets WHERE id = ?")
48
44
  @command.set_types(BigDecimal)
49
45
  @reader = @command.execute_reader(6)
@@ -56,11 +52,11 @@ share_examples_for 'supporting BigDecimal' do
56
52
  end
57
53
 
58
54
  it 'should return the correctly typed result' do
59
- @values.first.should be_kind_of(NilClass)
55
+ @values.first.should.be.kind_of(NilClass)
60
56
  end
61
57
 
62
58
  it 'should return the correct result' do
63
- @values.first.should be_nil
59
+ @values.first.should.be.nil
64
60
  end
65
61
 
66
62
  end
@@ -69,7 +65,7 @@ share_examples_for 'supporting BigDecimal' do
69
65
 
70
66
  describe 'writing an Integer' do
71
67
 
72
- before do
68
+ before do
73
69
  @reader = @connection.create_command("SELECT id FROM widgets WHERE id = ?").execute_reader(BigDecimal("2.0"))
74
70
  @reader.next!
75
71
  @values = @reader.values
@@ -87,19 +83,15 @@ share_examples_for 'supporting BigDecimal' do
87
83
 
88
84
  end
89
85
 
90
- share_examples_for 'supporting BigDecimal autocasting' do
86
+ shared 'supporting BigDecimal autocasting' do
91
87
 
92
- include DataObjectsSpecHelpers
93
-
94
- before :all do
95
- setup_test_environment
96
- end
88
+ setup_test_environment
97
89
 
98
- before :each do
90
+ before do
99
91
  @connection = DataObjects::Connection.new(CONFIG.uri)
100
92
  end
101
93
 
102
- after :each do
94
+ after do
103
95
  @connection.close
104
96
  end
105
97
 
@@ -107,7 +99,7 @@ share_examples_for 'supporting BigDecimal autocasting' do
107
99
 
108
100
  describe 'with automatic typecasting' do
109
101
 
110
- before do
102
+ before do
111
103
  @reader = @connection.create_command("SELECT cost2 FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
112
104
  @reader.next!
113
105
  @values = @reader.values
@@ -118,7 +110,7 @@ share_examples_for 'supporting BigDecimal autocasting' do
118
110
  end
119
111
 
120
112
  it 'should return the correctly typed result' do
121
- @values.first.should be_kind_of(BigDecimal)
113
+ @values.first.should.be.kind_of(BigDecimal)
122
114
  end
123
115
 
124
116
  it 'should return the correct result' do
@@ -1,16 +1,12 @@
1
- share_examples_for 'supporting Boolean' do
1
+ shared 'supporting Boolean' do
2
2
 
3
- include DataObjectsSpecHelpers
3
+ setup_test_environment
4
4
 
5
- before :all do
6
- setup_test_environment
7
- end
8
-
9
- before :each do
5
+ before do
10
6
  @connection = DataObjects::Connection.new(CONFIG.uri)
11
7
  end
12
8
 
13
- after :each do
9
+ after do
14
10
  @connection.close
15
11
  end
16
12
 
@@ -18,7 +14,7 @@ share_examples_for 'supporting Boolean' do
18
14
 
19
15
  describe 'with manual typecasting' do
20
16
 
21
- before do
17
+ before do
22
18
  @command = @connection.create_command("SELECT flags FROM widgets WHERE ad_description = ?")
23
19
  @command.set_types(TrueClass)
24
20
  @reader = @command.execute_reader('Buy this product now!')
@@ -31,7 +27,7 @@ share_examples_for 'supporting Boolean' do
31
27
  end
32
28
 
33
29
  it 'should return the correctly typed result' do
34
- @values.first.should be_kind_of(FalseClass)
30
+ @values.first.should.be.kind_of(FalseClass)
35
31
  end
36
32
 
37
33
  it 'should return the correct result' do
@@ -42,7 +38,7 @@ share_examples_for 'supporting Boolean' do
42
38
 
43
39
  describe 'with manual typecasting a nil value' do
44
40
 
45
- before do
41
+ before do
46
42
  @command = @connection.create_command("SELECT flags FROM widgets WHERE id = ?")
47
43
  @command.set_types(TrueClass)
48
44
  @reader = @command.execute_reader(4)
@@ -55,11 +51,11 @@ share_examples_for 'supporting Boolean' do
55
51
  end
56
52
 
57
53
  it 'should return the correctly typed result' do
58
- @values.first.should be_kind_of(NilClass)
54
+ @values.first.should.be.kind_of(NilClass)
59
55
  end
60
56
 
61
57
  it 'should return the correct result' do
62
- @values.first.should be_nil
58
+ @values.first.should.be.nil
63
59
  end
64
60
 
65
61
  end
@@ -68,7 +64,7 @@ share_examples_for 'supporting Boolean' do
68
64
 
69
65
  describe 'writing an Boolean' do
70
66
 
71
- before do
67
+ before do
72
68
  @reader = @connection.create_command("SELECT id FROM widgets WHERE flags = ?").execute_reader(true)
73
69
  @reader.next!
74
70
  @values = @reader.values
@@ -86,19 +82,15 @@ share_examples_for 'supporting Boolean' do
86
82
 
87
83
  end
88
84
 
89
- share_examples_for 'supporting Boolean autocasting' do
85
+ shared 'supporting Boolean autocasting' do
90
86
 
91
- include DataObjectsSpecHelpers
92
-
93
- before :all do
94
- setup_test_environment
95
- end
87
+ setup_test_environment
96
88
 
97
- before :each do
89
+ before do
98
90
  @connection = DataObjects::Connection.new(CONFIG.uri)
99
91
  end
100
92
 
101
- after :each do
93
+ after do
102
94
  @connection.close
103
95
  end
104
96
 
@@ -106,7 +98,7 @@ share_examples_for 'supporting Boolean autocasting' do
106
98
 
107
99
  describe 'with automatic typecasting' do
108
100
 
109
- before do
101
+ before do
110
102
  @reader = @connection.create_command("SELECT flags FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
111
103
  @reader.next!
112
104
  @values = @reader.values
@@ -117,7 +109,7 @@ share_examples_for 'supporting Boolean autocasting' do
117
109
  end
118
110
 
119
111
  it 'should return the correctly typed result' do
120
- @values.first.should be_kind_of(FalseClass)
112
+ @values.first.should.be.kind_of(FalseClass)
121
113
  end
122
114
 
123
115
  it 'should return the correct result' do
@@ -1,16 +1,12 @@
1
- share_examples_for 'supporting ByteArray' do
1
+ shared 'supporting ByteArray' do
2
2
 
3
- include DataObjectsSpecHelpers
3
+ setup_test_environment
4
4
 
5
- before :all do
6
- setup_test_environment
7
- end
8
-
9
- before :each do
5
+ before do
10
6
  @connection = DataObjects::Connection.new(CONFIG.uri)
11
7
  end
12
8
 
13
- after :each do
9
+ after do
14
10
  @connection.close
15
11
  end
16
12
 
@@ -18,7 +14,7 @@ share_examples_for 'supporting ByteArray' do
18
14
 
19
15
  describe 'with automatic typecasting' do
20
16
 
21
- before do
17
+ before do
22
18
  @reader = @connection.create_command("SELECT cad_drawing FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
23
19
  @reader.next!
24
20
  @values = @reader.values
@@ -29,7 +25,7 @@ share_examples_for 'supporting ByteArray' do
29
25
  end
30
26
 
31
27
  it 'should return the correctly typed result' do
32
- @values.first.should be_kind_of(::Extlib::ByteArray)
28
+ @values.first.should.be.kind_of(::Extlib::ByteArray)
33
29
  end
34
30
 
35
31
  it 'should return the correct result' do
@@ -40,7 +36,7 @@ share_examples_for 'supporting ByteArray' do
40
36
 
41
37
  describe 'with manual typecasting' do
42
38
 
43
- before do
39
+ before do
44
40
  @command = @connection.create_command("SELECT cad_drawing FROM widgets WHERE ad_description = ?")
45
41
  @command.set_types(::Extlib::ByteArray)
46
42
  @reader = @command.execute_reader('Buy this product now!')
@@ -53,7 +49,7 @@ share_examples_for 'supporting ByteArray' do
53
49
  end
54
50
 
55
51
  it 'should return the correctly typed result' do
56
- @values.first.should be_kind_of(::Extlib::ByteArray)
52
+ @values.first.should.be.kind_of(::Extlib::ByteArray)
57
53
  end
58
54
 
59
55
  it 'should return the correct result' do
@@ -66,8 +62,8 @@ share_examples_for 'supporting ByteArray' do
66
62
 
67
63
  describe 'writing a ByteArray' do
68
64
 
69
- before do
70
- @reader = @connection.create_command("SELECT id FROM widgets WHERE id = ?").execute_reader(::Extlib::ByteArray.new("2"))
65
+ before do
66
+ @reader = @connection.create_command("SELECT ad_description FROM widgets WHERE cad_drawing = ?").execute_reader(::Extlib::ByteArray.new("CAD \001 \000 DRAWING"))
71
67
  @reader.next!
72
68
  @values = @reader.values
73
69
  end
@@ -78,7 +74,7 @@ share_examples_for 'supporting ByteArray' do
78
74
 
79
75
  it 'should return the correct entry' do
80
76
  #Some of the drivers starts autoincrementation from 0 not 1
81
- @values.first.should satisfy { |val| val == 2 or val == 1 }
77
+ @values.first.should == 'Buy this product now!'
82
78
  end
83
79
 
84
80
  end
@@ -1,16 +1,12 @@
1
- share_examples_for 'supporting Class' do
1
+ shared 'supporting Class' do
2
2
 
3
- include DataObjectsSpecHelpers
3
+ setup_test_environment
4
4
 
5
- before :all do
6
- setup_test_environment
7
- end
8
-
9
- before :each do
5
+ before do
10
6
  @connection = DataObjects::Connection.new(CONFIG.uri)
11
7
  end
12
8
 
13
- after :each do
9
+ after do
14
10
  @connection.close
15
11
  end
16
12
 
@@ -18,7 +14,7 @@ share_examples_for 'supporting Class' do
18
14
 
19
15
  describe 'with manual typecasting' do
20
16
 
21
- before do
17
+ before do
22
18
  @command = @connection.create_command("SELECT whitepaper_text FROM widgets WHERE ad_description = ?")
23
19
  @command.set_types(Class)
24
20
  @reader = @command.execute_reader('Buy this product now!')
@@ -31,7 +27,7 @@ share_examples_for 'supporting Class' do
31
27
  end
32
28
 
33
29
  it 'should return the correctly typed result' do
34
- @values.first.should be_kind_of(Class)
30
+ @values.first.should.be.kind_of(Class)
35
31
  end
36
32
 
37
33
  it 'should return the correct result' do
@@ -44,7 +40,7 @@ share_examples_for 'supporting Class' do
44
40
 
45
41
  describe 'writing a Class' do
46
42
 
47
- before do
43
+ before do
48
44
  @reader = @connection.create_command("SELECT whitepaper_text FROM widgets WHERE whitepaper_text = ?").execute_reader(String)
49
45
  @reader.next!
50
46
  @values = @reader.values
@@ -1,16 +1,12 @@
1
- share_examples_for 'supporting Date' do
1
+ shared 'supporting Date' do
2
2
 
3
- include DataObjectsSpecHelpers
3
+ setup_test_environment
4
4
 
5
- before :all do
6
- setup_test_environment
7
- end
8
-
9
- before :each do
5
+ before do
10
6
  @connection = DataObjects::Connection.new(CONFIG.uri)
11
7
  end
12
8
 
13
- after :each do
9
+ after do
14
10
  @connection.close
15
11
  end
16
12
 
@@ -18,7 +14,7 @@ share_examples_for 'supporting Date' do
18
14
 
19
15
  describe 'with manual typecasting' do
20
16
 
21
- before do
17
+ before do
22
18
  @command = @connection.create_command("SELECT release_datetime FROM widgets WHERE ad_description = ?")
23
19
  @command.set_types(Date)
24
20
  @reader = @command.execute_reader('Buy this product now!')
@@ -31,7 +27,7 @@ share_examples_for 'supporting Date' do
31
27
  end
32
28
 
33
29
  it 'should return the correctly typed result' do
34
- @values.first.should be_kind_of(Date)
30
+ @values.first.should.be.kind_of(Date)
35
31
  end
36
32
 
37
33
  it 'should return the correct result' do
@@ -42,7 +38,7 @@ share_examples_for 'supporting Date' do
42
38
 
43
39
  describe 'with manual typecasting a nil value' do
44
40
 
45
- before do
41
+ before do
46
42
  @command = @connection.create_command("SELECT release_date FROM widgets WHERE id = ?")
47
43
  @command.set_types(Date)
48
44
  @reader = @command.execute_reader(7)
@@ -55,11 +51,11 @@ share_examples_for 'supporting Date' do
55
51
  end
56
52
 
57
53
  it 'should return a nil class' do
58
- @values.first.should be_kind_of(NilClass)
54
+ @values.first.should.be.kind_of(NilClass)
59
55
  end
60
56
 
61
57
  it 'should return nil' do
62
- @values.first.should be_nil
58
+ @values.first.should.be.nil
63
59
  end
64
60
 
65
61
  end
@@ -68,7 +64,7 @@ share_examples_for 'supporting Date' do
68
64
 
69
65
  describe 'writing an Date' do
70
66
 
71
- before do
67
+ before do
72
68
  @reader = @connection.create_command("SELECT id FROM widgets WHERE release_date = ? ORDER BY id").execute_reader(Date.civil(2008, 2, 14))
73
69
  @reader.next!
74
70
  @values = @reader.values
@@ -80,26 +76,22 @@ share_examples_for 'supporting Date' do
80
76
 
81
77
  it 'should return the correct entry' do
82
78
  #Some of the drivers starts autoincrementation from 0 not 1
83
- @values.first.should satisfy { |val| val == 1 or val == 0 }
79
+ @values.first.should.satisfy { |val| val == 1 or val == 0 }
84
80
  end
85
81
 
86
82
  end
87
83
 
88
84
  end
89
85
 
90
- share_examples_for 'supporting Date autocasting' do
86
+ shared 'supporting Date autocasting' do
91
87
 
92
- include DataObjectsSpecHelpers
93
-
94
- before :all do
95
- setup_test_environment
96
- end
88
+ setup_test_environment
97
89
 
98
- before :each do
90
+ before do
99
91
  @connection = DataObjects::Connection.new(CONFIG.uri)
100
92
  end
101
93
 
102
- after :each do
94
+ after do
103
95
  @connection.close
104
96
  end
105
97
 
@@ -107,7 +99,7 @@ share_examples_for 'supporting Date autocasting' do
107
99
 
108
100
  describe 'with automatic typecasting' do
109
101
 
110
- before do
102
+ before do
111
103
  @reader = @connection.create_command("SELECT release_date FROM widgets WHERE ad_description = ?").execute_reader('Buy this product now!')
112
104
  @reader.next!
113
105
  @values = @reader.values
@@ -118,7 +110,7 @@ share_examples_for 'supporting Date autocasting' do
118
110
  end
119
111
 
120
112
  it 'should return the correctly typed result' do
121
- @values.first.should be_kind_of(Date)
113
+ @values.first.should.be.kind_of(Date)
122
114
  end
123
115
 
124
116
  it 'should return the correct result' do