shoulda-matchers 2.6.2 → 2.7.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +6 -1
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +26 -22
  5. data/NEWS.md +52 -1
  6. data/README.md +8 -6
  7. data/Rakefile +1 -1
  8. data/doc_config/gh-pages/index.html.erb +1 -1
  9. data/doc_config/yard/templates/default/fulldoc/html/css/global.css +1 -1
  10. data/doc_config/yard/templates/default/fulldoc/html/css/style.css +26 -0
  11. data/features/rails_integration.feature +18 -3
  12. data/features/step_definitions/rails_steps.rb +21 -3
  13. data/gemfiles/3.0.gemfile +1 -1
  14. data/gemfiles/3.0.gemfile.lock +30 -24
  15. data/gemfiles/3.1.gemfile +1 -1
  16. data/gemfiles/3.1.gemfile.lock +32 -26
  17. data/gemfiles/3.1_1.9.2.gemfile +1 -1
  18. data/gemfiles/3.1_1.9.2.gemfile.lock +22 -19
  19. data/gemfiles/3.2.gemfile +1 -1
  20. data/gemfiles/3.2.gemfile.lock +32 -26
  21. data/gemfiles/3.2_1.9.2.gemfile +1 -1
  22. data/gemfiles/3.2_1.9.2.gemfile.lock +8 -8
  23. data/gemfiles/4.0.0.gemfile +2 -2
  24. data/gemfiles/4.0.0.gemfile.lock +35 -31
  25. data/gemfiles/4.0.1.gemfile +2 -2
  26. data/gemfiles/4.0.1.gemfile.lock +24 -22
  27. data/gemfiles/4.1.gemfile +1 -1
  28. data/gemfiles/4.1.gemfile.lock +26 -22
  29. data/lib/shoulda/matchers/action_controller/filter_param_matcher.rb +10 -3
  30. data/lib/shoulda/matchers/action_controller/set_session_matcher.rb +24 -6
  31. data/lib/shoulda/matchers/active_model.rb +2 -2
  32. data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +1 -1
  33. data/lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb +1 -1
  34. data/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +5 -3
  35. data/lib/shoulda/matchers/active_model/{ensure_exclusion_of_matcher.rb → validate_exclusion_of_matcher.rb} +20 -10
  36. data/lib/shoulda/matchers/active_model/{ensure_inclusion_of_matcher.rb → validate_inclusion_of_matcher.rb} +52 -28
  37. data/lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb +28 -19
  38. data/lib/shoulda/matchers/active_record.rb +18 -16
  39. data/lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb +4 -4
  40. data/lib/shoulda/matchers/active_record/association_matcher.rb +17 -12
  41. data/lib/shoulda/matchers/active_record/association_matchers/join_table_matcher.rb +86 -0
  42. data/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +19 -0
  43. data/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +2 -1
  44. data/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb +138 -0
  45. data/lib/shoulda/matchers/independent.rb +3 -2
  46. data/lib/shoulda/matchers/independent/{delegate_matcher.rb → delegate_method_matcher.rb} +69 -49
  47. data/lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb +37 -0
  48. data/lib/shoulda/matchers/independent/delegate_method_matcher/target_not_defined_error.rb +15 -0
  49. data/lib/shoulda/matchers/version.rb +1 -1
  50. data/lib/shoulda/matchers/warn.rb +30 -2
  51. data/spec/shoulda/matchers/action_controller/filter_param_matcher_spec.rb +6 -0
  52. data/spec/shoulda/matchers/action_controller/set_session_matcher_spec.rb +67 -5
  53. data/spec/shoulda/matchers/action_controller/strong_parameters_matcher_spec.rb +9 -9
  54. data/spec/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb +30 -3
  55. data/spec/shoulda/matchers/active_model/{ensure_exclusion_of_matcher_spec.rb → validate_exclusion_of_matcher_spec.rb} +29 -13
  56. data/spec/shoulda/matchers/active_model/{ensure_inclusion_of_matcher_spec.rb → validate_inclusion_of_matcher_spec.rb} +34 -16
  57. data/spec/shoulda/matchers/active_model/validate_uniqueness_of_matcher_spec.rb +35 -0
  58. data/spec/shoulda/matchers/active_record/association_matcher_spec.rb +56 -1
  59. data/spec/shoulda/matchers/active_record/define_enum_for_matcher_spec.rb +101 -0
  60. data/spec/shoulda/matchers/doublespeak/object_double_spec.rb +6 -6
  61. data/spec/shoulda/matchers/independent/{delegate_matcher → delegate_method_matcher}/stubbed_target_spec.rb +1 -1
  62. data/spec/shoulda/matchers/independent/{delegate_matcher_spec.rb → delegate_method_matcher_spec.rb} +88 -29
  63. data/spec/spec_helper.rb +2 -3
  64. data/spec/support/fail_with_message_including_matcher.rb +14 -3
  65. data/spec/support/fail_with_message_matcher.rb +14 -2
  66. data/spec/support/rails_versions.rb +4 -0
  67. metadata +19 -14
  68. data/lib/shoulda/matchers/independent/delegate_matcher/stubbed_target.rb +0 -35
data/spec/spec_helper.rb CHANGED
@@ -28,16 +28,15 @@ require 'rspec/rails'
28
28
 
29
29
  PROJECT_ROOT = File.expand_path('../..', __FILE__)
30
30
  $LOAD_PATH << File.join(PROJECT_ROOT, 'lib')
31
- Dir[ File.join(PROJECT_ROOT, 'spec/support/**/*.rb') ].each { |file| require file }
32
31
 
32
+ Dir[ File.join(PROJECT_ROOT, 'spec/support/**/*.rb') ].each { |file| require file }
33
33
  RSpec.configure do |config|
34
34
  config.expect_with :rspec do |c|
35
35
  c.syntax = :expect
36
36
  end
37
37
 
38
38
  config.mock_with :mocha
39
- config.include Shoulda::Matchers::ActionController,
40
- example_group: { file_path: /action_controller/ }
39
+ config.include Shoulda::Matchers::ActionController, type: :controller
41
40
  end
42
41
 
43
42
  $VERBOSE = true
@@ -1,4 +1,8 @@
1
1
  RSpec::Matchers.define :fail_with_message_including do |expected|
2
+ def supports_block_expectations?
3
+ true
4
+ end
5
+
2
6
  match do |block|
3
7
  @actual = nil
4
8
 
@@ -11,7 +15,7 @@ RSpec::Matchers.define :fail_with_message_including do |expected|
11
15
  @actual && @actual.include?(expected)
12
16
  end
13
17
 
14
- failure_message_for_should do
18
+ def failure_message
15
19
  msg = "Expectation should have failed with message including '#{expected}'"
16
20
 
17
21
  if @actual
@@ -23,11 +27,18 @@ RSpec::Matchers.define :fail_with_message_including do |expected|
23
27
  msg
24
28
  end
25
29
 
26
- failure_message_for_should_not do
30
+ def failure_message_for_should
31
+ failure_message
32
+ end
33
+
34
+ def failure_message_when_negated
27
35
  msg = "Expectation should not have failed with message including '#{expected}'"
28
36
  msg << ", but did."
29
37
 
30
38
  msg
31
39
  end
32
40
 
33
- end
41
+ def failure_message_for_should_not
42
+ failure_message_when_negated
43
+ end
44
+ end
@@ -1,4 +1,8 @@
1
1
  RSpec::Matchers.define :fail_with_message do |expected|
2
+ def supports_block_expectations?
3
+ true
4
+ end
5
+
2
6
  match do |block|
3
7
  @actual = nil
4
8
 
@@ -11,7 +15,7 @@ RSpec::Matchers.define :fail_with_message do |expected|
11
15
  @actual && @actual == expected
12
16
  end
13
17
 
14
- failure_message_for_should do
18
+ def failure_message
15
19
  msg = "Expectation should have failed with message '#{expected}'"
16
20
 
17
21
  if @actual
@@ -23,10 +27,18 @@ RSpec::Matchers.define :fail_with_message do |expected|
23
27
  msg
24
28
  end
25
29
 
26
- failure_message_for_should_not do
30
+ def failure_message_for_should
31
+ failure_message
32
+ end
33
+
34
+ def failure_message_when_negated
27
35
  msg = "Expectation should not have failed with message '#{expected}'"
28
36
  msg << ", but did."
29
37
 
30
38
  msg
31
39
  end
40
+
41
+ def failure_message_for_should_not
42
+ failure_message_when_negated
43
+ end
32
44
  end
@@ -14,6 +14,10 @@ module RailsVersions
14
14
  def rails_gte_4_1?
15
15
  Gem::Requirement.new('>= 4.1').satisfied_by?(rails_version)
16
16
  end
17
+
18
+ def active_record_supports_enum?
19
+ defined?(::ActiveRecord::Enum)
20
+ end
17
21
  end
18
22
 
19
23
  RSpec.configure do |config|
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.6.2
4
+ version: 2.7.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: 2014-07-18 00:00:00.000000000 Z
16
+ date: 2014-09-03 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activesupport
@@ -110,8 +110,6 @@ files:
110
110
  - lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb
111
111
  - lib/shoulda/matchers/active_model/allow_value_matcher.rb
112
112
  - lib/shoulda/matchers/active_model/disallow_value_matcher.rb
113
- - lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb
114
- - lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb
115
113
  - lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb
116
114
  - lib/shoulda/matchers/active_model/errors.rb
117
115
  - lib/shoulda/matchers/active_model/exception_message_finder.rb
@@ -126,6 +124,8 @@ files:
126
124
  - lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb
127
125
  - lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb
128
126
  - lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb
127
+ - lib/shoulda/matchers/active_model/validate_exclusion_of_matcher.rb
128
+ - lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb
129
129
  - lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb
130
130
  - lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb
131
131
  - lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb
@@ -138,12 +138,14 @@ files:
138
138
  - lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
139
139
  - lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb
140
140
  - lib/shoulda/matchers/active_record/association_matchers/inverse_of_matcher.rb
141
+ - lib/shoulda/matchers/active_record/association_matchers/join_table_matcher.rb
141
142
  - lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb
142
143
  - lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb
143
144
  - lib/shoulda/matchers/active_record/association_matchers/option_verifier.rb
144
145
  - lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
145
146
  - lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
146
147
  - lib/shoulda/matchers/active_record/association_matchers/through_matcher.rb
148
+ - lib/shoulda/matchers/active_record/define_enum_for_matcher.rb
147
149
  - lib/shoulda/matchers/active_record/have_db_column_matcher.rb
148
150
  - lib/shoulda/matchers/active_record/have_db_index_matcher.rb
149
151
  - lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb
@@ -160,8 +162,9 @@ files:
160
162
  - lib/shoulda/matchers/doublespeak/world.rb
161
163
  - lib/shoulda/matchers/error.rb
162
164
  - lib/shoulda/matchers/independent.rb
163
- - lib/shoulda/matchers/independent/delegate_matcher.rb
164
- - lib/shoulda/matchers/independent/delegate_matcher/stubbed_target.rb
165
+ - lib/shoulda/matchers/independent/delegate_method_matcher.rb
166
+ - lib/shoulda/matchers/independent/delegate_method_matcher/stubbed_target.rb
167
+ - lib/shoulda/matchers/independent/delegate_method_matcher/target_not_defined_error.rb
165
168
  - lib/shoulda/matchers/integrations/nunit_test_case_detection.rb
166
169
  - lib/shoulda/matchers/integrations/rspec.rb
167
170
  - lib/shoulda/matchers/integrations/test_unit.rb
@@ -188,8 +191,6 @@ files:
188
191
  - spec/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb
189
192
  - spec/shoulda/matchers/active_model/allow_value_matcher_spec.rb
190
193
  - spec/shoulda/matchers/active_model/disallow_value_matcher_spec.rb
191
- - spec/shoulda/matchers/active_model/ensure_exclusion_of_matcher_spec.rb
192
- - spec/shoulda/matchers/active_model/ensure_inclusion_of_matcher_spec.rb
193
194
  - spec/shoulda/matchers/active_model/ensure_length_of_matcher_spec.rb
194
195
  - spec/shoulda/matchers/active_model/exception_message_finder_spec.rb
195
196
  - spec/shoulda/matchers/active_model/have_secure_password_matcher_spec.rb
@@ -201,6 +202,8 @@ files:
201
202
  - spec/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb
202
203
  - spec/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb
203
204
  - spec/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb
205
+ - spec/shoulda/matchers/active_model/validate_exclusion_of_matcher_spec.rb
206
+ - spec/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb
204
207
  - spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb
205
208
  - spec/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb
206
209
  - spec/shoulda/matchers/active_model/validate_uniqueness_of_matcher_spec.rb
@@ -208,6 +211,7 @@ files:
208
211
  - spec/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb
209
212
  - spec/shoulda/matchers/active_record/association_matcher_spec.rb
210
213
  - spec/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb
214
+ - spec/shoulda/matchers/active_record/define_enum_for_matcher_spec.rb
211
215
  - spec/shoulda/matchers/active_record/have_db_column_matcher_spec.rb
212
216
  - spec/shoulda/matchers/active_record/have_db_index_matcher_spec.rb
213
217
  - spec/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb
@@ -220,8 +224,8 @@ files:
220
224
  - spec/shoulda/matchers/doublespeak/stub_implementation_spec.rb
221
225
  - spec/shoulda/matchers/doublespeak/world_spec.rb
222
226
  - spec/shoulda/matchers/doublespeak_spec.rb
223
- - spec/shoulda/matchers/independent/delegate_matcher/stubbed_target_spec.rb
224
- - spec/shoulda/matchers/independent/delegate_matcher_spec.rb
227
+ - spec/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb
228
+ - spec/shoulda/matchers/independent/delegate_method_matcher_spec.rb
225
229
  - spec/spec_helper.rb
226
230
  - spec/support/active_model_versions.rb
227
231
  - spec/support/active_resource_builder.rb
@@ -289,8 +293,6 @@ test_files:
289
293
  - spec/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb
290
294
  - spec/shoulda/matchers/active_model/allow_value_matcher_spec.rb
291
295
  - spec/shoulda/matchers/active_model/disallow_value_matcher_spec.rb
292
- - spec/shoulda/matchers/active_model/ensure_exclusion_of_matcher_spec.rb
293
- - spec/shoulda/matchers/active_model/ensure_inclusion_of_matcher_spec.rb
294
296
  - spec/shoulda/matchers/active_model/ensure_length_of_matcher_spec.rb
295
297
  - spec/shoulda/matchers/active_model/exception_message_finder_spec.rb
296
298
  - spec/shoulda/matchers/active_model/have_secure_password_matcher_spec.rb
@@ -302,6 +304,8 @@ test_files:
302
304
  - spec/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb
303
305
  - spec/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb
304
306
  - spec/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb
307
+ - spec/shoulda/matchers/active_model/validate_exclusion_of_matcher_spec.rb
308
+ - spec/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb
305
309
  - spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb
306
310
  - spec/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb
307
311
  - spec/shoulda/matchers/active_model/validate_uniqueness_of_matcher_spec.rb
@@ -309,6 +313,7 @@ test_files:
309
313
  - spec/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb
310
314
  - spec/shoulda/matchers/active_record/association_matcher_spec.rb
311
315
  - spec/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb
316
+ - spec/shoulda/matchers/active_record/define_enum_for_matcher_spec.rb
312
317
  - spec/shoulda/matchers/active_record/have_db_column_matcher_spec.rb
313
318
  - spec/shoulda/matchers/active_record/have_db_index_matcher_spec.rb
314
319
  - spec/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb
@@ -321,8 +326,8 @@ test_files:
321
326
  - spec/shoulda/matchers/doublespeak/stub_implementation_spec.rb
322
327
  - spec/shoulda/matchers/doublespeak/world_spec.rb
323
328
  - spec/shoulda/matchers/doublespeak_spec.rb
324
- - spec/shoulda/matchers/independent/delegate_matcher/stubbed_target_spec.rb
325
- - spec/shoulda/matchers/independent/delegate_matcher_spec.rb
329
+ - spec/shoulda/matchers/independent/delegate_method_matcher/stubbed_target_spec.rb
330
+ - spec/shoulda/matchers/independent/delegate_method_matcher_spec.rb
326
331
  - spec/spec_helper.rb
327
332
  - spec/support/active_model_versions.rb
328
333
  - spec/support/active_resource_builder.rb
@@ -1,35 +0,0 @@
1
- module Shoulda
2
- module Matchers
3
- module Independent
4
- # @private
5
- class DelegateMatcher::StubbedTarget # :nodoc:
6
- def initialize(method)
7
- @received_method = false
8
- @received_arguments = []
9
- stub_method(method)
10
- end
11
-
12
- def has_received_method?
13
- received_method
14
- end
15
-
16
- def has_received_arguments?(*args)
17
- args == received_arguments
18
- end
19
-
20
- protected
21
-
22
- def stub_method(method)
23
- class_eval do
24
- define_method method do |*args|
25
- @received_method = true
26
- @received_arguments = args
27
- end
28
- end
29
- end
30
-
31
- attr_reader :received_method, :received_arguments
32
- end
33
- end
34
- end
35
- end