shoulda-matchers 2.4.0 → 2.5.0

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +7 -4
  3. data/Appraisals +19 -7
  4. data/Gemfile.lock +1 -1
  5. data/NEWS.md +35 -0
  6. data/README.md +1204 -46
  7. data/features/step_definitions/rails_steps.rb +1 -1
  8. data/gemfiles/3.0.gemfile.lock +1 -1
  9. data/gemfiles/3.1.gemfile.lock +1 -1
  10. data/gemfiles/3.2.gemfile.lock +1 -1
  11. data/gemfiles/{4.0.gemfile → 4.0.0.gemfile} +4 -4
  12. data/gemfiles/{4.0.gemfile.lock → 4.0.0.gemfile.lock} +24 -24
  13. data/gemfiles/4.0.1.gemfile +19 -0
  14. data/gemfiles/4.0.1.gemfile.lock +161 -0
  15. data/lib/shoulda/matchers/action_controller.rb +1 -0
  16. data/lib/shoulda/matchers/action_controller/filter_param_matcher.rb +4 -2
  17. data/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +6 -3
  18. data/lib/shoulda/matchers/action_controller/render_template_matcher.rb +6 -3
  19. data/lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb +4 -2
  20. data/lib/shoulda/matchers/action_controller/rescue_from_matcher.rb +4 -2
  21. data/lib/shoulda/matchers/action_controller/respond_with_matcher.rb +4 -2
  22. data/lib/shoulda/matchers/action_controller/route_matcher.rb +13 -19
  23. data/lib/shoulda/matchers/action_controller/route_params.rb +47 -0
  24. data/lib/shoulda/matchers/action_controller/set_session_matcher.rb +4 -2
  25. data/lib/shoulda/matchers/action_controller/set_the_flash_matcher.rb +4 -2
  26. data/lib/shoulda/matchers/active_model.rb +4 -3
  27. data/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb +9 -6
  28. data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +4 -2
  29. data/lib/shoulda/matchers/active_model/disallow_value_matcher.rb +6 -4
  30. data/lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb +4 -1
  31. data/lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb +8 -1
  32. data/lib/shoulda/matchers/active_model/have_secure_password_matcher.rb +4 -2
  33. data/lib/shoulda/matchers/active_model/numericality_matchers/comparison_matcher.rb +59 -0
  34. data/lib/shoulda/matchers/active_model/numericality_matchers/odd_even_number_matcher.rb +51 -0
  35. data/lib/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher.rb +41 -0
  36. data/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +77 -0
  37. data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +14 -12
  38. data/lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb +6 -6
  39. data/lib/shoulda/matchers/active_model/validation_matcher.rb +10 -7
  40. data/lib/shoulda/matchers/active_record.rb +2 -0
  41. data/lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb +4 -2
  42. data/lib/shoulda/matchers/active_record/association_matcher.rb +11 -3
  43. data/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +80 -0
  44. data/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +20 -55
  45. data/lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb +40 -0
  46. data/lib/shoulda/matchers/active_record/have_db_column_matcher.rb +4 -2
  47. data/lib/shoulda/matchers/active_record/have_db_index_matcher.rb +4 -2
  48. data/lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb +7 -4
  49. data/lib/shoulda/matchers/active_record/serialize_matcher.rb +4 -2
  50. data/lib/shoulda/matchers/integrations/test_unit.rb +3 -3
  51. data/lib/shoulda/matchers/rails_shim.rb +14 -6
  52. data/lib/shoulda/matchers/version.rb +1 -1
  53. data/spec/shoulda/matchers/action_controller/filter_param_matcher_spec.rb +1 -1
  54. data/spec/shoulda/matchers/action_controller/rescue_from_matcher_spec.rb +2 -2
  55. data/spec/shoulda/matchers/action_controller/route_matcher_spec.rb +5 -0
  56. data/spec/shoulda/matchers/action_controller/route_params_spec.rb +30 -0
  57. data/spec/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb +1 -1
  58. data/spec/shoulda/matchers/active_model/allow_value_matcher_spec.rb +1 -1
  59. data/spec/shoulda/matchers/active_model/disallow_value_matcher_spec.rb +2 -2
  60. data/spec/shoulda/matchers/active_model/ensure_inclusion_of_matcher_spec.rb +10 -0
  61. data/spec/shoulda/matchers/active_model/ensure_length_of_matcher_spec.rb +7 -0
  62. data/spec/shoulda/matchers/active_model/{comparison_matcher_spec.rb → numericality_matchers/comparison_matcher_spec.rb} +2 -2
  63. data/spec/shoulda/matchers/active_model/{odd_even_number_matcher_spec.rb → numericality_matchers/odd_even_number_matcher_spec.rb} +4 -4
  64. data/spec/shoulda/matchers/active_model/{only_integer_matcher_spec.rb → numericality_matchers/only_integer_matcher_spec.rb} +3 -3
  65. data/spec/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb +139 -0
  66. data/spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb +7 -7
  67. data/spec/shoulda/matchers/active_model/validate_uniqueness_of_matcher_spec.rb +48 -38
  68. data/spec/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb +6 -6
  69. data/spec/shoulda/matchers/active_record/association_matcher_spec.rb +21 -8
  70. data/spec/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb +247 -0
  71. data/spec/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb +1 -1
  72. data/spec/shoulda/matchers/active_record/serialize_matcher_spec.rb +3 -3
  73. data/spec/spec_helper.rb +9 -15
  74. data/spec/support/active_resource_builder.rb +2 -0
  75. data/spec/support/controller_builder.rb +4 -10
  76. data/spec/support/model_builder.rb +6 -2
  77. data/spec/support/rails_versions.rb +18 -0
  78. data/spec/support/shared_examples/numerical_submatcher_spec.rb +4 -4
  79. data/spec/support/test_application.rb +97 -0
  80. metadata +30 -14
  81. data/lib/shoulda/matchers/active_model/comparison_matcher.rb +0 -57
  82. data/lib/shoulda/matchers/active_model/odd_even_number_matcher.rb +0 -47
  83. data/lib/shoulda/matchers/active_model/only_integer_matcher.rb +0 -37
@@ -1,3 +1,5 @@
1
+ require 'active_resource'
2
+
1
3
  module ActiveResourceBuilder
2
4
  def self.included(example_group)
3
5
  example_group.class_eval do
@@ -1,7 +1,4 @@
1
1
  module ControllerBuilder
2
- TMP_VIEW_PATH = File.expand_path(File.join(TESTAPP_ROOT, 'tmp',
3
- 'views')).freeze
4
-
5
2
  def self.included(example_group)
6
3
  example_group.class_eval do
7
4
  after do
@@ -18,8 +15,7 @@ module ControllerBuilder
18
15
  end
19
16
 
20
17
  def define_routes(&block)
21
- Rails.application.routes.draw(&block)
22
- @routes = Rails.application.routes
18
+ @routes = $test_app.draw_routes(&block)
23
19
  class << self
24
20
  include ActionDispatch::Assertions
25
21
  end
@@ -33,7 +29,7 @@ module ControllerBuilder
33
29
  layout false
34
30
  define_method(action, &block)
35
31
  end
36
- controller_class.view_paths = [TMP_VIEW_PATH]
32
+ controller_class.view_paths = [ $test_app.temp_views_dir_path ]
37
33
 
38
34
  define_routes do
39
35
  get 'examples', :to => "examples##{action}"
@@ -59,15 +55,13 @@ module ControllerBuilder
59
55
  end
60
56
 
61
57
  def create_view(path, contents)
62
- full_path = File.join(TMP_VIEW_PATH, path)
63
- FileUtils.mkdir_p(File.dirname(full_path))
64
- File.open(full_path, 'w') { |file| file.write(contents) }
58
+ $test_app.create_temp_view(path, contents)
65
59
  end
66
60
 
67
61
  private
68
62
 
69
63
  def delete_temporary_views
70
- FileUtils.rm_rf(TMP_VIEW_PATH)
64
+ $test_app.delete_temp_views
71
65
  end
72
66
 
73
67
  def restore_original_routes
@@ -48,8 +48,12 @@ module ModelBuilder
48
48
  class_name = name.to_s.pluralize.classify
49
49
  table_name = class_name.tableize
50
50
  table_block = lambda do |table|
51
- columns.each do |name, type|
52
- table.column name, type
51
+ columns.each do |name, specification|
52
+ if specification.is_a?(Hash)
53
+ table.column name, specification[:type], specification[:options]
54
+ else
55
+ table.column name, specification
56
+ end
53
57
  end
54
58
  end
55
59
 
@@ -0,0 +1,18 @@
1
+ module RailsVersions
2
+ def rails_version
3
+ Gem::Version.new(Rails::VERSION::STRING)
4
+ end
5
+
6
+ def rails_3_x?
7
+ Gem::Requirement.new('~> 3.0').satisfied_by?(rails_version)
8
+ end
9
+
10
+ def rails_4_x?
11
+ Gem::Requirement.new('~> 4.0').satisfied_by?(rails_version)
12
+ end
13
+ end
14
+
15
+ RSpec.configure do |config|
16
+ config.include(RailsVersions)
17
+ config.extend(RailsVersions)
18
+ end
@@ -13,11 +13,11 @@ shared_examples 'a numerical submatcher' do
13
13
  subject.should respond_to(:matches?).with(1).arguments
14
14
  end
15
15
 
16
- it 'implements the failure_message_for_should method' do
17
- subject.should respond_to(:failure_message_for_should).with(0).arguments
16
+ it 'implements the failure_message method' do
17
+ subject.should respond_to(:failure_message).with(0).arguments
18
18
  end
19
19
 
20
- it 'implements the failure_message_for_should_not method' do
21
- subject.should respond_to(:failure_message_for_should_not).with(0).arguments
20
+ it 'implements the failure_message_when_negated method' do
21
+ subject.should respond_to(:failure_message_when_negated).with(0).arguments
22
22
  end
23
23
  end
@@ -0,0 +1,97 @@
1
+ require 'fileutils'
2
+
3
+ class TestApplication
4
+ ROOT_DIR = File.expand_path('../../../tmp/aruba/testapp', __FILE__)
5
+
6
+ def create
7
+ clean
8
+ generate
9
+ within_app { install_gems }
10
+ end
11
+
12
+ def load
13
+ load_environment
14
+ run_migrations
15
+ end
16
+
17
+ def gemfile_path
18
+ File.join(ROOT_DIR, 'Gemfile')
19
+ end
20
+
21
+ def environment_file_path
22
+ File.join(ROOT_DIR, 'config/environment')
23
+ end
24
+
25
+ def temp_views_dir_path
26
+ File.join(ROOT_DIR, 'tmp/views')
27
+ end
28
+
29
+ def create_temp_view(path, contents)
30
+ full_path = temp_view_path_for(path)
31
+ FileUtils.mkdir_p(File.dirname(full_path))
32
+ File.open(full_path, 'w') { |file| file.write(contents) }
33
+ end
34
+
35
+ def delete_temp_views
36
+ FileUtils.rm_rf(temp_views_dir_path)
37
+ end
38
+
39
+ def draw_routes(&block)
40
+ Rails.application.routes.draw(&block)
41
+ Rails.application.routes
42
+ end
43
+
44
+ private
45
+
46
+ def migrations_dir_path
47
+ File.join(ROOT_DIR, 'db/migrate')
48
+ end
49
+
50
+ def temp_view_path_for(path)
51
+ File.join(temp_views_dir_path, path)
52
+ end
53
+
54
+ def clean
55
+ FileUtils.rm_rf(ROOT_DIR)
56
+ end
57
+
58
+ def generate
59
+ `rails new #{ROOT_DIR} --skip-bundle`
60
+ end
61
+
62
+ def load_environment
63
+ require environment_file_path
64
+ end
65
+
66
+ def run_migrations
67
+ ActiveRecord::Migration.verbose = false
68
+ ActiveRecord::Migrator.migrate(migrations_dir_path)
69
+ end
70
+
71
+ def install_gems
72
+ retrying('bundle install') do |command|
73
+ Bundler.with_clean_env { `#{command}` }
74
+ end
75
+ end
76
+
77
+ def within_app(&block)
78
+ Dir.chdir(ROOT_DIR, &block)
79
+ end
80
+
81
+ def retrying(command, &runner)
82
+ runner ||= -> { `#{command}` }
83
+
84
+ retry_count = 0
85
+ loop do
86
+ output = runner.call("#{command} 2>&1")
87
+ if $? == 0
88
+ break
89
+ else
90
+ retry_count += 1
91
+ if retry_count == 3
92
+ raise "Command '#{command}' failed:\n#{output}"
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoulda-matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tammer Saleh
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-09-20 00:00:00.000000000 Z
16
+ date: 2014-01-10 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activesupport
@@ -172,8 +172,10 @@ files:
172
172
  - gemfiles/3.1.gemfile.lock
173
173
  - gemfiles/3.2.gemfile
174
174
  - gemfiles/3.2.gemfile.lock
175
- - gemfiles/4.0.gemfile
176
- - gemfiles/4.0.gemfile.lock
175
+ - gemfiles/4.0.0.gemfile
176
+ - gemfiles/4.0.0.gemfile.lock
177
+ - gemfiles/4.0.1.gemfile
178
+ - gemfiles/4.0.1.gemfile.lock
177
179
  - lib/shoulda-matchers.rb
178
180
  - lib/shoulda/matchers.rb
179
181
  - lib/shoulda/matchers/action_controller.rb
@@ -184,12 +186,12 @@ files:
184
186
  - lib/shoulda/matchers/action_controller/rescue_from_matcher.rb
185
187
  - lib/shoulda/matchers/action_controller/respond_with_matcher.rb
186
188
  - lib/shoulda/matchers/action_controller/route_matcher.rb
189
+ - lib/shoulda/matchers/action_controller/route_params.rb
187
190
  - lib/shoulda/matchers/action_controller/set_session_matcher.rb
188
191
  - lib/shoulda/matchers/action_controller/set_the_flash_matcher.rb
189
192
  - lib/shoulda/matchers/active_model.rb
190
193
  - lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb
191
194
  - lib/shoulda/matchers/active_model/allow_value_matcher.rb
192
- - lib/shoulda/matchers/active_model/comparison_matcher.rb
193
195
  - lib/shoulda/matchers/active_model/disallow_value_matcher.rb
194
196
  - lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb
195
197
  - lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb
@@ -198,8 +200,10 @@ files:
198
200
  - lib/shoulda/matchers/active_model/exception_message_finder.rb
199
201
  - lib/shoulda/matchers/active_model/have_secure_password_matcher.rb
200
202
  - lib/shoulda/matchers/active_model/helpers.rb
201
- - lib/shoulda/matchers/active_model/odd_even_number_matcher.rb
202
- - lib/shoulda/matchers/active_model/only_integer_matcher.rb
203
+ - lib/shoulda/matchers/active_model/numericality_matchers/comparison_matcher.rb
204
+ - lib/shoulda/matchers/active_model/numericality_matchers/odd_even_number_matcher.rb
205
+ - lib/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher.rb
206
+ - lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb
203
207
  - lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb
204
208
  - lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb
205
209
  - lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb
@@ -212,9 +216,11 @@ files:
212
216
  - lib/shoulda/matchers/active_record/association_matcher.rb
213
217
  - lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
214
218
  - lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb
219
+ - lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb
215
220
  - lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb
216
221
  - lib/shoulda/matchers/active_record/association_matchers/option_verifier.rb
217
222
  - lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
223
+ - lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
218
224
  - lib/shoulda/matchers/active_record/association_matchers/through_matcher.rb
219
225
  - lib/shoulda/matchers/active_record/have_db_column_matcher.rb
220
226
  - lib/shoulda/matchers/active_record/have_db_index_matcher.rb
@@ -233,11 +239,11 @@ files:
233
239
  - spec/shoulda/matchers/action_controller/rescue_from_matcher_spec.rb
234
240
  - spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
235
241
  - spec/shoulda/matchers/action_controller/route_matcher_spec.rb
242
+ - spec/shoulda/matchers/action_controller/route_params_spec.rb
236
243
  - spec/shoulda/matchers/action_controller/set_session_matcher_spec.rb
237
244
  - spec/shoulda/matchers/action_controller/set_the_flash_matcher_spec.rb
238
245
  - spec/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb
239
246
  - spec/shoulda/matchers/active_model/allow_value_matcher_spec.rb
240
- - spec/shoulda/matchers/active_model/comparison_matcher_spec.rb
241
247
  - spec/shoulda/matchers/active_model/disallow_value_matcher_spec.rb
242
248
  - spec/shoulda/matchers/active_model/ensure_exclusion_of_matcher_spec.rb
243
249
  - spec/shoulda/matchers/active_model/ensure_inclusion_of_matcher_spec.rb
@@ -245,8 +251,10 @@ files:
245
251
  - spec/shoulda/matchers/active_model/exception_message_finder_spec.rb
246
252
  - spec/shoulda/matchers/active_model/have_secure_password_matcher_spec.rb
247
253
  - spec/shoulda/matchers/active_model/helpers_spec.rb
248
- - spec/shoulda/matchers/active_model/odd_even_number_matcher_spec.rb
249
- - spec/shoulda/matchers/active_model/only_integer_matcher_spec.rb
254
+ - spec/shoulda/matchers/active_model/numericality_matchers/comparison_matcher_spec.rb
255
+ - spec/shoulda/matchers/active_model/numericality_matchers/odd_even_number_matcher_spec.rb
256
+ - spec/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher_spec.rb
257
+ - spec/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb
250
258
  - spec/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb
251
259
  - spec/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb
252
260
  - spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb
@@ -255,6 +263,7 @@ files:
255
263
  - spec/shoulda/matchers/active_model/validation_message_finder_spec.rb
256
264
  - spec/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb
257
265
  - spec/shoulda/matchers/active_record/association_matcher_spec.rb
266
+ - spec/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb
258
267
  - spec/shoulda/matchers/active_record/have_db_column_matcher_spec.rb
259
268
  - spec/shoulda/matchers/active_record/have_db_index_matcher_spec.rb
260
269
  - spec/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb
@@ -269,7 +278,9 @@ files:
269
278
  - spec/support/i18n_faker.rb
270
279
  - spec/support/mailer_builder.rb
271
280
  - spec/support/model_builder.rb
281
+ - spec/support/rails_versions.rb
272
282
  - spec/support/shared_examples/numerical_submatcher_spec.rb
283
+ - spec/support/test_application.rb
273
284
  homepage: http://thoughtbot.com/community/
274
285
  licenses:
275
286
  - MIT
@@ -290,7 +301,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
301
  version: '0'
291
302
  requirements: []
292
303
  rubyforge_project:
293
- rubygems_version: 2.0.0
304
+ rubygems_version: 2.0.14
294
305
  signing_key:
295
306
  specification_version: 4
296
307
  summary: Making tests easy on the fingers and eyes
@@ -305,11 +316,11 @@ test_files:
305
316
  - spec/shoulda/matchers/action_controller/rescue_from_matcher_spec.rb
306
317
  - spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
307
318
  - spec/shoulda/matchers/action_controller/route_matcher_spec.rb
319
+ - spec/shoulda/matchers/action_controller/route_params_spec.rb
308
320
  - spec/shoulda/matchers/action_controller/set_session_matcher_spec.rb
309
321
  - spec/shoulda/matchers/action_controller/set_the_flash_matcher_spec.rb
310
322
  - spec/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb
311
323
  - spec/shoulda/matchers/active_model/allow_value_matcher_spec.rb
312
- - spec/shoulda/matchers/active_model/comparison_matcher_spec.rb
313
324
  - spec/shoulda/matchers/active_model/disallow_value_matcher_spec.rb
314
325
  - spec/shoulda/matchers/active_model/ensure_exclusion_of_matcher_spec.rb
315
326
  - spec/shoulda/matchers/active_model/ensure_inclusion_of_matcher_spec.rb
@@ -317,8 +328,10 @@ test_files:
317
328
  - spec/shoulda/matchers/active_model/exception_message_finder_spec.rb
318
329
  - spec/shoulda/matchers/active_model/have_secure_password_matcher_spec.rb
319
330
  - spec/shoulda/matchers/active_model/helpers_spec.rb
320
- - spec/shoulda/matchers/active_model/odd_even_number_matcher_spec.rb
321
- - spec/shoulda/matchers/active_model/only_integer_matcher_spec.rb
331
+ - spec/shoulda/matchers/active_model/numericality_matchers/comparison_matcher_spec.rb
332
+ - spec/shoulda/matchers/active_model/numericality_matchers/odd_even_number_matcher_spec.rb
333
+ - spec/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher_spec.rb
334
+ - spec/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb
322
335
  - spec/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb
323
336
  - spec/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb
324
337
  - spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb
@@ -327,6 +340,7 @@ test_files:
327
340
  - spec/shoulda/matchers/active_model/validation_message_finder_spec.rb
328
341
  - spec/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb
329
342
  - spec/shoulda/matchers/active_record/association_matcher_spec.rb
343
+ - spec/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb
330
344
  - spec/shoulda/matchers/active_record/have_db_column_matcher_spec.rb
331
345
  - spec/shoulda/matchers/active_record/have_db_index_matcher_spec.rb
332
346
  - spec/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb
@@ -341,4 +355,6 @@ test_files:
341
355
  - spec/support/i18n_faker.rb
342
356
  - spec/support/mailer_builder.rb
343
357
  - spec/support/model_builder.rb
358
+ - spec/support/rails_versions.rb
344
359
  - spec/support/shared_examples/numerical_submatcher_spec.rb
360
+ - spec/support/test_application.rb
@@ -1,57 +0,0 @@
1
- module Shoulda # :nodoc:
2
- module Matchers
3
- module ActiveModel # :nodoc:
4
- # Examples:
5
- # it { should validate_numericality_of(:attr).
6
- # is_greater_than(6).
7
- # less_than(20)...(and so on) }
8
- class ComparisonMatcher < ValidationMatcher
9
- def initialize(value, operator)
10
- @value = value
11
- @operator = operator
12
- @message = nil
13
- end
14
-
15
- def for(attribute)
16
- @attribute = attribute
17
- self
18
- end
19
-
20
- def matches?(subject)
21
- @subject = subject
22
- disallows_value_of(value_to_compare, @message)
23
- end
24
-
25
- def allowed_types
26
- 'integer'
27
- end
28
-
29
- def with_message(message)
30
- @message = message
31
- end
32
-
33
- private
34
-
35
- def value_to_compare
36
- case @operator
37
- when :> then [@value, @value - 1].sample
38
- when :>= then @value - 1
39
- when :== then @value + 1
40
- when :< then [@value, @value + 1].sample
41
- when :<= then @value + 1
42
- end
43
- end
44
-
45
- def expectation
46
- case @operator
47
- when :> then "greater than"
48
- when :>= then "greater than or equal to"
49
- when :== then "equal to"
50
- when :< then "less than"
51
- when :<= then "less than or equal to"
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,47 +0,0 @@
1
- module Shoulda # :nodoc:
2
- module Matchers
3
- module ActiveModel # :nodoc:
4
- class OddEvenNumberMatcher # :nodoc:
5
- NON_EVEN_NUMBER_VALUE = 1
6
- NON_ODD_NUMBER_VALUE = 2
7
-
8
- def initialize(attribute, options = {})
9
- @attribute = attribute
10
- options[:odd] ||= true
11
- options[:even] ||= false
12
-
13
- if options[:odd] && !options[:even]
14
- @disallow_value_matcher = DisallowValueMatcher.new(NON_ODD_NUMBER_VALUE).
15
- for(@attribute).
16
- with_message(:odd)
17
- else
18
- @disallow_value_matcher = DisallowValueMatcher.new(NON_EVEN_NUMBER_VALUE).
19
- for(@attribute).
20
- with_message(:even)
21
- end
22
- end
23
-
24
- def matches?(subject)
25
- @disallow_value_matcher.matches?(subject)
26
- end
27
-
28
- def with_message(message)
29
- @disallow_value_matcher.with_message(message)
30
- self
31
- end
32
-
33
- def allowed_types
34
- 'integer'
35
- end
36
-
37
- def failure_message_for_should
38
- @disallow_value_matcher.failure_message_for_should
39
- end
40
-
41
- def failure_message_for_should_not
42
- @disallow_value_matcher.failure_message_for_should_not
43
- end
44
- end
45
- end
46
- end
47
- end