mcmire-shoulda-matchers 2.5.0 → 2.6.1.docs.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +9 -0
  4. data/.yardopts +2 -1
  5. data/Appraisals +62 -22
  6. data/Gemfile +1 -1
  7. data/Gemfile.lock +3 -3
  8. data/NEWS.md +87 -4
  9. data/README.md +2 -2
  10. data/Rakefile +18 -0
  11. data/features/activemodel_integration.feature +15 -0
  12. data/features/rails_integration.feature +1 -1
  13. data/features/step_definitions/activemodel_steps.rb +21 -0
  14. data/features/step_definitions/rails_steps.rb +5 -4
  15. data/gemfiles/3.0.gemfile +6 -3
  16. data/gemfiles/3.0.gemfile.lock +14 -4
  17. data/gemfiles/3.1.gemfile +10 -4
  18. data/gemfiles/3.1.gemfile.lock +32 -5
  19. data/gemfiles/3.1_1.9.2.gemfile +21 -0
  20. data/gemfiles/3.1_1.9.2.gemfile.lock +191 -0
  21. data/gemfiles/3.2.gemfile +9 -4
  22. data/gemfiles/3.2.gemfile.lock +28 -5
  23. data/gemfiles/4.0.0.gemfile +11 -3
  24. data/gemfiles/4.0.0.gemfile.lock +42 -5
  25. data/gemfiles/4.0.1.gemfile +11 -3
  26. data/gemfiles/4.0.1.gemfile.lock +42 -5
  27. data/gemfiles/4.1.gemfile +37 -0
  28. data/gemfiles/4.1.gemfile.lock +216 -0
  29. data/lib/shoulda/matchers/action_controller/callback_matcher.rb +202 -0
  30. data/lib/shoulda/matchers/action_controller/rescue_from_matcher.rb +1 -1
  31. data/lib/shoulda/matchers/action_controller/set_the_flash_matcher.rb +2 -1
  32. data/lib/shoulda/matchers/action_controller/strong_parameters_matcher.rb +165 -0
  33. data/lib/shoulda/matchers/action_controller.rb +2 -0
  34. data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +26 -4
  35. data/lib/shoulda/matchers/active_model/disallow_value_matcher.rb +6 -0
  36. data/lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb +2 -0
  37. data/lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb +60 -18
  38. data/lib/shoulda/matchers/active_model/errors.rb +43 -1
  39. data/lib/shoulda/matchers/active_model/numericality_matchers/comparison_matcher.rb +14 -3
  40. data/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +2 -1
  41. data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +100 -45
  42. data/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +38 -5
  43. data/lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb +27 -20
  44. data/lib/shoulda/matchers/active_record/association_matcher.rb +12 -2
  45. data/lib/shoulda/matchers/active_record/association_matchers/inverse_of_matcher.rb +41 -0
  46. data/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +24 -1
  47. data/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +1 -1
  48. data/lib/shoulda/matchers/active_record/have_db_index_matcher.rb +1 -1
  49. data/lib/shoulda/matchers/active_record.rb +1 -0
  50. data/lib/shoulda/matchers/assertion_error.rb +8 -3
  51. data/lib/shoulda/matchers/doublespeak/double.rb +75 -0
  52. data/lib/shoulda/matchers/doublespeak/double_collection.rb +55 -0
  53. data/lib/shoulda/matchers/doublespeak/double_implementation_registry.rb +28 -0
  54. data/lib/shoulda/matchers/doublespeak/object_double.rb +33 -0
  55. data/lib/shoulda/matchers/doublespeak/proxy_implementation.rb +31 -0
  56. data/lib/shoulda/matchers/doublespeak/structs.rb +10 -0
  57. data/lib/shoulda/matchers/doublespeak/stub_implementation.rb +35 -0
  58. data/lib/shoulda/matchers/doublespeak/world.rb +39 -0
  59. data/lib/shoulda/matchers/doublespeak.rb +28 -0
  60. data/lib/shoulda/matchers/error.rb +20 -1
  61. data/lib/shoulda/matchers/independent/delegate_matcher/stubbed_target.rb +35 -0
  62. data/lib/shoulda/matchers/independent/delegate_matcher.rb +293 -0
  63. data/lib/shoulda/matchers/independent.rb +10 -0
  64. data/lib/shoulda/matchers/integrations/nunit_test_case_detection.rb +38 -0
  65. data/lib/shoulda/matchers/integrations/rspec.rb +13 -14
  66. data/lib/shoulda/matchers/integrations/test_unit.rb +19 -15
  67. data/lib/shoulda/matchers/integrations.rb +13 -0
  68. data/lib/shoulda/matchers/rails_shim.rb +16 -0
  69. data/lib/shoulda/matchers/version.rb +1 -1
  70. data/lib/shoulda/matchers.rb +15 -3
  71. data/spec/shoulda/matchers/action_controller/callback_matcher_spec.rb +82 -0
  72. data/spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb +2 -2
  73. data/spec/shoulda/matchers/action_controller/render_template_matcher_spec.rb +5 -5
  74. data/spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb +4 -4
  75. data/spec/shoulda/matchers/action_controller/rescue_from_matcher_spec.rb +38 -11
  76. data/spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb +1 -1
  77. data/spec/shoulda/matchers/action_controller/set_session_matcher_spec.rb +1 -1
  78. data/spec/shoulda/matchers/action_controller/set_the_flash_matcher_spec.rb +6 -6
  79. data/spec/shoulda/matchers/action_controller/strong_parameters_matcher_spec.rb +314 -0
  80. data/spec/shoulda/matchers/active_model/allow_value_matcher_spec.rb +32 -0
  81. data/spec/shoulda/matchers/active_model/ensure_inclusion_of_matcher_spec.rb +553 -211
  82. data/spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb +22 -0
  83. data/spec/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb +38 -0
  84. data/spec/shoulda/matchers/active_model/validate_uniqueness_of_matcher_spec.rb +42 -36
  85. data/spec/shoulda/matchers/active_record/association_matcher_spec.rb +15 -1
  86. data/spec/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb +4 -0
  87. data/spec/shoulda/matchers/active_record/have_db_index_matcher_spec.rb +4 -0
  88. data/spec/shoulda/matchers/doublespeak/double_collection_spec.rb +102 -0
  89. data/spec/shoulda/matchers/doublespeak/double_implementation_registry_spec.rb +21 -0
  90. data/spec/shoulda/matchers/doublespeak/double_spec.rb +144 -0
  91. data/spec/shoulda/matchers/doublespeak/object_double_spec.rb +77 -0
  92. data/spec/shoulda/matchers/doublespeak/proxy_implementation_spec.rb +40 -0
  93. data/spec/shoulda/matchers/doublespeak/stub_implementation_spec.rb +88 -0
  94. data/spec/shoulda/matchers/doublespeak/world_spec.rb +88 -0
  95. data/spec/shoulda/matchers/doublespeak_spec.rb +19 -0
  96. data/spec/shoulda/matchers/independent/delegate_matcher/stubbed_target_spec.rb +43 -0
  97. data/spec/shoulda/matchers/independent/delegate_matcher_spec.rb +250 -0
  98. data/spec/spec_helper.rb +15 -0
  99. data/spec/support/activemodel_helpers.rb +6 -2
  100. data/spec/support/controller_builder.rb +29 -1
  101. data/spec/support/rails_versions.rb +4 -0
  102. data/spec/support/test_application.rb +1 -1
  103. metadata +59 -10
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- shoulda-matchers (2.5.0)
4
+ shoulda-matchers (2.6.1)
5
5
  activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -52,6 +52,13 @@ GEM
52
52
  childprocess (0.3.9)
53
53
  ffi (~> 1.0, >= 1.0.11)
54
54
  coderay (1.1.0)
55
+ coffee-rails (4.0.1)
56
+ coffee-script (>= 2.2.0)
57
+ railties (>= 4.0.0, < 5.0)
58
+ coffee-script (2.2.0)
59
+ coffee-script-source
60
+ execjs
61
+ coffee-script-source (1.7.0)
55
62
  cucumber (1.3.10)
56
63
  builder (>= 2.1.2)
57
64
  diff-lcs (>= 1.1.3)
@@ -60,14 +67,19 @@ GEM
60
67
  multi_test (>= 0.0.2)
61
68
  diff-lcs (1.2.5)
62
69
  erubis (2.7.0)
70
+ execjs (2.0.2)
63
71
  ffi (1.9.3)
64
72
  gherkin (2.12.2)
65
73
  multi_json (~> 1.3)
66
74
  hike (1.2.3)
67
75
  i18n (0.6.5)
76
+ jbuilder (1.5.3)
77
+ activesupport (>= 3.0.0)
78
+ multi_json (>= 1.2.0)
68
79
  jquery-rails (3.0.4)
69
80
  railties (>= 3.0, < 5.0)
70
81
  thor (>= 0.14, < 2.0)
82
+ json (1.8.1)
71
83
  mail (2.5.4)
72
84
  mime-types (~> 1.16)
73
85
  treetop (~> 1.4.8)
@@ -80,12 +92,16 @@ GEM
80
92
  multi_json (1.8.2)
81
93
  multi_test (0.0.2)
82
94
  polyglot (0.3.3)
95
+ posix-spawn (0.3.8)
83
96
  protected_attributes (1.0.5)
84
97
  activemodel (>= 4.0.1, < 5.0)
85
98
  pry (0.9.12.6)
86
99
  coderay (~> 1.0)
87
100
  method_source (~> 0.8)
88
101
  slop (~> 3.4)
102
+ pygments.rb (0.5.4)
103
+ posix-spawn (~> 0.3.6)
104
+ yajl-ruby (~> 1.1.0)
89
105
  rack (1.5.2)
90
106
  rack-test (0.6.2)
91
107
  rack (>= 1.0)
@@ -105,6 +121,9 @@ GEM
105
121
  rake (>= 0.8.7)
106
122
  thor (>= 0.18.1, < 2.0)
107
123
  rake (10.1.1)
124
+ rdoc (4.1.1)
125
+ json (~> 1.4)
126
+ redcarpet (3.1.1)
108
127
  rspec-core (2.14.7)
109
128
  rspec-expectations (2.14.4)
110
129
  diff-lcs (>= 1.1.3, < 2.0)
@@ -121,7 +140,10 @@ GEM
121
140
  railties (>= 4.0.0, < 5.0)
122
141
  sass (>= 3.1.10)
123
142
  sprockets-rails (~> 2.0.0)
124
- shoulda-context (1.1.6)
143
+ sdoc (0.4.0)
144
+ json (~> 1.8)
145
+ rdoc (~> 4.0, < 5.0)
146
+ shoulda-context (1.2.0)
125
147
  slop (3.4.7)
126
148
  sprockets (2.10.1)
127
149
  hike (~> 1.2)
@@ -140,8 +162,15 @@ GEM
140
162
  treetop (1.4.15)
141
163
  polyglot
142
164
  polyglot (>= 0.3.1)
165
+ turbolinks (2.2.2)
166
+ coffee-rails
143
167
  tzinfo (0.3.38)
144
- yard (0.8.7.3)
168
+ uglifier (2.5.0)
169
+ execjs (>= 0.3.0)
170
+ json (>= 1.8.0)
171
+ watchr (0.7)
172
+ yajl-ruby (1.1.0)
173
+ yard (0.8.7.4)
145
174
 
146
175
  PLATFORMS
147
176
  ruby
@@ -155,18 +184,26 @@ DEPENDENCIES
155
184
  bcrypt-ruby (~> 3.1.2)
156
185
  bourne (~> 1.3)
157
186
  bundler (~> 1.1)
187
+ coffee-rails (~> 4.0.0)
158
188
  cucumber (~> 1.1)
189
+ jbuilder (~> 1.2)
159
190
  jdbc-sqlite3
160
191
  jquery-rails
161
192
  jruby-openssl
162
193
  protected_attributes
163
194
  pry
195
+ pygments.rb
164
196
  rails (= 4.0.1)
165
197
  rake (>= 0.9.2)
198
+ redcarpet
166
199
  rspec-rails (>= 2.13.1, < 3)
167
- sass-rails (= 4.0.1)
168
- shoulda-context (~> 1.1.2)
200
+ sass-rails (~> 4.0.0)
201
+ sdoc
202
+ shoulda-context (~> 1.2.0)
169
203
  shoulda-matchers!
170
204
  sqlite3
171
205
  therubyrhino
206
+ turbolinks
207
+ uglifier (>= 1.3.0)
208
+ watchr
172
209
  yard
@@ -0,0 +1,37 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", "~> 1.0.0.beta2"
6
+ gem "aruba"
7
+ gem "bourne", "~> 1.3"
8
+ gem "bundler", "~> 1.1"
9
+ gem "cucumber", "~> 1.1"
10
+ gem "pry"
11
+ gem "rake", ">= 0.9.2"
12
+ gem "rspec-rails", ">= 2.13.1", "< 3"
13
+ gem "yard"
14
+ gem "redcarpet"
15
+ gem "pygments.rb"
16
+ gem "watchr"
17
+ gem "shoulda-context", "~> 1.2.0"
18
+ gem "sqlite3", :platform=>:ruby
19
+ gem "activerecord-jdbc-adapter", :platform=>:jruby
20
+ gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
21
+ gem "jdbc-sqlite3", :platform=>:jruby
22
+ gem "jruby-openssl", :platform=>:jruby
23
+ gem "therubyrhino", :platform=>:jruby
24
+ gem "uglifier", ">= 1.3.0"
25
+ gem "coffee-rails", "~> 4.0.0"
26
+ gem "jquery-rails"
27
+ gem "turbolinks"
28
+ gem "activeresource", "4.0.0"
29
+ gem "rails", "~> 4.1.0"
30
+ gem "jbuilder", "~> 2.0"
31
+ gem "sass-rails", "~> 4.0.3"
32
+ gem "sdoc", "~> 0.4.0"
33
+ gem "bcrypt", "~> 3.1.7"
34
+ gem "protected_attributes", "~> 1.0.6"
35
+ gem "spring"
36
+
37
+ gemspec :path=>".././"
@@ -0,0 +1,216 @@
1
+ PATH
2
+ remote: .././
3
+ specs:
4
+ shoulda-matchers (2.6.1)
5
+ activesupport (>= 3.0.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.1.0)
11
+ actionpack (= 4.1.0)
12
+ actionview (= 4.1.0)
13
+ mail (~> 2.5.4)
14
+ actionpack (4.1.0)
15
+ actionview (= 4.1.0)
16
+ activesupport (= 4.1.0)
17
+ rack (~> 1.5.2)
18
+ rack-test (~> 0.6.2)
19
+ actionview (4.1.0)
20
+ activesupport (= 4.1.0)
21
+ builder (~> 3.1)
22
+ erubis (~> 2.7.0)
23
+ activemodel (4.1.0)
24
+ activesupport (= 4.1.0)
25
+ builder (~> 3.1)
26
+ activerecord (4.1.0)
27
+ activemodel (= 4.1.0)
28
+ activesupport (= 4.1.0)
29
+ arel (~> 5.0.0)
30
+ activeresource (4.0.0)
31
+ activemodel (~> 4.0)
32
+ activesupport (~> 4.0)
33
+ rails-observers (~> 0.1.1)
34
+ activesupport (4.1.0)
35
+ i18n (~> 0.6, >= 0.6.9)
36
+ json (~> 1.7, >= 1.7.7)
37
+ minitest (~> 5.1)
38
+ thread_safe (~> 0.1)
39
+ tzinfo (~> 1.1)
40
+ appraisal (1.0.0.beta2)
41
+ bundler
42
+ rake
43
+ thor (>= 0.14.0)
44
+ arel (5.0.0)
45
+ aruba (0.5.4)
46
+ childprocess (>= 0.3.6)
47
+ cucumber (>= 1.1.1)
48
+ rspec-expectations (>= 2.7.0)
49
+ bcrypt (3.1.7)
50
+ bourne (1.5.0)
51
+ mocha (>= 0.13.2, < 0.15)
52
+ builder (3.2.2)
53
+ childprocess (0.4.0)
54
+ ffi (~> 1.0, >= 1.0.11)
55
+ coderay (1.1.0)
56
+ coffee-rails (4.0.1)
57
+ coffee-script (>= 2.2.0)
58
+ railties (>= 4.0.0, < 5.0)
59
+ coffee-script (2.2.0)
60
+ coffee-script-source
61
+ execjs
62
+ coffee-script-source (1.7.0)
63
+ cucumber (1.3.10)
64
+ builder (>= 2.1.2)
65
+ diff-lcs (>= 1.1.3)
66
+ gherkin (~> 2.12)
67
+ multi_json (>= 1.7.5, < 2.0)
68
+ multi_test (>= 0.0.2)
69
+ diff-lcs (1.2.5)
70
+ erubis (2.7.0)
71
+ execjs (2.0.2)
72
+ ffi (1.9.3)
73
+ gherkin (2.12.2)
74
+ multi_json (~> 1.3)
75
+ hike (1.2.3)
76
+ i18n (0.6.9)
77
+ jbuilder (2.0.6)
78
+ activesupport (>= 3.0.0, < 5)
79
+ multi_json (~> 1.2)
80
+ jquery-rails (3.1.0)
81
+ railties (>= 3.0, < 5.0)
82
+ thor (>= 0.14, < 2.0)
83
+ json (1.8.1)
84
+ mail (2.5.4)
85
+ mime-types (~> 1.16)
86
+ treetop (~> 1.4.8)
87
+ metaclass (0.0.2)
88
+ method_source (0.8.2)
89
+ mime-types (1.25.1)
90
+ minitest (5.3.2)
91
+ mocha (0.14.0)
92
+ metaclass (~> 0.0.1)
93
+ multi_json (1.9.2)
94
+ multi_test (0.0.3)
95
+ polyglot (0.3.4)
96
+ posix-spawn (0.3.8)
97
+ protected_attributes (1.0.7)
98
+ activemodel (>= 4.0.1, < 5.0)
99
+ pry (0.9.12.6)
100
+ coderay (~> 1.0)
101
+ method_source (~> 0.8)
102
+ slop (~> 3.4)
103
+ pygments.rb (0.5.4)
104
+ posix-spawn (~> 0.3.6)
105
+ yajl-ruby (~> 1.1.0)
106
+ rack (1.5.2)
107
+ rack-test (0.6.2)
108
+ rack (>= 1.0)
109
+ rails (4.1.0)
110
+ actionmailer (= 4.1.0)
111
+ actionpack (= 4.1.0)
112
+ actionview (= 4.1.0)
113
+ activemodel (= 4.1.0)
114
+ activerecord (= 4.1.0)
115
+ activesupport (= 4.1.0)
116
+ bundler (>= 1.3.0, < 2.0)
117
+ railties (= 4.1.0)
118
+ sprockets-rails (~> 2.0)
119
+ rails-observers (0.1.2)
120
+ activemodel (~> 4.0)
121
+ railties (4.1.0)
122
+ actionpack (= 4.1.0)
123
+ activesupport (= 4.1.0)
124
+ rake (>= 0.8.7)
125
+ thor (>= 0.18.1, < 2.0)
126
+ rake (10.2.2)
127
+ rdoc (4.1.1)
128
+ json (~> 1.4)
129
+ redcarpet (3.1.1)
130
+ rspec-core (2.14.7)
131
+ rspec-expectations (2.14.4)
132
+ diff-lcs (>= 1.1.3, < 2.0)
133
+ rspec-mocks (2.14.4)
134
+ rspec-rails (2.14.1)
135
+ actionpack (>= 3.0)
136
+ activemodel (>= 3.0)
137
+ activesupport (>= 3.0)
138
+ railties (>= 3.0)
139
+ rspec-core (~> 2.14.0)
140
+ rspec-expectations (~> 2.14.0)
141
+ rspec-mocks (~> 2.14.0)
142
+ sass (3.2.19)
143
+ sass-rails (4.0.3)
144
+ railties (>= 4.0.0, < 5.0)
145
+ sass (~> 3.2.0)
146
+ sprockets (~> 2.8, <= 2.11.0)
147
+ sprockets-rails (~> 2.0)
148
+ sdoc (0.4.0)
149
+ json (~> 1.8)
150
+ rdoc (~> 4.0, < 5.0)
151
+ shoulda-context (1.2.0)
152
+ slop (3.4.7)
153
+ spring (1.1.2)
154
+ sprockets (2.11.0)
155
+ hike (~> 1.2)
156
+ multi_json (~> 1.0)
157
+ rack (~> 1.0)
158
+ tilt (~> 1.1, != 1.3.0)
159
+ sprockets-rails (2.1.0)
160
+ actionpack (>= 4.0)
161
+ activesupport (>= 4.0)
162
+ sprockets (~> 2.8)
163
+ sqlite3 (1.3.9)
164
+ thor (0.19.1)
165
+ thread_safe (0.3.3)
166
+ tilt (1.4.1)
167
+ treetop (1.4.15)
168
+ polyglot
169
+ polyglot (>= 0.3.1)
170
+ turbolinks (2.2.2)
171
+ coffee-rails
172
+ tzinfo (1.1.0)
173
+ thread_safe (~> 0.1)
174
+ uglifier (2.5.0)
175
+ execjs (>= 0.3.0)
176
+ json (>= 1.8.0)
177
+ watchr (0.7)
178
+ yajl-ruby (1.1.0)
179
+ yard (0.8.7.4)
180
+
181
+ PLATFORMS
182
+ ruby
183
+
184
+ DEPENDENCIES
185
+ activerecord-jdbc-adapter
186
+ activerecord-jdbcsqlite3-adapter
187
+ activeresource (= 4.0.0)
188
+ appraisal (~> 1.0.0.beta2)
189
+ aruba
190
+ bcrypt (~> 3.1.7)
191
+ bourne (~> 1.3)
192
+ bundler (~> 1.1)
193
+ coffee-rails (~> 4.0.0)
194
+ cucumber (~> 1.1)
195
+ jbuilder (~> 2.0)
196
+ jdbc-sqlite3
197
+ jquery-rails
198
+ jruby-openssl
199
+ protected_attributes (~> 1.0.6)
200
+ pry
201
+ pygments.rb
202
+ rails (~> 4.1.0)
203
+ rake (>= 0.9.2)
204
+ redcarpet
205
+ rspec-rails (>= 2.13.1, < 3)
206
+ sass-rails (~> 4.0.3)
207
+ sdoc (~> 0.4.0)
208
+ shoulda-context (~> 1.2.0)
209
+ shoulda-matchers!
210
+ spring
211
+ sqlite3
212
+ therubyrhino
213
+ turbolinks
214
+ uglifier (>= 1.3.0)
215
+ watchr
216
+ yard
@@ -0,0 +1,202 @@
1
+ module Shoulda
2
+ module Matchers
3
+ module ActionController
4
+ # The `use_before_filter` matcher is used to test that a `before_filter`
5
+ # callback in a controller is called.
6
+ #
7
+ # class TopicsController < ActionController::Base
8
+ # before_filter :authenticate_user!
9
+ # skip_before_filter :prevent_ssl
10
+ #
11
+ # private
12
+ #
13
+ # def authenticate_user!; ...; end
14
+ # end
15
+ #
16
+ # # RSpec
17
+ # describe TopicsController do
18
+ # it { should use_before_filter(:authenticate_user!) }
19
+ # it { should_not use_before_filter(:prevent_ssl) }
20
+ # end
21
+ #
22
+ # # Test::Unit
23
+ # class TopicsControllerTest < ActionController::TestCase
24
+ # should use_before_filter(:authenticate_user!)
25
+ # should_not use_before_filter(:prevent_ssl)
26
+ # end
27
+ #
28
+ def use_before_filter(callback)
29
+ CallbackMatcher.new(callback, :before, :filter)
30
+ end
31
+
32
+ # The `use_after_filter` matcher is used to test that an `after_filter`
33
+ # callback in a controller is called.
34
+ #
35
+ # class CommentsController < ActionController::Base
36
+ # after_filter :log_activity
37
+ # skip_before_filter :destroy_user
38
+ #
39
+ # private
40
+ #
41
+ # def log_activity; ...; end
42
+ # end
43
+ #
44
+ # # RSpec
45
+ # describe CommentsController do
46
+ # it { should use_after_filter(:log_activity) }
47
+ # it { should_not use_after_filter(:destroy_user) }
48
+ # end
49
+ #
50
+ # # Test::Unit
51
+ # class CommentsControllerTest < ActionController::TestCase
52
+ # should use_after_filter(:log_activity)
53
+ # should_not use_after_filter(:destroy_user)
54
+ # end
55
+ #
56
+ def use_after_filter(callback)
57
+ CallbackMatcher.new(callback, :after, :filter)
58
+ end
59
+
60
+ # The `use_before_action` matcher is used to test that a `before_action`
61
+ # callback in a controller is called.
62
+ #
63
+ # class TopicsController < ActionController::Base
64
+ # before_action :authenticate_user!
65
+ # skip_before_action :prevent_ssl
66
+ #
67
+ # private
68
+ #
69
+ # def authenticate_user!; ...; end
70
+ # end
71
+ #
72
+ # # RSpec
73
+ # describe TopicsController do
74
+ # it { should use_before_action(:authenticate_user!) }
75
+ # it { should_not use_before_action(:prevent_ssl) }
76
+ # end
77
+ #
78
+ # # Test::Unit
79
+ # class TopicsControllerTest < ActionController::TestCase
80
+ # should use_before_action(:authenticate_user!)
81
+ # should_not use_before_action(:prevent_ssl)
82
+ # end
83
+ #
84
+ def use_before_action(callback)
85
+ CallbackMatcher.new(callback, :before, :action)
86
+ end
87
+
88
+ # The `use_after_action` matcher is used to test that an `after_action`
89
+ # callback in a controller is called.
90
+ #
91
+ # class CommentsController < ActionController::Base
92
+ # after_action :log_activity
93
+ # skip_before_action :destroy_user
94
+ #
95
+ # private
96
+ #
97
+ # def log_activity; ...; end
98
+ # end
99
+ #
100
+ # # RSpec
101
+ # describe CommentsController do
102
+ # it { should use_after_action(:log_activity) }
103
+ # it { should_not use_after_action(:destroy_user) }
104
+ # end
105
+ #
106
+ # # Test::Unit
107
+ # class CommentsControllerTest < ActionController::TestCase
108
+ # should use_after_action(:log_activity)
109
+ # should_not use_after_action(:destroy_user)
110
+ # end
111
+ #
112
+ def use_after_action(callback)
113
+ CallbackMatcher.new(callback, :after, :action)
114
+ end
115
+
116
+ # The `use_around_filter` matcher is used to test that an `around_filter`
117
+ # callback in a controller is called.
118
+ #
119
+ # class CommentsController < ActionController::Base
120
+ # around_action :log_activity
121
+ # skip_around_action :authenticate_user!
122
+ #
123
+ # private
124
+ #
125
+ # def log_activity; ...; end
126
+ # end
127
+ #
128
+ # # RSpec
129
+ # describe CommentsController do
130
+ # it { should use_around_action(:log_activity) }
131
+ # it { should_not use_around_action(:authenticate_user!) }
132
+ # end
133
+ #
134
+ def use_around_filter(callback)
135
+ CallbackMatcher.new(callback, :around, :filter)
136
+ end
137
+
138
+ # The `use_around_action` matcher is used to test that an `around_action`
139
+ # callback in a controller is called.
140
+ #
141
+ # class CommentsController < ActionController::Base
142
+ # around_action :log_activity
143
+ # skip_around_action :authenticate_user!
144
+ #
145
+ # private
146
+ #
147
+ # def log_activity; ...; end
148
+ # end
149
+ #
150
+ # # RSpec
151
+ # describe CommentsController do
152
+ # it { should use_around_action(:log_activity) }
153
+ # it { should_not use_around_action(:authenticate_user!) }
154
+ # end
155
+ #
156
+ def use_around_action(callback)
157
+ CallbackMatcher.new(callback, :around, :action)
158
+ end
159
+
160
+ # @private
161
+ class CallbackMatcher
162
+ def initialize(method_name, kind, callback_type)
163
+ @method_name = method_name
164
+ @kind = kind
165
+ @callback_type = callback_type
166
+ end
167
+
168
+ def matches?(controller)
169
+ @controller = controller
170
+ @controller_class = controller.class
171
+
172
+ callbacks.map(&:filter).include?(method_name)
173
+ end
174
+
175
+ def failure_message
176
+ "Expected that #{controller_class.name} would have :#{method_name} as a #{kind}_#{callback_type}"
177
+ end
178
+ alias failure_message_for_should failure_message
179
+
180
+ def failure_message_when_negated
181
+ "Expected that #{controller_class.name} would not have :#{method_name} as a #{kind}_#{callback_type}"
182
+ end
183
+ alias failure_message_for_should_not failure_message_when_negated
184
+
185
+ def description
186
+ "have :#{method_name} as a #{kind}_#{callback_type}"
187
+ end
188
+
189
+ private
190
+
191
+ def callbacks
192
+ controller_class._process_action_callbacks.select do |callback|
193
+ callback.kind == kind
194
+ end
195
+ end
196
+
197
+ attr_reader :method_name, :controller, :controller_class, :kind,
198
+ :callback_type
199
+ end
200
+ end
201
+ end
202
+ end
@@ -103,7 +103,7 @@ module Shoulda
103
103
 
104
104
  def handler_exists?
105
105
  if expected_method.present?
106
- controller.respond_to? expected_method
106
+ controller.respond_to? expected_method, true
107
107
  else
108
108
  true
109
109
  end
@@ -218,7 +218,8 @@ module Shoulda
218
218
 
219
219
  def flash_values
220
220
  if @options.key?(:key)
221
- [flash.to_hash[@options[:key]]]
221
+ flash_hash = HashWithIndifferentAccess.new(flash.to_hash)
222
+ [flash_hash[@options[:key]]]
222
223
  else
223
224
  flash.to_hash.values
224
225
  end