data_objects 0.10.3 → 0.10.4.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/LICENSE +1 -1
  2. data/README.markdown +1 -1
  3. data/Rakefile +6 -32
  4. data/lib/data_objects/connection.rb +9 -6
  5. data/lib/data_objects/pooling.rb +1 -1
  6. data/lib/data_objects/spec/lib/pending_helpers.rb +11 -0
  7. data/lib/data_objects/spec/{helpers → lib}/ssl.rb +0 -0
  8. data/lib/data_objects/spec/setup.rb +5 -0
  9. data/lib/data_objects/spec/{command_spec.rb → shared/command_spec.rb} +54 -50
  10. data/lib/data_objects/spec/shared/connection_spec.rb +245 -0
  11. data/lib/data_objects/spec/{encoding_spec.rb → shared/encoding_spec.rb} +41 -43
  12. data/lib/data_objects/spec/shared/error/sql_error_spec.rb +30 -0
  13. data/lib/data_objects/spec/{quoting_spec.rb → shared/quoting_spec.rb} +0 -0
  14. data/lib/data_objects/spec/{reader_spec.rb → shared/reader_spec.rb} +31 -26
  15. data/lib/data_objects/spec/shared/result_spec.rb +79 -0
  16. data/lib/data_objects/spec/{typecast → shared/typecast}/array_spec.rb +4 -2
  17. data/lib/data_objects/spec/{typecast → shared/typecast}/bigdecimal_spec.rb +12 -8
  18. data/lib/data_objects/spec/{typecast → shared/typecast}/boolean_spec.rb +14 -10
  19. data/lib/data_objects/spec/{typecast → shared/typecast}/byte_array_spec.rb +6 -4
  20. data/lib/data_objects/spec/{typecast → shared/typecast}/class_spec.rb +5 -3
  21. data/lib/data_objects/spec/{typecast → shared/typecast}/date_spec.rb +13 -9
  22. data/lib/data_objects/spec/{typecast → shared/typecast}/datetime_spec.rb +14 -11
  23. data/lib/data_objects/spec/{typecast → shared/typecast}/float_spec.rb +17 -13
  24. data/lib/data_objects/spec/{typecast → shared/typecast}/integer_spec.rb +7 -5
  25. data/lib/data_objects/spec/{typecast → shared/typecast}/ipaddr_spec.rb +0 -0
  26. data/lib/data_objects/spec/{typecast → shared/typecast}/nil_spec.rb +23 -17
  27. data/lib/data_objects/spec/{typecast → shared/typecast}/other_spec.rb +11 -9
  28. data/lib/data_objects/spec/{typecast → shared/typecast}/range_spec.rb +4 -2
  29. data/lib/data_objects/spec/{typecast → shared/typecast}/string_spec.rb +10 -8
  30. data/lib/data_objects/spec/{typecast → shared/typecast}/time_spec.rb +44 -6
  31. data/lib/data_objects/transaction.rb +9 -0
  32. data/lib/data_objects/uri.rb +62 -4
  33. data/lib/data_objects/version.rb +1 -1
  34. data/spec/command_spec.rb +2 -2
  35. data/spec/connection_spec.rb +45 -25
  36. data/spec/pooling_spec.rb +9 -9
  37. data/spec/reader_spec.rb +11 -12
  38. data/spec/result_spec.rb +13 -11
  39. data/spec/spec_helper.rb +1 -16
  40. data/spec/transaction_spec.rb +9 -11
  41. data/spec/uri_spec.rb +35 -27
  42. data/tasks/spec.rake +8 -17
  43. metadata +40 -56
  44. data/lib/data_objects/spec/bacon.rb +0 -9
  45. data/lib/data_objects/spec/connection_spec.rb +0 -217
  46. data/lib/data_objects/spec/error/sql_error_spec.rb +0 -19
  47. data/lib/data_objects/spec/helpers/immediate_red_green_output.rb +0 -59
  48. data/lib/data_objects/spec/helpers/pending.rb +0 -22
  49. data/lib/data_objects/spec/result_spec.rb +0 -79
  50. data/tasks/metrics.rake +0 -36
@@ -1,19 +0,0 @@
1
- shared 'raising a SQLError' do
2
-
3
- setup_test_environment
4
-
5
- before do
6
- @connection = DataObjects::Connection.new(CONFIG.uri)
7
- @invalid_query = @connection.create_command("SLCT * FROM widgets WHERE ad_description = ? order by id")
8
- @invalid_result = @connection.create_command("SELECT MAX((SELECT 1 UNION SELECT 2))")
9
- end
10
-
11
- it 'should raise an error on an invalid query' do
12
- should.raise(DataObjects::SQLError) { @invalid_query.execute_reader('Buy this product now!') }
13
- end
14
-
15
- it 'should raise on an invalid result set' do
16
- should.raise(DataObjects::SQLError) { @invalid_result.execute_reader }
17
- end
18
-
19
- end
@@ -1,59 +0,0 @@
1
- module Bacon
2
- module ImmediateRedGreenOutput
3
-
4
- def handle_specification(name)
5
- yield
6
- @current_group = name
7
- end
8
-
9
- def handle_requirement(description)
10
- error = yield
11
- if error.empty?
12
- example_passed
13
- elsif error == 'PENDING'
14
- example_pending
15
- else
16
- example_failed(error, description, Counter[:specifications])
17
- end
18
- end
19
-
20
- def handle_summary
21
- puts
22
- puts ErrorLog
23
- counter = Counter.values_at(:specifications, :requirements, :failed, :errors, :pending)
24
- message = ("%d tests, %d assertions, %d failures, %d errors, %d pending" % counter)
25
- color = (counter[2].to_i != 0 || counter[3].to_i != 0 ? :red : (counter[4].to_i != 0 ? :yellow : :green))
26
- puts self.send(color, message)
27
- end
28
-
29
- private
30
-
31
- def example_failed(error, description, counter)
32
- if @current_group
33
- puts
34
- puts @current_group
35
- @current_group = nil # only print the group name once
36
- end
37
-
38
- if error == 'FAILED'
39
- puts red("- #{description} (FAILED - #{counter})")
40
- puts ErrorLog if Backtraces # dump stacktrace immediately
41
- else
42
- puts red("- #{description} (ERROR - #{counter})")
43
- end
44
- end
45
-
46
- def example_passed
47
- print green('.')
48
- end
49
-
50
- def example_pending
51
- print yellow('*')
52
- end
53
-
54
- def red(s) "\e[31m#{s}\e[0m"; end
55
- def green(s) "\e[32m#{s}\e[0m"; end
56
- def yellow(s) "\e[33m#{s}\e[0m"; end
57
-
58
- end
59
- end
@@ -1,22 +0,0 @@
1
- module DataObjects::Spec
2
- module Pending
3
-
4
- def pending(message = '')
5
- raise Bacon::Error.new(:pending, message)
6
- end
7
-
8
- def pending_if(message, boolean)
9
- if boolean
10
- pending(message) { yield }
11
- else
12
- yield
13
- end
14
- end
15
- end
16
- end
17
-
18
- module Bacon
19
- class Context
20
- include DataObjects::Spec::Pending
21
- end
22
- end
@@ -1,79 +0,0 @@
1
- shared 'a Result' do
2
-
3
- setup_test_environment
4
-
5
- before do
6
- @connection = DataObjects::Connection.new(CONFIG.uri)
7
- @result = @connection.create_command("INSERT INTO users (name) VALUES (?)").execute_non_query("monkey")
8
- end
9
-
10
- after do
11
- @connection.close
12
- end
13
-
14
- it 'should respond to #affected_rows' do @result.should.respond_to(:affected_rows) end
15
-
16
- describe 'affected_rows' do
17
-
18
- it 'should return the number of affected rows' do
19
- @result.affected_rows.should == 1
20
- end
21
-
22
- end
23
-
24
- end
25
-
26
- shared 'a Result which returns inserted key with sequences' do
27
-
28
- before do
29
- setup_test_environment
30
- @connection = DataObjects::Connection.new(CONFIG.uri)
31
- command = @connection.create_command("INSERT INTO users (name) VALUES (?)")
32
- # execute the command twice and expose the second result
33
- command.execute_non_query("monkey")
34
- @result = command.execute_non_query("monkey")
35
- end
36
-
37
- after do
38
- @connection.close
39
- end
40
-
41
- it 'should respond to #affected_rows' do @result.should.respond_to(:affected_rows) end
42
-
43
- describe 'insert_id' do
44
-
45
- it 'should return the insert_id' do
46
- # This is actually the 2nd record inserted
47
- @result.insert_id.should == 2
48
- end
49
-
50
- end
51
-
52
- end
53
-
54
- shared 'a Result which returns nil without sequences' do
55
-
56
- before do
57
- setup_test_environment
58
- @connection = DataObjects::Connection.new(CONFIG.uri)
59
- command = @connection.create_command("INSERT INTO invoices (invoice_number) VALUES (?)")
60
- # execute the command twice and expose the second result
61
- @result = command.execute_non_query("monkey")
62
- end
63
-
64
- after do
65
- @connection.close
66
- end
67
-
68
- it 'should respond to #affected_rows' do @result.should.respond_to(:affected_rows) end
69
-
70
- describe 'insert_id' do
71
-
72
- it 'should return the insert_id' do
73
- # This is actually the 2nd record inserted
74
- @result.insert_id.should.be.nil
75
- end
76
-
77
- end
78
-
79
- end
data/tasks/metrics.rake DELETED
@@ -1,36 +0,0 @@
1
- begin
2
- require 'metric_fu'
3
- rescue LoadError
4
- namespace :metrics do
5
- task :all do
6
- abort 'metric_fu is not available. In order to run metrics:all, you must: gem install metric_fu'
7
- end
8
- end
9
- end
10
-
11
- begin
12
- require 'reek/adapters/rake_task'
13
-
14
- Reek::RakeTask.new do |t|
15
- t.fail_on_error = true
16
- t.verbose = false
17
- t.source_files = 'lib/**/*.rb'
18
- end
19
- rescue LoadError
20
- task :reek do
21
- abort 'Reek is not available. In order to run reek, you must: gem install reek'
22
- end
23
- end
24
-
25
- begin
26
- require 'roodi'
27
- require 'roodi_task'
28
-
29
- RoodiTask.new do |t|
30
- t.verbose = false
31
- end
32
- rescue LoadError
33
- task :roodi do
34
- abort 'Roodi is not available. In order to run roodi, you must: gem install roodi'
35
- end
36
- end