ardb 0.21.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,9 +3,6 @@ source "https://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  gem 'rake'
6
- gem 'pry', "~> 0.9.0"
7
-
8
- platform :rbx do
9
- gem 'rubysl'
10
- end
6
+ gem 'pry', "~> 0.9.0"
7
+ gem 'i18n', "< 0.7"
11
8
 
@@ -18,12 +18,11 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_development_dependency("assert", ["~> 2.10"])
22
- gem.add_development_dependency("assert-mocha", ["~> 1.1"])
21
+ gem.add_development_dependency("assert", ["~> 2.14"])
23
22
 
24
23
  gem.add_dependency('activerecord', ["~> 3.2"])
25
24
  gem.add_dependency('activesupport', ["~> 3.2"])
26
25
  gem.add_dependency('ns-options', ["~> 1.1"])
27
- gem.add_dependency('scmd', ["~> 2.2"])
26
+ gem.add_dependency('scmd', ["~> 2.3"])
28
27
 
29
28
  end
@@ -1,3 +1,6 @@
1
+ require 'arel'
2
+ require 'ardb/relation_spy'
3
+
1
4
  module Ardb
2
5
 
3
6
  module RecordSpy
@@ -19,13 +22,16 @@ module Ardb
19
22
  module ClassMethods
20
23
 
21
24
  attr_accessor :table_name
22
- attr_reader :associations, :callbacks, :validations
25
+
26
+ # Associations
27
+
28
+ def associations
29
+ @associations ||= []
30
+ end
23
31
 
24
32
  [ :belongs_to, :has_one, :has_many ].each do |method_name|
25
33
 
26
34
  define_method(method_name) do |assoc_name, *args|
27
- @associations ||= []
28
-
29
35
  define_method(assoc_name) do
30
36
  instance_variable_get("@#{assoc_name}") || (method_name == :has_many ? [] : nil)
31
37
  end
@@ -33,57 +39,140 @@ module Ardb
33
39
  instance_variable_set("@#{assoc_name}", value)
34
40
  end
35
41
 
36
- @associations << Association.new(method_name, assoc_name, *args)
42
+ self.associations << Association.new(method_name, assoc_name, *args)
37
43
  end
38
44
 
39
45
  end
40
46
 
41
- [ :validates_acceptance_of, :validates_confirmation_of,
42
- :validates_exclusion_of, :validates_format_of, :validates_inclusion_of,
43
- :validates_length_of, :validates_numericality_of,
44
- :validates_presence_of, :validates_size_of, :validates_uniqueness_of
47
+ # Validations
48
+
49
+ def validations
50
+ @validations ||= []
51
+ end
52
+
53
+ [ :validates_acceptance_of,
54
+ :validates_confirmation_of,
55
+ :validates_exclusion_of,
56
+ :validates_format_of,
57
+ :validates_inclusion_of,
58
+ :validates_length_of,
59
+ :validates_numericality_of,
60
+ :validates_presence_of,
61
+ :validates_size_of,
62
+ :validates_uniqueness_of
45
63
  ].each do |method_name|
46
64
  type = method_name.to_s.match(/\Avalidates_(.+)_of\Z/)[1]
47
65
 
48
66
  define_method(method_name) do |*args|
49
- @validations ||= []
50
- @validations << Validation.new(type, *args)
67
+ self.validations << Validation.new(type, *args)
51
68
  end
52
69
 
53
70
  end
54
71
 
55
72
  def validates_associated(*args)
56
- @validations ||= []
57
- @validations << Validation.new(:associated, *args)
73
+ self.validations << Validation.new(:associated, *args)
58
74
  end
59
75
 
60
76
  def validates_with(*args)
61
- @validations ||= []
62
- @validations << Validation.new(:with, *args)
77
+ self.validations << Validation.new(:with, *args)
63
78
  end
64
79
 
65
80
  def validates_each(*args, &block)
66
- @validations ||= []
67
- @validations << Validation.new(:each, *args, &block)
81
+ self.validations << Validation.new(:each, *args, &block)
68
82
  end
69
83
 
70
84
  def validate(method_name = nil, &block)
71
- @validations ||= []
72
- @validations << Validation.new(:custom, method_name, &block)
85
+ self.validations << Validation.new(:custom, method_name, &block)
86
+ end
87
+
88
+ def callbacks
89
+ @callbacks ||= []
73
90
  end
74
91
 
75
- [ :before_validation, :after_validation,
76
- :before_create, :around_create, :after_create,
77
- :before_update, :around_update, :after_update,
78
- :before_save, :around_save, :after_save,
79
- :before_destroy, :around_destroy, :after_destroy,
80
- :after_commit, :after_rollback,
81
- :after_initialize, :after_find
92
+ # Callbacks
93
+
94
+ [ :before_validation,
95
+ :after_validation,
96
+ :before_create,
97
+ :around_create,
98
+ :after_create,
99
+ :before_update,
100
+ :around_update,
101
+ :after_update,
102
+ :before_save,
103
+ :around_save,
104
+ :after_save,
105
+ :before_destroy,
106
+ :around_destroy,
107
+ :after_destroy,
108
+ :after_commit,
109
+ :after_rollback,
110
+ :after_initialize,
111
+ :after_find
82
112
  ].each do |method_name|
83
113
 
84
114
  define_method(method_name) do |*args, &block|
85
- @callbacks ||= []
86
- @callbacks << Callback.new(method_name, *args, &block)
115
+ self.callbacks << Callback.new(method_name, *args, &block)
116
+ end
117
+
118
+ end
119
+
120
+ def custom_callback_types
121
+ @custom_callback_types ||= []
122
+ end
123
+
124
+ def define_model_callbacks(*args)
125
+ options = args.last.kind_of?(Hash) ? args.pop : {}
126
+ types = options[:only] || [:before, :around, :after]
127
+ metaclass = class << self; self; end
128
+
129
+ args.each do |name|
130
+ self.custom_callback_types << CallbackType.new(name, options)
131
+ types.each do |type|
132
+ method_name = "#{type}_#{name}"
133
+ metaclass.send(:define_method, method_name) do |*args, &block|
134
+ self.callbacks << Callback.new(method_name, *args, &block)
135
+ end
136
+ end
137
+ end
138
+ end
139
+
140
+ CallbackType = Struct.new(:name, :options)
141
+
142
+ # Scopes
143
+
144
+ attr_writer :relation_spy
145
+ def relation_spy
146
+ @relation_spy ||= RelationSpy.new
147
+ end
148
+
149
+ def arel_table
150
+ @arel_table ||= Arel::Table.new(self.table_name)
151
+ end
152
+
153
+ def scoped
154
+ self.relation_spy
155
+ end
156
+
157
+ [ :select,
158
+ :from,
159
+ :includes,
160
+ :joins,
161
+ :where,
162
+ :group,
163
+ :having,
164
+ :order,
165
+ :reverse_order,
166
+ :readonly,
167
+ :limit,
168
+ :offset,
169
+ :merge,
170
+ :except,
171
+ :only
172
+ ].each do |method_name|
173
+
174
+ define_method(method_name) do |*args|
175
+ self.relation_spy.send(method_name, *args)
87
176
  end
88
177
 
89
178
  end
@@ -98,6 +187,15 @@ module Ardb
98
187
  self.send("#{col}=", value)
99
188
  end
100
189
 
190
+ def manually_run_callbacks
191
+ @manually_run_callbacks ||= []
192
+ end
193
+
194
+ def run_callbacks(name, &block)
195
+ self.manually_run_callbacks << name
196
+ block.call if block
197
+ end
198
+
101
199
  end
102
200
 
103
201
  class Association
@@ -25,14 +25,24 @@ module Ardb
25
25
  @applied.map(&:to_sql).join(", ")
26
26
  end
27
27
 
28
+ def reset!
29
+ @applied.clear
30
+ @results.clear
31
+ @offset_value = nil
32
+ @limit_value = nil
33
+ end
34
+
28
35
  # ActiveRecord::QueryMethods
29
36
 
30
37
  [ :select,
31
38
  :from,
32
- :includes, :joins,
39
+ :includes,
40
+ :joins,
33
41
  :where,
34
- :group, :having,
35
- :order, :reverse_order,
42
+ :group,
43
+ :having,
44
+ :order,
45
+ :reverse_order,
36
46
  :readonly
37
47
  ].each do |type|
38
48
 
@@ -1,3 +1,3 @@
1
1
  module Ardb
2
- VERSION = "0.21.0"
2
+ VERSION = "0.22.0"
3
3
  end
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
6
6
 
7
7
  # require pry for debugging (`binding.pry`)
8
8
  require 'pry'
9
- require 'assert-mocha' if defined?(Assert)
9
+ require 'test/support/factory'
10
10
 
11
11
  ENV['ARDB_DB_FILE'] = 'tmp/testdb/config/db'
12
12
  require 'ardb'
@@ -0,0 +1,6 @@
1
+ require 'assert/factory'
2
+
3
+ module Factory
4
+ extend Assert::Factory
5
+
6
+ end
@@ -54,13 +54,7 @@ class Ardb::Adapter::Postgresql
54
54
  setup do
55
55
  cmd_str = "psql -f \"#{@adapter.sql_schema_path}\" #{@adapter.database}"
56
56
  @cmd_spy = CmdSpy.new
57
- Scmd.stubs(:new).tap do |s|
58
- s.with(cmd_str, @env)
59
- s.returns(@cmd_spy)
60
- end
61
- end
62
- teardown do
63
- Scmd.unstub(:new)
57
+ Assert.stub(Scmd, :new).with(cmd_str, @env){ @cmd_spy }
64
58
  end
65
59
 
66
60
  should "run a command for loading a SQL schema using `load_sql_schema`" do
@@ -75,13 +69,7 @@ class Ardb::Adapter::Postgresql
75
69
  cmd_str = "pg_dump -i -s -x -O -f " \
76
70
  "\"#{@adapter.sql_schema_path}\" #{@adapter.database}"
77
71
  @cmd_spy = CmdSpy.new
78
- Scmd.stubs(:new).tap do |s|
79
- s.with(cmd_str, @env)
80
- s.returns(@cmd_spy)
81
- end
82
- end
83
- teardown do
84
- Scmd.unstub(:new)
72
+ Assert.stub(Scmd, :new).with(cmd_str, @env){ @cmd_spy }
85
73
  end
86
74
 
87
75
  should "run a command for dumping a SQL schema using `dump_sql_schema`" do
@@ -6,13 +6,17 @@ module Ardb::RecordSpy
6
6
  class UnitTests < Assert::Context
7
7
  desc "Ardb::RecordSpy"
8
8
  setup do
9
- @instance = MyRecord.new
9
+ @record_spy_class = Class.new do
10
+ include Ardb::RecordSpy
11
+ attr_accessor :name
12
+ end
10
13
  end
11
- subject{ MyRecord }
14
+ subject{ @record_spy_class }
12
15
 
13
16
  should have_accessors :table_name
14
- should have_readers :associations, :callbacks, :validations
17
+ should have_imeths :associations
15
18
  should have_imeths :belongs_to, :has_many, :has_one
19
+ should have_imeths :validations
16
20
  should have_imeths :validates_acceptance_of, :validates_confirmation_of
17
21
  should have_imeths :validates_exclusion_of, :validates_format_of
18
22
  should have_imeths :validates_inclusion_of, :validates_length_of
@@ -20,6 +24,7 @@ module Ardb::RecordSpy
20
24
  should have_imeths :validates_size_of, :validates_uniqueness_of
21
25
  should have_imeths :validates_associated, :validates_with, :validates_each
22
26
  should have_imeths :validate
27
+ should have_imeths :callbacks
23
28
  should have_imeths :before_validation, :after_validation
24
29
  should have_imeths :before_create, :around_create, :after_create
25
30
  should have_imeths :before_update, :around_update, :after_update
@@ -27,16 +32,22 @@ module Ardb::RecordSpy
27
32
  should have_imeths :before_destroy, :around_destroy, :after_destroy
28
33
  should have_imeths :after_commit, :after_rollback
29
34
  should have_imeths :after_initialize, :after_find
30
-
31
- should "included the record spy instance methods" do
32
- assert_includes Ardb::RecordSpy::InstanceMethods, subject.included_modules
33
- end
35
+ should have_imeths :custom_callback_types, :define_model_callbacks
36
+ should have_writers :relation_spy
37
+ should have_imeths :relation_spy, :arel_table, :scoped
38
+ should have_imeths :select, :from, :includes, :joins, :where
39
+ should have_imeths :group, :having, :order, :reverse_order, :readonly
40
+ should have_imeths :limit, :offset, :merge, :except, :only
34
41
 
35
42
  should "allow reading and writing the record's table name" do
36
43
  subject.table_name = 'my_records'
37
44
  assert_equal 'my_records', subject.table_name
38
45
  end
39
46
 
47
+ should "default its associations" do
48
+ assert_equal [], subject.associations
49
+ end
50
+
40
51
  should "add an association config with #belongs_to" do
41
52
  subject.belongs_to :area, :foreign_key => :area_id
42
53
  association = subject.associations.last
@@ -61,6 +72,10 @@ module Ardb::RecordSpy
61
72
  assert_equal 'Linking', association.options[:class_name]
62
73
  end
63
74
 
75
+ should "default its validations" do
76
+ assert_equal [], subject.validations
77
+ end
78
+
64
79
  should "add a validation config for '*_of' validations" do
65
80
  subject.validates_presence_of :name, :email, :on => :create
66
81
  validation = subject.validations.last
@@ -108,10 +123,14 @@ module Ardb::RecordSpy
108
123
  subject.validate(&block)
109
124
  validation = subject.validations.last
110
125
  assert_equal :custom, validation.type
111
- assert_equal block, validation.block
126
+ assert_equal block, validation.block
112
127
  end
113
128
 
114
- should "add a callback config with with a method name" do
129
+ should "default its callbacks" do
130
+ assert_equal [], subject.validations
131
+ end
132
+
133
+ should "add a callback config with a method name" do
115
134
  subject.after_initialize :a_callback_method
116
135
  callback = subject.callbacks.last
117
136
  assert_equal :after_initialize, callback.type
@@ -125,8 +144,141 @@ module Ardb::RecordSpy
125
144
  callback = subject.callbacks.last
126
145
  assert_equal :before_validation, callback.type
127
146
  assert_equal :create, callback.options[:on]
128
- @instance.instance_eval(&callback.block)
129
- assert_equal 'test', @instance.name
147
+ record_spy = subject.new
148
+ record_spy.instance_eval(&callback.block)
149
+ assert_equal 'test', record_spy.name
150
+ end
151
+
152
+ should "default its custom callback types" do
153
+ assert_equal [], subject.custom_callback_types
154
+ end
155
+
156
+ should "add a custom callback type using `define_model_callbacks`" do
157
+ name = Factory.string
158
+ options = { Factory.string => Factory.string }
159
+ subject.define_model_callbacks(name, options)
160
+
161
+ callback_type = subject.custom_callback_types.last
162
+ assert_equal name, callback_type.name
163
+ assert_equal options, callback_type.options
164
+ end
165
+
166
+ should "define callback methods using `define_model_callbacks`" do
167
+ name = Factory.string
168
+ subject.define_model_callbacks(name)
169
+
170
+ assert_respond_to "before_#{name}", subject
171
+ assert_respond_to "around_#{name}", subject
172
+ assert_respond_to "after_#{name}", subject
173
+
174
+ callback_name = ["before_#{name}", "around_#{name}", "after_#{name}"].choice
175
+ method_name = Factory.string
176
+ subject.send(callback_name, method_name)
177
+ callback = subject.callbacks.last
178
+ assert_equal callback_name.to_sym, callback.type
179
+ assert_equal [method_name], callback.args
180
+
181
+ name = Factory.string
182
+ subject.define_model_callbacks(name, :only => [:before])
183
+
184
+ assert_respond_to "before_#{name}", subject
185
+ assert_not_respond_to "around_#{name}", subject
186
+ assert_not_respond_to "after_#{name}", subject
187
+ end
188
+
189
+ should "know its relation spy" do
190
+ assert_instance_of Ardb::RelationSpy, subject.relation_spy
191
+ spy = subject.relation_spy
192
+ assert_same spy, subject.relation_spy
193
+ end
194
+
195
+ should "know its arel table" do
196
+ subject.table_name = Factory.string
197
+ assert_instance_of Arel::Table, subject.arel_table
198
+ assert_equal subject.table_name, subject.arel_table.name
199
+ end
200
+
201
+ should "return its relation spy using `scoped`" do
202
+ assert_same subject.relation_spy, subject.scoped
203
+ end
204
+
205
+ should "demeter its scope methods to its relation spy" do
206
+ relation_spy = subject.relation_spy
207
+
208
+ select_args = [Factory.string]
209
+ subject.select(*select_args)
210
+ assert_equal :select, relation_spy.applied.last.type
211
+ assert_equal select_args, relation_spy.applied.last.args
212
+
213
+ from_args = [Factory.string]
214
+ subject.from(*from_args)
215
+ assert_equal :from, relation_spy.applied.last.type
216
+ assert_equal from_args, relation_spy.applied.last.args
217
+
218
+ includes_args = [Factory.string]
219
+ subject.includes(*includes_args)
220
+ assert_equal :includes, relation_spy.applied.last.type
221
+ assert_equal includes_args, relation_spy.applied.last.args
222
+
223
+ joins_args = [Factory.string]
224
+ subject.joins(*joins_args)
225
+ assert_equal :joins, relation_spy.applied.last.type
226
+ assert_equal joins_args, relation_spy.applied.last.args
227
+
228
+ where_args = [Factory.string]
229
+ subject.where(*where_args)
230
+ assert_equal :where, relation_spy.applied.last.type
231
+ assert_equal where_args, relation_spy.applied.last.args
232
+
233
+ group_args = [Factory.string]
234
+ subject.group(*group_args)
235
+ assert_equal :group, relation_spy.applied.last.type
236
+ assert_equal group_args, relation_spy.applied.last.args
237
+
238
+ having_args = [Factory.string]
239
+ subject.having(*having_args)
240
+ assert_equal :having, relation_spy.applied.last.type
241
+ assert_equal having_args, relation_spy.applied.last.args
242
+
243
+ order_args = [Factory.string]
244
+ subject.order(*order_args)
245
+ assert_equal :order, relation_spy.applied.last.type
246
+ assert_equal order_args, relation_spy.applied.last.args
247
+
248
+ subject.reverse_order
249
+ assert_equal :reverse_order, relation_spy.applied.last.type
250
+
251
+ readonly_args = [Factory.boolean]
252
+ subject.readonly(*readonly_args)
253
+ assert_equal :readonly, relation_spy.applied.last.type
254
+ assert_equal readonly_args, relation_spy.applied.last.args
255
+
256
+ limit_args = [Factory.integer]
257
+ subject.limit(*limit_args)
258
+ assert_equal :limit, relation_spy.applied.last.type
259
+ assert_equal limit_args, relation_spy.applied.last.args
260
+
261
+ offset_args = [Factory.integer]
262
+ subject.offset(*offset_args)
263
+ assert_equal :offset, relation_spy.applied.last.type
264
+ assert_equal offset_args, relation_spy.applied.last.args
265
+
266
+ merge_args = [Factory.string]
267
+ subject.merge(*merge_args)
268
+ assert_equal :merge, relation_spy.applied.last.type
269
+ assert_equal merge_args, relation_spy.applied.last.args
270
+
271
+ except_args = [Factory.string]
272
+ except_called_with = nil
273
+ Assert.stub(relation_spy, :except){ |*args| except_called_with = args }
274
+ subject.except(*except_args)
275
+ assert_equal except_args, except_called_with
276
+
277
+ only_args = [Factory.string]
278
+ only_called_with = nil
279
+ Assert.stub(relation_spy, :only){ |*args| only_called_with = args }
280
+ subject.only(*only_args)
281
+ assert_equal only_args, only_called_with
130
282
  end
131
283
 
132
284
  end
@@ -151,10 +303,14 @@ module Ardb::RecordSpy
151
303
  end
152
304
 
153
305
  class InstanceTests < UnitTests
306
+ setup do
307
+ @instance = MyRecord.new
308
+ end
154
309
  subject{ @instance }
155
310
 
156
311
  should have_accessors :id
157
312
  should have_imeths :update_column
313
+ should have_imeths :manually_run_callbacks, :run_callbacks
158
314
 
159
315
  should "allow spying the update_column method by just writing the value" do
160
316
  assert_not_equal 'updated', subject.name
@@ -177,6 +333,23 @@ module Ardb::RecordSpy
177
333
  assert_equal [1,2,3], subject.hm_things
178
334
  end
179
335
 
336
+ should "default its manually run callbacks" do
337
+ assert_equal [], subject.manually_run_callbacks
338
+ end
339
+
340
+ should "spy any callbacks that are manually run" do
341
+ assert_empty subject.manually_run_callbacks
342
+ name = Factory.string
343
+ subject.run_callbacks(name)
344
+ assert_includes name, subject.manually_run_callbacks
345
+
346
+ name = Factory.string
347
+ block_called = false
348
+ subject.run_callbacks(name){ block_called = true }
349
+ assert_includes name, subject.manually_run_callbacks
350
+ assert_true block_called
351
+ end
352
+
180
353
  end
181
354
 
182
355
  class MyRecord
@@ -13,7 +13,7 @@ class Ardb::RelationSpy
13
13
  should have_readers :applied
14
14
  should have_accessors :results
15
15
  should have_accessors :limit_value, :offset_value
16
- should have_imeths :to_sql
16
+ should have_imeths :to_sql, :reset!
17
17
  should have_imeths :select
18
18
  should have_imeths :from
19
19
  should have_imeths :includes, :joins
@@ -27,10 +27,10 @@ class Ardb::RelationSpy
27
27
  should have_imeths :count
28
28
 
29
29
  should "default it's attributes" do
30
- assert_equal [], subject.applied
31
- assert_equal [], subject.results
32
- assert_equal nil, subject.limit_value
33
- assert_equal nil, subject.offset_value
30
+ assert_equal [], subject.applied
31
+ assert_equal [], subject.results
32
+ assert_nil subject.limit_value
33
+ assert_nil subject.offset_value
34
34
  end
35
35
 
36
36
  should "dup its applied and results arrays when copied" do
@@ -57,6 +57,18 @@ class Ardb::RelationSpy
57
57
  assert_equal expected, subject.to_sql
58
58
  end
59
59
 
60
+ should "be able to be reset" do
61
+ Factory.integer(3).times.each{ subject.applied << Factory.string }
62
+ Factory.integer(3).times.each{ subject.results << Factory.string }
63
+ subject.limit_value = Factory.integer
64
+ subject.offset_value = Factory.integer
65
+ subject.reset!
66
+ assert_equal [], subject.applied
67
+ assert_equal [], subject.results
68
+ assert_nil subject.limit_value
69
+ assert_nil subject.offset_value
70
+ end
71
+
60
72
  end
61
73
 
62
74
  class SelectTests < UnitTests
@@ -66,7 +78,7 @@ class Ardb::RelationSpy
66
78
  @applied = subject.applied.first
67
79
  end
68
80
 
69
- should "have added a select applied expression with the passed args" do
81
+ should "add a select applied expression with the passed args" do
70
82
  assert_instance_of AppliedExpression, @applied
71
83
  assert_equal :select, @applied.type
72
84
  assert_equal [ :column_a, :column_b ], @applied.args
@@ -81,7 +93,7 @@ class Ardb::RelationSpy
81
93
  @applied = subject.applied.first
82
94
  end
83
95
 
84
- should "have added a from applied expression with the passed args" do
96
+ should "add a from applied expression with the passed args" do
85
97
  assert_instance_of AppliedExpression, @applied
86
98
  assert_equal :from, @applied.type
87
99
  assert_equal [ "some SQL" ], @applied.args
@@ -96,7 +108,7 @@ class Ardb::RelationSpy
96
108
  @applied = subject.applied.first
97
109
  end
98
110
 
99
- should "have added an includes applied expression with the passed args" do
111
+ should "add an includes applied expression with the passed args" do
100
112
  assert_instance_of AppliedExpression, @applied
101
113
  assert_equal :includes, @applied.type
102
114
  assert_equal [ :table_a, :table_b ], @applied.args
@@ -111,7 +123,7 @@ class Ardb::RelationSpy
111
123
  @applied = subject.applied.first
112
124
  end
113
125
 
114
- should "have added a joins applied expression with the passed args" do
126
+ should "add a joins applied expression with the passed args" do
115
127
  assert_instance_of AppliedExpression, @applied
116
128
  assert_equal :joins, @applied.type
117
129
  assert_equal [ :table_a, :table_b ], @applied.args
@@ -126,7 +138,7 @@ class Ardb::RelationSpy
126
138
  @applied = subject.applied.first
127
139
  end
128
140
 
129
- should "have added a where applied expression with the passed args" do
141
+ should "add a where applied expression with the passed args" do
130
142
  assert_instance_of AppliedExpression, @applied
131
143
  assert_equal :where, @applied.type
132
144
  assert_equal [ { :column_a => 'some value' } ], @applied.args
@@ -141,7 +153,7 @@ class Ardb::RelationSpy
141
153
  @applied = subject.applied.first
142
154
  end
143
155
 
144
- should "have added an order applied expression with the passed args" do
156
+ should "add an order applied expression with the passed args" do
145
157
  assert_instance_of AppliedExpression, @applied
146
158
  assert_equal :order, @applied.type
147
159
  assert_equal [ :column_a, :column_b ], @applied.args
@@ -156,7 +168,7 @@ class Ardb::RelationSpy
156
168
  @applied = subject.applied.first
157
169
  end
158
170
 
159
- should "have added a reverse order applied expression with the passed args" do
171
+ should "add a reverse order applied expression with the passed args" do
160
172
  assert_instance_of AppliedExpression, @applied
161
173
  assert_equal :reverse_order, @applied.type
162
174
  end
@@ -170,7 +182,7 @@ class Ardb::RelationSpy
170
182
  @applied = subject.applied.first
171
183
  end
172
184
 
173
- should "have added a group applied expression with the passed args" do
185
+ should "add a group applied expression with the passed args" do
174
186
  assert_instance_of AppliedExpression, @applied
175
187
  assert_equal :group, @applied.type
176
188
  assert_equal [ :column_a, :column_b ], @applied.args
@@ -185,7 +197,7 @@ class Ardb::RelationSpy
185
197
  @applied = subject.applied.first
186
198
  end
187
199
 
188
- should "have added a having applied expression with the passed args" do
200
+ should "add a having applied expression with the passed args" do
189
201
  assert_instance_of AppliedExpression, @applied
190
202
  assert_equal :having, @applied.type
191
203
  assert_equal [ 'COUNT(column_a) > 0' ], @applied.args
@@ -200,7 +212,7 @@ class Ardb::RelationSpy
200
212
  @applied = subject.applied.first
201
213
  end
202
214
 
203
- should "have added a readonly applied expression with the passed args" do
215
+ should "add a readonly applied expression with the passed args" do
204
216
  assert_instance_of AppliedExpression, @applied
205
217
  assert_equal :readonly, @applied.type
206
218
  assert_equal [ true ], @applied.args
@@ -215,7 +227,7 @@ class Ardb::RelationSpy
215
227
  @applied = subject.applied.first
216
228
  end
217
229
 
218
- should "have added a limit applied expression with the passed args" do
230
+ should "add a limit applied expression with the passed args" do
219
231
  assert_instance_of AppliedExpression, @applied
220
232
  assert_equal :limit, @applied.type
221
233
  assert_equal [ 100 ], @applied.args
@@ -234,7 +246,7 @@ class Ardb::RelationSpy
234
246
  @applied = subject.applied.first
235
247
  end
236
248
 
237
- should "have added a offset applied expression with the passed args" do
249
+ should "add an offset applied expression with the passed args" do
238
250
  assert_instance_of AppliedExpression, @applied
239
251
  assert_equal :offset, @applied.type
240
252
  assert_equal [ 100 ], @applied.args
@@ -269,7 +281,7 @@ class Ardb::RelationSpy
269
281
  @applied = subject.applied.first
270
282
  end
271
283
 
272
- should "have added a merge applied expression with the passed args" do
284
+ should "add a merge applied expression with the passed args" do
273
285
  assert_instance_of AppliedExpression, @applied
274
286
  assert_equal :merge, @applied.type
275
287
  assert_equal [ @fake_relation ], @applied.args
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ardb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 75
4
+ hash: 71
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 21
8
+ - 22
9
9
  - 0
10
- version: 0.21.0
10
+ version: 0.22.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2014-06-13 00:00:00 Z
19
+ date: 2015-07-08 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -24,32 +24,17 @@ dependencies:
24
24
  requirements:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
- hash: 23
27
+ hash: 31
28
28
  segments:
29
29
  - 2
30
- - 10
31
- version: "2.10"
32
- version_requirements: *id001
30
+ - 14
31
+ version: "2.14"
33
32
  type: :development
34
33
  name: assert
34
+ version_requirements: *id001
35
35
  prerelease: false
36
36
  - !ruby/object:Gem::Dependency
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
40
- - - ~>
41
- - !ruby/object:Gem::Version
42
- hash: 13
43
- segments:
44
- - 1
45
- - 1
46
- version: "1.1"
47
- version_requirements: *id002
48
- type: :development
49
- name: assert-mocha
50
- prerelease: false
51
- - !ruby/object:Gem::Dependency
52
- requirement: &id003 !ruby/object:Gem::Requirement
53
38
  none: false
54
39
  requirements:
55
40
  - - ~>
@@ -59,12 +44,12 @@ dependencies:
59
44
  - 3
60
45
  - 2
61
46
  version: "3.2"
62
- version_requirements: *id003
63
47
  type: :runtime
64
48
  name: activerecord
49
+ version_requirements: *id002
65
50
  prerelease: false
66
51
  - !ruby/object:Gem::Dependency
67
- requirement: &id004 !ruby/object:Gem::Requirement
52
+ requirement: &id003 !ruby/object:Gem::Requirement
68
53
  none: false
69
54
  requirements:
70
55
  - - ~>
@@ -74,12 +59,12 @@ dependencies:
74
59
  - 3
75
60
  - 2
76
61
  version: "3.2"
77
- version_requirements: *id004
78
62
  type: :runtime
79
63
  name: activesupport
64
+ version_requirements: *id003
80
65
  prerelease: false
81
66
  - !ruby/object:Gem::Dependency
82
- requirement: &id005 !ruby/object:Gem::Requirement
67
+ requirement: &id004 !ruby/object:Gem::Requirement
83
68
  none: false
84
69
  requirements:
85
70
  - - ~>
@@ -89,24 +74,24 @@ dependencies:
89
74
  - 1
90
75
  - 1
91
76
  version: "1.1"
92
- version_requirements: *id005
93
77
  type: :runtime
94
78
  name: ns-options
79
+ version_requirements: *id004
95
80
  prerelease: false
96
81
  - !ruby/object:Gem::Dependency
97
- requirement: &id006 !ruby/object:Gem::Requirement
82
+ requirement: &id005 !ruby/object:Gem::Requirement
98
83
  none: false
99
84
  requirements:
100
85
  - - ~>
101
86
  - !ruby/object:Gem::Version
102
- hash: 7
87
+ hash: 5
103
88
  segments:
104
89
  - 2
105
- - 2
106
- version: "2.2"
107
- version_requirements: *id006
90
+ - 3
91
+ version: "2.3"
108
92
  type: :runtime
109
93
  name: scmd
94
+ version_requirements: *id005
110
95
  prerelease: false
111
96
  description: Activerecord database tools.
112
97
  email:
@@ -147,6 +132,7 @@ files:
147
132
  - lib/ardb/version.rb
148
133
  - log/.gitkeep
149
134
  - test/helper.rb
135
+ - test/support/factory.rb
150
136
  - test/unit/adapter/base_tests.rb
151
137
  - test/unit/adapter/mysql_tests.rb
152
138
  - test/unit/adapter/postgresql_tests.rb
@@ -206,12 +192,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
192
  requirements: []
207
193
 
208
194
  rubyforge_project:
209
- rubygems_version: 1.8.29
195
+ rubygems_version: 1.8.25
210
196
  signing_key:
211
197
  specification_version: 3
212
198
  summary: Activerecord database tools.
213
199
  test_files:
214
200
  - test/helper.rb
201
+ - test/support/factory.rb
215
202
  - test/unit/adapter/base_tests.rb
216
203
  - test/unit/adapter/mysql_tests.rb
217
204
  - test/unit/adapter/postgresql_tests.rb