mcmire-shoulda-matchers 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +32 -0
- data/.yardopts +7 -0
- data/Appraisals +45 -0
- data/CONTRIBUTING.md +41 -0
- data/Gemfile +31 -0
- data/Gemfile.lock +166 -0
- data/MIT-LICENSE +22 -0
- data/NEWS.md +299 -0
- data/README.md +163 -0
- data/Rakefile +116 -0
- data/doc_config/gh-pages/index.html.erb +9 -0
- data/doc_config/yard/setup.rb +22 -0
- data/doc_config/yard/templates/default/fulldoc/html/css/bootstrap.css +5967 -0
- data/doc_config/yard/templates/default/fulldoc/html/css/full_list.css +12 -0
- data/doc_config/yard/templates/default/fulldoc/html/css/global.css +45 -0
- data/doc_config/yard/templates/default/fulldoc/html/css/solarized.css +69 -0
- data/doc_config/yard/templates/default/fulldoc/html/css/style.css +283 -0
- data/doc_config/yard/templates/default/fulldoc/html/full_list.erb +32 -0
- data/doc_config/yard/templates/default/fulldoc/html/full_list_class.erb +1 -0
- data/doc_config/yard/templates/default/fulldoc/html/full_list_method.erb +8 -0
- data/doc_config/yard/templates/default/fulldoc/html/js/app.js +300 -0
- data/doc_config/yard/templates/default/fulldoc/html/js/full_list.js +1 -0
- data/doc_config/yard/templates/default/fulldoc/html/js/jquery.stickyheaders.js +289 -0
- data/doc_config/yard/templates/default/fulldoc/html/js/underscore.min.js +6 -0
- data/doc_config/yard/templates/default/fulldoc/html/setup.rb +8 -0
- data/doc_config/yard/templates/default/layout/html/breadcrumb.erb +14 -0
- data/doc_config/yard/templates/default/layout/html/fonts.erb +1 -0
- data/doc_config/yard/templates/default/layout/html/layout.erb +23 -0
- data/doc_config/yard/templates/default/layout/html/search.erb +13 -0
- data/doc_config/yard/templates/default/layout/html/setup.rb +8 -0
- data/doc_config/yard/templates/default/method_details/html/source.erb +10 -0
- data/doc_config/yard/templates/default/module/html/box_info.erb +31 -0
- data/features/rails_integration.feature +113 -0
- data/features/step_definitions/rails_steps.rb +162 -0
- data/features/support/env.rb +5 -0
- data/gemfiles/3.0.gemfile +24 -0
- data/gemfiles/3.0.gemfile.lock +150 -0
- data/gemfiles/3.1.gemfile +27 -0
- data/gemfiles/3.1.gemfile.lock +173 -0
- data/gemfiles/3.2.gemfile +27 -0
- data/gemfiles/3.2.gemfile.lock +171 -0
- data/gemfiles/4.0.0.gemfile +28 -0
- data/gemfiles/4.0.0.gemfile.lock +172 -0
- data/gemfiles/4.0.1.gemfile +28 -0
- data/gemfiles/4.0.1.gemfile.lock +172 -0
- data/lib/shoulda-matchers.rb +1 -0
- data/lib/shoulda/matchers.rb +11 -0
- data/lib/shoulda/matchers/action_controller.rb +17 -0
- data/lib/shoulda/matchers/action_controller/filter_param_matcher.rb +64 -0
- data/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +97 -0
- data/lib/shoulda/matchers/action_controller/render_template_matcher.rb +81 -0
- data/lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb +117 -0
- data/lib/shoulda/matchers/action_controller/rescue_from_matcher.rb +114 -0
- data/lib/shoulda/matchers/action_controller/respond_with_matcher.rb +154 -0
- data/lib/shoulda/matchers/action_controller/route_matcher.rb +116 -0
- data/lib/shoulda/matchers/action_controller/route_params.rb +48 -0
- data/lib/shoulda/matchers/action_controller/set_session_matcher.rb +164 -0
- data/lib/shoulda/matchers/action_controller/set_the_flash_matcher.rb +296 -0
- data/lib/shoulda/matchers/active_model.rb +30 -0
- data/lib/shoulda/matchers/active_model/allow_mass_assignment_of_matcher.rb +167 -0
- data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +314 -0
- data/lib/shoulda/matchers/active_model/disallow_value_matcher.rb +46 -0
- data/lib/shoulda/matchers/active_model/ensure_exclusion_of_matcher.rb +160 -0
- data/lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb +417 -0
- data/lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb +337 -0
- data/lib/shoulda/matchers/active_model/errors.rb +10 -0
- data/lib/shoulda/matchers/active_model/exception_message_finder.rb +58 -0
- data/lib/shoulda/matchers/active_model/have_secure_password_matcher.rb +92 -0
- data/lib/shoulda/matchers/active_model/helpers.rb +46 -0
- data/lib/shoulda/matchers/active_model/numericality_matchers.rb +9 -0
- data/lib/shoulda/matchers/active_model/numericality_matchers/comparison_matcher.rb +75 -0
- data/lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb +27 -0
- data/lib/shoulda/matchers/active_model/numericality_matchers/numeric_type_matcher.rb +41 -0
- data/lib/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher.rb +27 -0
- data/lib/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher.rb +26 -0
- data/lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb +112 -0
- data/lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb +77 -0
- data/lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb +121 -0
- data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +380 -0
- data/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +89 -0
- data/lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb +372 -0
- data/lib/shoulda/matchers/active_model/validation_matcher.rb +97 -0
- data/lib/shoulda/matchers/active_model/validation_message_finder.rb +69 -0
- data/lib/shoulda/matchers/active_record.rb +22 -0
- data/lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb +204 -0
- data/lib/shoulda/matchers/active_record/association_matcher.rb +901 -0
- data/lib/shoulda/matchers/active_record/association_matchers.rb +9 -0
- data/lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb +41 -0
- data/lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb +41 -0
- data/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +81 -0
- data/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +65 -0
- data/lib/shoulda/matchers/active_record/association_matchers/option_verifier.rb +94 -0
- data/lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb +41 -0
- data/lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb +41 -0
- data/lib/shoulda/matchers/active_record/association_matchers/through_matcher.rb +63 -0
- data/lib/shoulda/matchers/active_record/have_db_column_matcher.rb +261 -0
- data/lib/shoulda/matchers/active_record/have_db_index_matcher.rb +149 -0
- data/lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb +72 -0
- data/lib/shoulda/matchers/active_record/serialize_matcher.rb +181 -0
- data/lib/shoulda/matchers/assertion_error.rb +19 -0
- data/lib/shoulda/matchers/error.rb +6 -0
- data/lib/shoulda/matchers/integrations/rspec.rb +20 -0
- data/lib/shoulda/matchers/integrations/test_unit.rb +30 -0
- data/lib/shoulda/matchers/rails_shim.rb +50 -0
- data/lib/shoulda/matchers/version.rb +6 -0
- data/lib/shoulda/matchers/warn.rb +8 -0
- data/shoulda-matchers.gemspec +23 -0
- data/spec/shoulda/matchers/action_controller/filter_param_matcher_spec.rb +22 -0
- data/spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb +42 -0
- data/spec/shoulda/matchers/action_controller/render_template_matcher_spec.rb +78 -0
- data/spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb +63 -0
- data/spec/shoulda/matchers/action_controller/rescue_from_matcher_spec.rb +63 -0
- data/spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb +31 -0
- data/spec/shoulda/matchers/action_controller/route_matcher_spec.rb +70 -0
- data/spec/shoulda/matchers/action_controller/route_params_spec.rb +30 -0
- data/spec/shoulda/matchers/action_controller/set_session_matcher_spec.rb +51 -0
- data/spec/shoulda/matchers/action_controller/set_the_flash_matcher_spec.rb +153 -0
- data/spec/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb +111 -0
- data/spec/shoulda/matchers/active_model/allow_value_matcher_spec.rb +170 -0
- data/spec/shoulda/matchers/active_model/disallow_value_matcher_spec.rb +81 -0
- data/spec/shoulda/matchers/active_model/ensure_exclusion_of_matcher_spec.rb +95 -0
- data/spec/shoulda/matchers/active_model/ensure_inclusion_of_matcher_spec.rb +320 -0
- data/spec/shoulda/matchers/active_model/ensure_length_of_matcher_spec.rb +166 -0
- data/spec/shoulda/matchers/active_model/exception_message_finder_spec.rb +111 -0
- data/spec/shoulda/matchers/active_model/have_secure_password_matcher_spec.rb +20 -0
- data/spec/shoulda/matchers/active_model/helpers_spec.rb +158 -0
- data/spec/shoulda/matchers/active_model/numericality_matchers/comparison_matcher_spec.rb +169 -0
- data/spec/shoulda/matchers/active_model/numericality_matchers/even_number_matcher_spec.rb +59 -0
- data/spec/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher_spec.rb +59 -0
- data/spec/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher_spec.rb +57 -0
- data/spec/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb +139 -0
- data/spec/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb +41 -0
- data/spec/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb +47 -0
- data/spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb +331 -0
- data/spec/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb +180 -0
- data/spec/shoulda/matchers/active_model/validate_uniqueness_of_matcher_spec.rb +398 -0
- data/spec/shoulda/matchers/active_model/validation_message_finder_spec.rb +127 -0
- data/spec/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb +107 -0
- data/spec/shoulda/matchers/active_record/association_matcher_spec.rb +860 -0
- data/spec/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb +247 -0
- data/spec/shoulda/matchers/active_record/have_db_column_matcher_spec.rb +111 -0
- data/spec/shoulda/matchers/active_record/have_db_index_matcher_spec.rb +78 -0
- data/spec/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb +41 -0
- data/spec/shoulda/matchers/active_record/serialize_matcher_spec.rb +86 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/support/active_model_versions.rb +13 -0
- data/spec/support/active_resource_builder.rb +29 -0
- data/spec/support/activemodel_helpers.rb +19 -0
- data/spec/support/capture_helpers.rb +19 -0
- data/spec/support/class_builder.rb +42 -0
- data/spec/support/controller_builder.rb +74 -0
- data/spec/support/fail_with_message_including_matcher.rb +33 -0
- data/spec/support/fail_with_message_matcher.rb +32 -0
- data/spec/support/i18n_faker.rb +10 -0
- data/spec/support/mailer_builder.rb +10 -0
- data/spec/support/model_builder.rb +81 -0
- data/spec/support/rails_versions.rb +18 -0
- data/spec/support/shared_examples/numerical_submatcher.rb +19 -0
- data/spec/support/shared_examples/numerical_type_submatcher.rb +17 -0
- data/spec/support/test_application.rb +120 -0
- data/yard.watchr +5 -0
- metadata +281 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal", "~> 0.4"
|
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 "shoulda-context", "~> 1.1.2"
|
15
|
+
gem "sqlite3", :platform=>:ruby
|
16
|
+
gem "activerecord-jdbc-adapter", :platform=>:jruby
|
17
|
+
gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
|
18
|
+
gem "jdbc-sqlite3", :platform=>:jruby
|
19
|
+
gem "jruby-openssl", :platform=>:jruby
|
20
|
+
gem "therubyrhino", :platform=>:jruby
|
21
|
+
gem "jquery-rails"
|
22
|
+
gem "activeresource", "4.0.0"
|
23
|
+
gem "protected_attributes"
|
24
|
+
gem "rails", "4.0.1"
|
25
|
+
gem "sass-rails", "4.0.1"
|
26
|
+
gem "bcrypt-ruby", "~> 3.1.2"
|
27
|
+
|
28
|
+
gemspec :path=>".././"
|
@@ -0,0 +1,172 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
shoulda-matchers (2.5.0)
|
5
|
+
activesupport (>= 3.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (4.0.1)
|
11
|
+
actionpack (= 4.0.1)
|
12
|
+
mail (~> 2.5.4)
|
13
|
+
actionpack (4.0.1)
|
14
|
+
activesupport (= 4.0.1)
|
15
|
+
builder (~> 3.1.0)
|
16
|
+
erubis (~> 2.7.0)
|
17
|
+
rack (~> 1.5.2)
|
18
|
+
rack-test (~> 0.6.2)
|
19
|
+
activemodel (4.0.1)
|
20
|
+
activesupport (= 4.0.1)
|
21
|
+
builder (~> 3.1.0)
|
22
|
+
activerecord (4.0.1)
|
23
|
+
activemodel (= 4.0.1)
|
24
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
25
|
+
activesupport (= 4.0.1)
|
26
|
+
arel (~> 4.0.0)
|
27
|
+
activerecord-deprecated_finders (1.0.3)
|
28
|
+
activeresource (4.0.0)
|
29
|
+
activemodel (~> 4.0)
|
30
|
+
activesupport (~> 4.0)
|
31
|
+
rails-observers (~> 0.1.1)
|
32
|
+
activesupport (4.0.1)
|
33
|
+
i18n (~> 0.6, >= 0.6.4)
|
34
|
+
minitest (~> 4.2)
|
35
|
+
multi_json (~> 1.3)
|
36
|
+
thread_safe (~> 0.1)
|
37
|
+
tzinfo (~> 0.3.37)
|
38
|
+
appraisal (1.0.0.beta2)
|
39
|
+
bundler
|
40
|
+
rake
|
41
|
+
thor (>= 0.14.0)
|
42
|
+
arel (4.0.1)
|
43
|
+
aruba (0.5.3)
|
44
|
+
childprocess (>= 0.3.6)
|
45
|
+
cucumber (>= 1.1.1)
|
46
|
+
rspec-expectations (>= 2.7.0)
|
47
|
+
atomic (1.1.14)
|
48
|
+
bcrypt-ruby (3.1.2)
|
49
|
+
bourne (1.5.0)
|
50
|
+
mocha (>= 0.13.2, < 0.15)
|
51
|
+
builder (3.1.4)
|
52
|
+
childprocess (0.3.9)
|
53
|
+
ffi (~> 1.0, >= 1.0.11)
|
54
|
+
coderay (1.1.0)
|
55
|
+
cucumber (1.3.10)
|
56
|
+
builder (>= 2.1.2)
|
57
|
+
diff-lcs (>= 1.1.3)
|
58
|
+
gherkin (~> 2.12)
|
59
|
+
multi_json (>= 1.7.5, < 2.0)
|
60
|
+
multi_test (>= 0.0.2)
|
61
|
+
diff-lcs (1.2.5)
|
62
|
+
erubis (2.7.0)
|
63
|
+
ffi (1.9.3)
|
64
|
+
gherkin (2.12.2)
|
65
|
+
multi_json (~> 1.3)
|
66
|
+
hike (1.2.3)
|
67
|
+
i18n (0.6.5)
|
68
|
+
jquery-rails (3.0.4)
|
69
|
+
railties (>= 3.0, < 5.0)
|
70
|
+
thor (>= 0.14, < 2.0)
|
71
|
+
mail (2.5.4)
|
72
|
+
mime-types (~> 1.16)
|
73
|
+
treetop (~> 1.4.8)
|
74
|
+
metaclass (0.0.1)
|
75
|
+
method_source (0.8.2)
|
76
|
+
mime-types (1.25.1)
|
77
|
+
minitest (4.7.5)
|
78
|
+
mocha (0.14.0)
|
79
|
+
metaclass (~> 0.0.1)
|
80
|
+
multi_json (1.8.2)
|
81
|
+
multi_test (0.0.2)
|
82
|
+
polyglot (0.3.3)
|
83
|
+
protected_attributes (1.0.5)
|
84
|
+
activemodel (>= 4.0.1, < 5.0)
|
85
|
+
pry (0.9.12.6)
|
86
|
+
coderay (~> 1.0)
|
87
|
+
method_source (~> 0.8)
|
88
|
+
slop (~> 3.4)
|
89
|
+
rack (1.5.2)
|
90
|
+
rack-test (0.6.2)
|
91
|
+
rack (>= 1.0)
|
92
|
+
rails (4.0.1)
|
93
|
+
actionmailer (= 4.0.1)
|
94
|
+
actionpack (= 4.0.1)
|
95
|
+
activerecord (= 4.0.1)
|
96
|
+
activesupport (= 4.0.1)
|
97
|
+
bundler (>= 1.3.0, < 2.0)
|
98
|
+
railties (= 4.0.1)
|
99
|
+
sprockets-rails (~> 2.0.0)
|
100
|
+
rails-observers (0.1.2)
|
101
|
+
activemodel (~> 4.0)
|
102
|
+
railties (4.0.1)
|
103
|
+
actionpack (= 4.0.1)
|
104
|
+
activesupport (= 4.0.1)
|
105
|
+
rake (>= 0.8.7)
|
106
|
+
thor (>= 0.18.1, < 2.0)
|
107
|
+
rake (10.1.1)
|
108
|
+
rspec-core (2.14.7)
|
109
|
+
rspec-expectations (2.14.4)
|
110
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
111
|
+
rspec-mocks (2.14.4)
|
112
|
+
rspec-rails (2.14.0)
|
113
|
+
actionpack (>= 3.0)
|
114
|
+
activesupport (>= 3.0)
|
115
|
+
railties (>= 3.0)
|
116
|
+
rspec-core (~> 2.14.0)
|
117
|
+
rspec-expectations (~> 2.14.0)
|
118
|
+
rspec-mocks (~> 2.14.0)
|
119
|
+
sass (3.2.12)
|
120
|
+
sass-rails (4.0.1)
|
121
|
+
railties (>= 4.0.0, < 5.0)
|
122
|
+
sass (>= 3.1.10)
|
123
|
+
sprockets-rails (~> 2.0.0)
|
124
|
+
shoulda-context (1.1.6)
|
125
|
+
slop (3.4.7)
|
126
|
+
sprockets (2.10.1)
|
127
|
+
hike (~> 1.2)
|
128
|
+
multi_json (~> 1.0)
|
129
|
+
rack (~> 1.0)
|
130
|
+
tilt (~> 1.1, != 1.3.0)
|
131
|
+
sprockets-rails (2.0.1)
|
132
|
+
actionpack (>= 3.0)
|
133
|
+
activesupport (>= 3.0)
|
134
|
+
sprockets (~> 2.8)
|
135
|
+
sqlite3 (1.3.8)
|
136
|
+
thor (0.18.1)
|
137
|
+
thread_safe (0.1.3)
|
138
|
+
atomic
|
139
|
+
tilt (1.4.1)
|
140
|
+
treetop (1.4.15)
|
141
|
+
polyglot
|
142
|
+
polyglot (>= 0.3.1)
|
143
|
+
tzinfo (0.3.38)
|
144
|
+
yard (0.8.7.3)
|
145
|
+
|
146
|
+
PLATFORMS
|
147
|
+
ruby
|
148
|
+
|
149
|
+
DEPENDENCIES
|
150
|
+
activerecord-jdbc-adapter
|
151
|
+
activerecord-jdbcsqlite3-adapter
|
152
|
+
activeresource (= 4.0.0)
|
153
|
+
appraisal (~> 1.0.0.beta2)
|
154
|
+
aruba
|
155
|
+
bcrypt-ruby (~> 3.1.2)
|
156
|
+
bourne (~> 1.3)
|
157
|
+
bundler (~> 1.1)
|
158
|
+
cucumber (~> 1.1)
|
159
|
+
jdbc-sqlite3
|
160
|
+
jquery-rails
|
161
|
+
jruby-openssl
|
162
|
+
protected_attributes
|
163
|
+
pry
|
164
|
+
rails (= 4.0.1)
|
165
|
+
rake (>= 0.9.2)
|
166
|
+
rspec-rails (>= 2.13.1, < 3)
|
167
|
+
sass-rails (= 4.0.1)
|
168
|
+
shoulda-context (~> 1.1.2)
|
169
|
+
shoulda-matchers!
|
170
|
+
sqlite3
|
171
|
+
therubyrhino
|
172
|
+
yard
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'shoulda/matchers'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'shoulda/matchers/assertion_error'
|
2
|
+
require 'shoulda/matchers/error'
|
3
|
+
require 'shoulda/matchers/rails_shim'
|
4
|
+
require 'shoulda/matchers/warn'
|
5
|
+
require 'shoulda/matchers/version'
|
6
|
+
|
7
|
+
if defined?(RSpec)
|
8
|
+
require 'shoulda/matchers/integrations/rspec'
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'shoulda/matchers/integrations/test_unit'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'shoulda/matchers/action_controller/filter_param_matcher'
|
2
|
+
require 'shoulda/matchers/action_controller/route_params'
|
3
|
+
require 'shoulda/matchers/action_controller/set_the_flash_matcher'
|
4
|
+
require 'shoulda/matchers/action_controller/render_with_layout_matcher'
|
5
|
+
require 'shoulda/matchers/action_controller/respond_with_matcher'
|
6
|
+
require 'shoulda/matchers/action_controller/set_session_matcher'
|
7
|
+
require 'shoulda/matchers/action_controller/route_matcher'
|
8
|
+
require 'shoulda/matchers/action_controller/redirect_to_matcher'
|
9
|
+
require 'shoulda/matchers/action_controller/render_template_matcher'
|
10
|
+
require 'shoulda/matchers/action_controller/rescue_from_matcher'
|
11
|
+
|
12
|
+
module Shoulda
|
13
|
+
module Matchers
|
14
|
+
module ActionController
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Shoulda
|
2
|
+
module Matchers
|
3
|
+
module ActionController
|
4
|
+
# The `filter_param` matcher is used to test parameter filtering
|
5
|
+
# configuration. Specifically, it asserts that the given parameter is
|
6
|
+
# present in `config.filter_parameters`.
|
7
|
+
#
|
8
|
+
# class MyApplication < Rails::Application
|
9
|
+
# config.filter_parameters << :secret_key
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# # RSpec
|
13
|
+
# describe ApplicationController do
|
14
|
+
# it { should filter_param(:secret_key) }
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# # Test::Unit
|
18
|
+
# class ApplicationControllerTest < ActionController::TestCase
|
19
|
+
# should filter_param(:secret_key)
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# @return [FilterParamMatcher]
|
23
|
+
#
|
24
|
+
def filter_param(key)
|
25
|
+
FilterParamMatcher.new(key)
|
26
|
+
end
|
27
|
+
|
28
|
+
# @private
|
29
|
+
class FilterParamMatcher
|
30
|
+
def initialize(key)
|
31
|
+
@key = key.to_s
|
32
|
+
end
|
33
|
+
|
34
|
+
def matches?(controller)
|
35
|
+
filters_key?
|
36
|
+
end
|
37
|
+
|
38
|
+
def failure_message
|
39
|
+
"Expected #{@key} to be filtered; filtered keys: #{filtered_keys.join(', ')}"
|
40
|
+
end
|
41
|
+
alias failure_message_for_should failure_message
|
42
|
+
|
43
|
+
def failure_message_when_negated
|
44
|
+
"Did not expect #{@key} to be filtered"
|
45
|
+
end
|
46
|
+
alias failure_message_for_should_not failure_message_when_negated
|
47
|
+
|
48
|
+
def description
|
49
|
+
"filter #{@key}"
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def filters_key?
|
55
|
+
filtered_keys.include?(@key)
|
56
|
+
end
|
57
|
+
|
58
|
+
def filtered_keys
|
59
|
+
Rails.application.config.filter_parameters.map(&:to_s)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Shoulda
|
2
|
+
module Matchers
|
3
|
+
module ActionController
|
4
|
+
# The `redirect_to` matcher tests that an action redirects to a certain
|
5
|
+
# location. In a test suite using RSpec, it is very similar to
|
6
|
+
# rspec-rails's `redirect_to` matcher. In a test suite using Test::Unit /
|
7
|
+
# Shoulda, it provides a more expressive syntax over
|
8
|
+
# `assert_redirected_to`.
|
9
|
+
#
|
10
|
+
# class PostsController < ApplicationController
|
11
|
+
# def show
|
12
|
+
# redirect_to :index
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# # RSpec
|
17
|
+
# describe PostsController do
|
18
|
+
# describe 'GET #list' do
|
19
|
+
# before { get :list }
|
20
|
+
#
|
21
|
+
# it { should redirect_to(posts_path) }
|
22
|
+
# it { should redirect_to(action: :index) }
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# # Test::Unit
|
27
|
+
# class PostsControllerTest < ActionController::TestCase
|
28
|
+
# context 'GET #list' do
|
29
|
+
# setup { get :list }
|
30
|
+
#
|
31
|
+
# should redirect_to { posts_path }
|
32
|
+
# should redirect_to(action: :index)
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# @return [RedirectToMatcher]
|
37
|
+
#
|
38
|
+
def redirect_to(url_or_description, &block)
|
39
|
+
RedirectToMatcher.new(url_or_description, self, &block)
|
40
|
+
end
|
41
|
+
|
42
|
+
# @private
|
43
|
+
class RedirectToMatcher
|
44
|
+
attr_reader :failure_message, :failure_message_when_negated
|
45
|
+
|
46
|
+
alias failure_message_for_should failure_message
|
47
|
+
alias failure_message_for_should_not failure_message_when_negated
|
48
|
+
|
49
|
+
def initialize(url_or_description, context, &block)
|
50
|
+
if block
|
51
|
+
@url_block = block
|
52
|
+
@location = url_or_description
|
53
|
+
else
|
54
|
+
@url = url_or_description
|
55
|
+
@location = @url
|
56
|
+
end
|
57
|
+
@context = context
|
58
|
+
end
|
59
|
+
|
60
|
+
def in_context(context)
|
61
|
+
@context = context
|
62
|
+
self
|
63
|
+
end
|
64
|
+
|
65
|
+
def matches?(controller)
|
66
|
+
@controller = controller
|
67
|
+
redirects_to_url?
|
68
|
+
end
|
69
|
+
|
70
|
+
def description
|
71
|
+
"redirect to #{@location}"
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def redirects_to_url?
|
77
|
+
begin
|
78
|
+
@context.__send__(:assert_redirected_to, url)
|
79
|
+
@failure_message_when_negated = "Didn't expect to redirect to #{url}"
|
80
|
+
true
|
81
|
+
rescue Shoulda::Matchers::AssertionError => error
|
82
|
+
@failure_message = error.message
|
83
|
+
false
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def url
|
88
|
+
if @url_block
|
89
|
+
@context.instance_eval(&@url_block)
|
90
|
+
else
|
91
|
+
@url
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Shoulda
|
2
|
+
module Matchers
|
3
|
+
module ActionController
|
4
|
+
# The `render_template` matcher tests that an action renders a template.
|
5
|
+
# In RSpec, it is very similar to rspec-rails's `render_template`
|
6
|
+
# matcher. In Test::Unit, it provides a more expressive syntax over
|
7
|
+
# `assert_template`.
|
8
|
+
#
|
9
|
+
# class PostsController < ApplicationController
|
10
|
+
# def show
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# # RSpec
|
15
|
+
# describe PostsController do
|
16
|
+
# describe 'GET #show' do
|
17
|
+
# before { get :show }
|
18
|
+
#
|
19
|
+
# it { should render_template('show') }
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# # Test::Unit
|
24
|
+
# class PostsControllerTest < ActionController::TestCase
|
25
|
+
# context 'GET #show' do
|
26
|
+
# setup { get :show }
|
27
|
+
#
|
28
|
+
# should render_template('show')
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# @return [RenderTemplateMatcher]
|
33
|
+
#
|
34
|
+
def render_template(options = {}, message = nil)
|
35
|
+
RenderTemplateMatcher.new(options, message, self)
|
36
|
+
end
|
37
|
+
|
38
|
+
# @private
|
39
|
+
class RenderTemplateMatcher
|
40
|
+
attr_reader :failure_message, :failure_message_when_negated
|
41
|
+
|
42
|
+
alias failure_message_for_should failure_message
|
43
|
+
alias failure_message_for_should_not failure_message_when_negated
|
44
|
+
|
45
|
+
def initialize(options, message, context)
|
46
|
+
@options = options
|
47
|
+
@message = message
|
48
|
+
@template = options.is_a?(Hash) ? options[:partial] : options
|
49
|
+
@context = context
|
50
|
+
end
|
51
|
+
|
52
|
+
def matches?(controller)
|
53
|
+
@controller = controller
|
54
|
+
renders_template?
|
55
|
+
end
|
56
|
+
|
57
|
+
def description
|
58
|
+
"render template #{@template}"
|
59
|
+
end
|
60
|
+
|
61
|
+
def in_context(context)
|
62
|
+
@context = context
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def renders_template?
|
69
|
+
begin
|
70
|
+
@context.__send__(:assert_template, @options, @message)
|
71
|
+
@failure_message_when_negated = "Didn't expect to render #{@template}"
|
72
|
+
true
|
73
|
+
rescue Shoulda::Matchers::AssertionError => error
|
74
|
+
@failure_message = error.message
|
75
|
+
false
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|