minitest-rails 3.0.0 → 5.0.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 (102) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +5 -0
  3. data/LICENSE +1 -1
  4. data/README.md +94 -0
  5. data/UPDATING.md +31 -0
  6. data/lib/generators/minitest.rb +17 -4
  7. data/lib/generators/minitest/controller/controller_generator.rb +6 -9
  8. data/lib/generators/minitest/controller/templates/{controller_spec.rb → functional_spec.rb.tt} +4 -4
  9. data/lib/generators/minitest/controller/templates/{controller_test.rb → functional_test.rb.tt} +3 -3
  10. data/lib/generators/minitest/generator/generator_generator.rb +3 -8
  11. data/lib/generators/minitest/generator/templates/{generator_spec.rb → generator_spec.rb.tt} +2 -2
  12. data/lib/generators/minitest/generator/templates/{generator_test.rb → generator_test.rb.tt} +1 -2
  13. data/lib/generators/minitest/helper/helper_generator.rb +5 -3
  14. data/lib/generators/minitest/install/install_generator.rb +19 -8
  15. data/lib/generators/minitest/install/templates/test/test_helper.rb.tt +16 -0
  16. data/lib/generators/minitest/integration/integration_generator.rb +12 -9
  17. data/lib/generators/minitest/integration/templates/integration_spec.rb.tt +9 -0
  18. data/lib/generators/minitest/integration/templates/integration_test.rb.tt +9 -0
  19. data/lib/generators/minitest/job/job_generator.rb +13 -10
  20. data/lib/generators/minitest/job/templates/unit_spec.rb.tt +9 -0
  21. data/lib/generators/minitest/job/templates/{job_test.rb → unit_test.rb.tt} +3 -3
  22. data/lib/generators/minitest/mailer/mailer_generator.rb +8 -11
  23. data/lib/generators/minitest/mailer/templates/functional_spec.rb.tt +21 -0
  24. data/lib/generators/minitest/mailer/templates/{mailer_test.rb → functional_test.rb.tt} +3 -3
  25. data/lib/generators/minitest/mailer/templates/{preview.rb → preview.rb.tt} +0 -0
  26. data/lib/generators/minitest/model/model_generator.rb +9 -12
  27. data/lib/generators/minitest/model/templates/{fixtures.yml → fixtures.yml.tt} +3 -3
  28. data/lib/generators/minitest/model/templates/unit_spec.rb.tt +9 -0
  29. data/lib/generators/minitest/model/templates/unit_test.rb.tt +9 -0
  30. data/lib/generators/minitest/plugin/plugin_generator.rb +15 -0
  31. data/lib/generators/minitest/plugin/templates/%file_name%_test.rb.tt +15 -0
  32. data/lib/generators/minitest/plugin/templates/test_helper.rb +2 -0
  33. data/lib/generators/minitest/scaffold/scaffold_generator.rb +21 -23
  34. data/lib/generators/minitest/scaffold/templates/api_functional_spec.rb.tt +42 -0
  35. data/lib/generators/minitest/scaffold/templates/api_functional_test.rb.tt +44 -0
  36. data/lib/generators/minitest/scaffold/templates/functional_spec.rb.tt +52 -0
  37. data/lib/generators/minitest/scaffold/templates/{controller_test.rb → functional_test.rb.tt} +16 -16
  38. data/lib/minitest/rails.rb +45 -108
  39. data/lib/minitest/rails/assertions.rb +5 -906
  40. data/lib/minitest/rails/assertions/action_dispatch.rb +356 -0
  41. data/lib/minitest/rails/assertions/action_mailer.rb +115 -0
  42. data/lib/minitest/rails/assertions/action_view.rb +356 -0
  43. data/lib/minitest/rails/assertions/active_job.rb +151 -0
  44. data/lib/minitest/rails/assertions/active_support.rb +29 -0
  45. data/lib/minitest/rails/expectations.rb +4 -565
  46. data/lib/minitest/rails/expectations/action_dispatch.rb +307 -0
  47. data/lib/minitest/rails/expectations/action_mailer.rb +136 -0
  48. data/lib/minitest/rails/expectations/active_job.rb +182 -0
  49. data/lib/minitest/rails/expectations/active_support.rb +42 -0
  50. data/lib/minitest/rails/railtie.rb +3 -2
  51. data/lib/minitest/rails/version.rb +1 -1
  52. metadata +72 -89
  53. data/.autotest +0 -23
  54. data/.gemtest +0 -0
  55. data/.travis.yml +0 -25
  56. data/CHANGELOG.rdoc +0 -223
  57. data/Gemfile +0 -7
  58. data/Manifest.txt +0 -76
  59. data/README.rdoc +0 -110
  60. data/Rakefile +0 -30
  61. data/gemfiles/5.0.gemfile +0 -5
  62. data/gemfiles/head.gemfile +0 -5
  63. data/lib/generators/.document +0 -0
  64. data/lib/generators/minitest/install/templates/test_helper.rb +0 -19
  65. data/lib/generators/minitest/integration/templates/integration_spec.rb +0 -8
  66. data/lib/generators/minitest/integration/templates/integration_test.rb +0 -7
  67. data/lib/generators/minitest/job/templates/job_spec.rb +0 -9
  68. data/lib/generators/minitest/mailer/templates/mailer_spec.rb +0 -20
  69. data/lib/generators/minitest/model/templates/model_spec.rb +0 -11
  70. data/lib/generators/minitest/model/templates/model_test.rb +0 -13
  71. data/lib/generators/minitest/scaffold/templates/api_controller_spec.rb +0 -42
  72. data/lib/generators/minitest/scaffold/templates/api_controller_test.rb +0 -44
  73. data/lib/generators/minitest/scaffold/templates/controller_spec.rb +0 -52
  74. data/lib/minitest/rails/constant_lookup.rb +0 -52
  75. data/lib/minitest/rails/controller.rb +0 -14
  76. data/minitest-rails.gemspec +0 -48
  77. data/tasks/test.rake +0 -29
  78. data/test/generators/test_controller_generator.rb +0 -58
  79. data/test/generators/test_generator_generator.rb +0 -58
  80. data/test/generators/test_helper_generator.rb +0 -34
  81. data/test/generators/test_install_generator.rb +0 -27
  82. data/test/generators/test_job_generator.rb +0 -45
  83. data/test/generators/test_mailer_generator.rb +0 -42
  84. data/test/generators/test_model_generator.rb +0 -80
  85. data/test/generators/test_scaffold_generator.rb +0 -26
  86. data/test/helper.rb +0 -93
  87. data/test/rails/action_dispatch/test_assertions.rb +0 -39
  88. data/test/rails/action_dispatch/test_expectations.rb +0 -39
  89. data/test/rails/action_dispatch/test_spec_type.rb +0 -49
  90. data/test/rails/action_mailer/test_mailers.rb +0 -109
  91. data/test/rails/action_mailer/test_spec_type.rb +0 -47
  92. data/test/rails/action_view/test_helpers.rb +0 -73
  93. data/test/rails/action_view/test_spec_type.rb +0 -58
  94. data/test/rails/active_job/test_assertions.rb +0 -46
  95. data/test/rails/active_job/test_expectations.rb +0 -55
  96. data/test/rails/active_job/test_spec_type.rb +0 -49
  97. data/test/rails/active_support/test_assertions.rb +0 -31
  98. data/test/rails/active_support/test_expectations.rb +0 -21
  99. data/test/rails/active_support/test_spec_type.rb +0 -28
  100. data/test/rails/generators/test_spec_type.rb +0 -45
  101. data/test/rails/test_constant_lookup.rb +0 -58
  102. data/test/test_sanity.rb +0 -7
@@ -0,0 +1,356 @@
1
+ class ActionView::TestCase
2
+ ##
3
+ # Checks the numeric difference between the return value of an expression as a result of what is evaluated.
4
+ #
5
+ # assert_difference "User.count", +1 do
6
+ # User.create
7
+ # end
8
+ #
9
+ # See also Minitest::Rails::Expectations#must_change
10
+ #
11
+ # :method: assert_difference
12
+ # :call-seq: assert_difference(expression, difference = 1, message = nil, &block)
13
+
14
+ ##
15
+ # Checks that the numeric result of evaluating an expression is not changed before and after invoking.
16
+ #
17
+ # assert_no_difference "User.count" do
18
+ # User.new
19
+ # end
20
+ #
21
+ # See also Minitest::Rails::Expectations#wont_change
22
+ #
23
+ # :method: assert_no_difference
24
+ # :call-seq: assert_no_difference(expression, message = nil, &block)
25
+
26
+ ##
27
+ # Checks that the numeric result of evaluating an expression is not changed before and after invoking.
28
+ #
29
+ # refute_difference "User.count", do
30
+ # User.new
31
+ # end
32
+ #
33
+ # See also Minitest::Rails::Expectations#wont_change
34
+ #
35
+ # :args: expression, message = nil, &block
36
+ alias refute_difference assert_no_difference
37
+
38
+ # Asserts that the response is one of the following types:
39
+ #
40
+ # * <tt>:success</tt> - Status code was in the 200-299 range
41
+ # * <tt>:redirect</tt> - Status code was in the 300-399 range
42
+ # * <tt>:missing</tt> - Status code was 404
43
+ # * <tt>:error</tt> - Status code was in the 500-599 range
44
+ #
45
+ # You can also pass an explicit status number like <tt>assert_response(501)</tt>
46
+ # or its symbolic equivalent <tt>assert_response(:not_implemented)</tt>.
47
+ # See Rack::Utils::SYMBOL_TO_STATUS_CODE for a full list.
48
+ #
49
+ # # assert that the response was a redirection
50
+ # assert_response :redirect
51
+ #
52
+ # # assert that the response code was status code 401 (unauthorized)
53
+ # assert_response 401
54
+ #
55
+ # See also Minitest::Rails::Expectations#must_respond_with
56
+ #
57
+ # :method: assert_response
58
+ # :call-seq: assert_response(type, message = nil)
59
+
60
+ ##
61
+ # Assert that the redirection options passed in match those of the redirect called in the latest action.
62
+ # This match can be partial, such that <tt>assert_redirected_to(controller: "weblog")</tt> will also
63
+ # match the redirection of <tt>redirect_to(controller: "weblog", action: "show")</tt> and so on.
64
+ #
65
+ # # assert that the redirection was to the "index" action on the WeblogController
66
+ # assert_redirected_to controller: "weblog", action: "index"
67
+ #
68
+ # # assert that the redirection was to the named route login_url
69
+ # assert_redirected_to login_url
70
+ #
71
+ # # assert that the redirection was to the url for @customer
72
+ # assert_redirected_to @customer
73
+ #
74
+ # # asserts that the redirection matches the regular expression
75
+ # assert_redirected_to %r(\Ahttp://example.org)
76
+ #
77
+ # See also Minitest::Rails::Expectations#must_redirect_to
78
+ #
79
+ # :method: assert_redirected_to
80
+ # :call-seq: assert_redirected_to(options = {}, message=nil)
81
+
82
+ ##
83
+ # Asserts that the provided options can be used to generate the provided path. This is the inverse of +assert_recognizes+.
84
+ # The +extras+ parameter is used to tell the request the names and values of additional request parameters that would be in
85
+ # a query string. The +message+ parameter allows you to specify a custom error message for assertion failures.
86
+ #
87
+ # The +defaults+ parameter is unused.
88
+ #
89
+ # # Asserts that the default action is generated for a route with no action
90
+ # assert_generates "/items", controller: "items", action: "index"
91
+ #
92
+ # # Tests that the list action is properly routed
93
+ # assert_generates "/items/list", controller: "items", action: "list"
94
+ #
95
+ # # Tests the generation of a route with a parameter
96
+ # assert_generates "/items/list/1", { controller: "items", action: "list", id: "1" }
97
+ #
98
+ # # Asserts that the generated route gives us our custom route
99
+ # assert_generates "changesets/12", { controller: 'scm', action: 'show_diff', revision: "12" }
100
+ #
101
+ # See also Minitest::Rails::Expectations#must_route_to
102
+ #
103
+ # :method: assert_generates
104
+ # :call-seq: assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)
105
+
106
+ ##
107
+ # Asserts that the routing of the given +path+ was handled correctly and that the parsed options (given in the +expected_options+ hash)
108
+ # match +path+. Basically, it asserts that \Rails recognizes the route given by +expected_options+.
109
+ #
110
+ # Pass a hash in the second argument (+path+) to specify the request method. This is useful for routes
111
+ # requiring a specific HTTP method. The hash should contain a :path with the incoming request path
112
+ # and a :method containing the required HTTP verb.
113
+ #
114
+ # # assert that POSTing to /items will call the create action on ItemsController
115
+ # assert_recognizes({controller: 'items', action: 'create'}, {path: 'items', method: :post})
116
+ #
117
+ # You can also pass in +extras+ with a hash containing URL parameters that would normally be in the query string. This can be used
118
+ # to assert that values in the query string string will end up in the params hash correctly. To test query strings you must use the
119
+ # extras argument, appending the query string on the path directly will not work. For example:
120
+ #
121
+ # # assert that a path of '/items/list/1?view=print' returns the correct options
122
+ # assert_recognizes({controller: 'items', action: 'list', id: '1', view: 'print'}, 'items/list/1', { view: "print" })
123
+ #
124
+ # The +message+ parameter allows you to pass in an error message that is displayed upon failure.
125
+ #
126
+ # # Check the default route (i.e., the index action)
127
+ # assert_recognizes({controller: 'items', action: 'index'}, 'items')
128
+ #
129
+ # # Test a specific action
130
+ # assert_recognizes({controller: 'items', action: 'list'}, 'items/list')
131
+ #
132
+ # # Test an action with a parameter
133
+ # assert_recognizes({controller: 'items', action: 'destroy', id: '1'}, 'items/destroy/1')
134
+ #
135
+ # # Test a custom route
136
+ # assert_recognizes({controller: 'items', action: 'show', id: '1'}, 'view/item1')
137
+ #
138
+ # See also Minitest::Rails::Expectations#must_route_from
139
+ #
140
+ # :method: assert_recognizes
141
+ # :call-seq: assert_recognizes(expected_options, path, extras={}, msg=nil)
142
+
143
+ ##
144
+ # Asserts that path and options match both ways; in other words, it verifies that <tt>path</tt> generates
145
+ # <tt>options</tt> and then that <tt>options</tt> generates <tt>path</tt>. This essentially combines +assert_recognizes+
146
+ # and +assert_generates+ into one step.
147
+ #
148
+ # The +extras+ hash allows you to specify options that would normally be provided as a query string to the action. The
149
+ # +message+ parameter allows you to specify a custom error message to display upon failure.
150
+ #
151
+ # # Assert a basic route: a controller with the default action (index)
152
+ # assert_routing '/home', controller: 'home', action: 'index'
153
+ #
154
+ # # Test a route generated with a specific controller, action, and parameter (id)
155
+ # assert_routing '/entries/show/23', controller: 'entries', action: 'show', id: 23
156
+ #
157
+ # # Assert a basic route (controller + default action), with an error message if it fails
158
+ # assert_routing '/store', { controller: 'store', action: 'index' }, {}, {}, 'Route for store index not generated properly'
159
+ #
160
+ # # Tests a route, providing a defaults hash
161
+ # assert_routing 'controller/action/9', {id: "9", item: "square"}, {controller: "controller", action: "action"}, {}, {item: "square"}
162
+ #
163
+ # # Tests a route with a HTTP method
164
+ # assert_routing({ method: 'put', path: '/product/321' }, { controller: "product", action: "update", id: "321" })
165
+ #
166
+ # See also Minitest::Rails::Expectations#must_route
167
+ #
168
+ # :method: assert_routing
169
+ # :call-seq: assert_routing(path, options, defaults={}, extras={}, message=nil)
170
+
171
+ # An assertion that selects elements and makes one or more equality tests.
172
+ #
173
+ # If the first argument is an element, selects all matching elements
174
+ # starting from (and including) that element and all its children in
175
+ # depth-first order.
176
+ #
177
+ # If no element if specified, calling +assert_select+ selects from the
178
+ # response HTML unless +assert_select+ is called from within an +assert_select+ block.
179
+ #
180
+ # When called with a block +assert_select+ passes an array of selected elements
181
+ # to the block. Calling +assert_select+ from the block, with no element specified,
182
+ # runs the assertion on the complete set of elements selected by the enclosing assertion.
183
+ # Alternatively the array may be iterated through so that +assert_select+ can be called
184
+ # separately for each element.
185
+ #
186
+ #
187
+ # ==== Example
188
+ # If the response contains two ordered lists, each with four list elements then:
189
+ # assert_select "ol" do |elements|
190
+ # elements.each do |element|
191
+ # assert_select element, "li", 4
192
+ # end
193
+ # end
194
+ #
195
+ # will pass, as will:
196
+ # assert_select "ol" do
197
+ # assert_select "li", 8
198
+ # end
199
+ #
200
+ # The selector may be a CSS selector expression (String), an expression
201
+ # with substitution values, or an HTML::Selector object.
202
+ #
203
+ # === Equality Tests
204
+ #
205
+ # The equality test may be one of the following:
206
+ # * <tt>true</tt> - Assertion is true if at least one element selected.
207
+ # * <tt>false</tt> - Assertion is true if no element selected.
208
+ # * <tt>String/Regexp</tt> - Assertion is true if the text value of at least
209
+ # one element matches the string or regular expression.
210
+ # * <tt>Integer</tt> - Assertion is true if exactly that number of
211
+ # elements are selected.
212
+ # * <tt>Range</tt> - Assertion is true if the number of selected
213
+ # elements fit the range.
214
+ # If no equality test specified, the assertion is true if at least one
215
+ # element selected.
216
+ #
217
+ # To perform more than one equality tests, use a hash with the following keys:
218
+ # * <tt>:text</tt> - Narrow the selection to elements that have this text
219
+ # value (string or regexp).
220
+ # * <tt>:html</tt> - Narrow the selection to elements that have this HTML
221
+ # content (string or regexp).
222
+ # * <tt>:count</tt> - Assertion is true if the number of selected elements
223
+ # is equal to this value.
224
+ # * <tt>:minimum</tt> - Assertion is true if the number of selected
225
+ # elements is at least this value.
226
+ # * <tt>:maximum</tt> - Assertion is true if the number of selected
227
+ # elements is at most this value.
228
+ #
229
+ # If the method is called with a block, once all equality tests are
230
+ # evaluated the block is called with an array of all matched elements.
231
+ #
232
+ # # At least one form element
233
+ # assert_select "form"
234
+ #
235
+ # # Form element includes four input fields
236
+ # assert_select "form input", 4
237
+ #
238
+ # # Page title is "Welcome"
239
+ # assert_select "title", "Welcome"
240
+ #
241
+ # # Page title is "Welcome" and there is only one title element
242
+ # assert_select "title", {count: 1, text: "Welcome"},
243
+ # "Wrong title or more than one title element"
244
+ #
245
+ # # Page contains no forms
246
+ # assert_select "form", false, "This page must contain no forms"
247
+ #
248
+ # # Test the content and style
249
+ # assert_select "body div.header ul.menu"
250
+ #
251
+ # # Use substitution values
252
+ # assert_select "ol>li#?", /item-\d+/
253
+ #
254
+ # # All input fields in the form have a name
255
+ # assert_select "form input" do
256
+ # assert_select "[name=?]", /.+/ # Not empty
257
+ # end
258
+ #
259
+ # See also Minitest::Rails::Expectations#must_select
260
+ #
261
+ # :method: assert_select
262
+ # :call-seq: assert_select(*args, &block)
263
+
264
+ # Extracts the body of an email and runs nested assertions on it.
265
+ #
266
+ # You must enable deliveries for this assertion to work, use:
267
+ # ActionMailer::Base.perform_deliveries = true
268
+ #
269
+ # assert_select_email do
270
+ # assert_select "h1", "Email alert"
271
+ # end
272
+ #
273
+ # assert_select_email do
274
+ # items = assert_select "ol>li"
275
+ # items.each do
276
+ # # Work with items here...
277
+ # end
278
+ # end
279
+ #
280
+ # See also Minitest::Rails::Expectations#must_select_email
281
+ #
282
+ # :method: assert_select_email
283
+ # :call-seq: assert_select_email(&block)
284
+
285
+ # Extracts the content of an element, treats it as encoded HTML and runs
286
+ # nested assertion on it.
287
+ #
288
+ # You typically call this method within another assertion to operate on
289
+ # all currently selected elements. You can also pass an element or array
290
+ # of elements.
291
+ #
292
+ # The content of each element is un-encoded, and wrapped in the root
293
+ # element +encoded+. It then calls the block with all un-encoded elements.
294
+ #
295
+ # # Selects all bold tags from within the title of an Atom feed's entries (perhaps to nab a section name prefix)
296
+ # assert_select "feed[xmlns='http://www.w3.org/2005/Atom']" do
297
+ # # Select each entry item and then the title item
298
+ # assert_select "entry>title" do
299
+ # # Run assertions on the encoded title elements
300
+ # assert_select_encoded do
301
+ # assert_select "b"
302
+ # end
303
+ # end
304
+ # end
305
+ #
306
+ #
307
+ # # Selects all paragraph tags from within the description of an RSS feed
308
+ # assert_select "rss[version=2.0]" do
309
+ # # Select description element of each feed item.
310
+ # assert_select "channel>item>description" do
311
+ # # Run assertions on the encoded elements.
312
+ # assert_select_encoded do
313
+ # assert_select "p"
314
+ # end
315
+ # end
316
+ # end
317
+ #
318
+ # See also Minitest::Rails::Expectations#must_select_encoded
319
+ #
320
+ # :method: assert_select_encoded
321
+ # :call-seq: assert_select_encoded(element = nil, &block)
322
+
323
+ ##
324
+ # Checks that two HTML strings are equivalent. That they contain the same elements and attributes with the associated values.
325
+ #
326
+ # assert_dom_equal '<a href="http://www.example.com">Apples</a>',
327
+ # link_to("Apples", "http://www.example.com")
328
+ #
329
+ # See also Minitest::Rails::Expectations#must_dom_equal
330
+ #
331
+ # :method: assert_dom_equal
332
+ # :call-seq: assert_dom_equal(expected, actual, message = nil)
333
+
334
+ ##
335
+ # Checks that two HTML strings are not equivalent. That they do not contain the same elements and attributes with the associated values.
336
+ #
337
+ # assert_dom_not_equal '<a href="http://www.example.com">Oranges</a>',
338
+ # link_to("Apples", "http://www.example.com")
339
+ #
340
+ # See also Minitest::Rails::Expectations#wont_dom_equal
341
+ #
342
+ # :method: assert_dom_not_equal
343
+ # :call-seq: assert_dom_not_equal(expected, actual, message = nil)
344
+
345
+ ##
346
+ # Checks that two HTML strings are not equivalent. That they do not contain the same elements and attributes with the associated values.
347
+ #
348
+ # refute_dom_equal '<a href="http://www.example.com">Oranges</a>',
349
+ # link_to("Apples", "http://www.example.com")
350
+ #
351
+ # See also Minitest::Rails::Expectations#wont_dom_equal
352
+ #
353
+ # :method: assert_dom_equal
354
+ # :call-seq: assert_dom_equal(expected, actual, message = nil)
355
+ alias refute_dom_equal assert_dom_not_equal
356
+ end
@@ -0,0 +1,151 @@
1
+ class ActiveJob::TestCase
2
+ # Asserts that the number of enqueued jobs matches the given number.
3
+ #
4
+ # def test_jobs
5
+ # assert_enqueued_jobs 0
6
+ # HelloJob.perform_later('david')
7
+ # assert_enqueued_jobs 1
8
+ # HelloJob.perform_later('abdelkader')
9
+ # assert_enqueued_jobs 2
10
+ # end
11
+ #
12
+ # If a block is passed, that block should cause the specified number of
13
+ # jobs to be enqueued.
14
+ #
15
+ # def test_jobs_again
16
+ # assert_enqueued_jobs 1 do
17
+ # HelloJob.perform_later('cristian')
18
+ # end
19
+ #
20
+ # assert_enqueued_jobs 2 do
21
+ # HelloJob.perform_later('aaron')
22
+ # HelloJob.perform_later('rafael')
23
+ # end
24
+ # end
25
+ #
26
+ # See also Minitest::Rails::Expectations#must_enqueue_jobs
27
+ #
28
+ # :method: assert_enqueued_jobs
29
+ # :call-seq: assert_enqueued_jobs(number)
30
+
31
+ ##
32
+ # Asserts that no jobs have been enqueued.
33
+ #
34
+ # def test_jobs
35
+ # refute_enqueued_jobs
36
+ # HelloJob.perform_later('jeremy')
37
+ # assert_enqueued_jobs 1
38
+ # end
39
+ #
40
+ # If a block is passed, that block should not cause any job to be enqueued.
41
+ #
42
+ # def test_jobs_again
43
+ # refute_enqueued_jobs do
44
+ # # No job should be enqueued from this block
45
+ # end
46
+ # end
47
+ #
48
+ # Note: This assertion is simply a shortcut for:
49
+ #
50
+ # assert_enqueued_jobs 0, &block
51
+ #
52
+ # See also Minitest::Rails::Expectations#wont_enqueue_jobs
53
+ #
54
+ # :args: number
55
+ alias refute_enqueued_jobs assert_no_enqueued_jobs
56
+
57
+ ##
58
+ # Asserts that the number of performed jobs matches the given number.
59
+ # If no block is passed, <tt>perform_enqueued_jobs</tt>d
60
+ # must be called around the job call.
61
+ #
62
+ # def test_jobs
63
+ # assert_performed_jobs 0
64
+ #
65
+ # perform_enqueued_jobs do
66
+ # HelloJob.perform_later('xavier')
67
+ # end
68
+ # assert_performed_jobs 1
69
+ #
70
+ # perform_enqueued_jobs do
71
+ # HelloJob.perform_later('yves')
72
+ # assert_performed_jobs 2
73
+ # end
74
+ # end
75
+ #
76
+ # If a block is passed, that block should cause the specified number of
77
+ # jobs to be performed.
78
+ #
79
+ # def test_jobs_again
80
+ # assert_performed_jobs 1 do
81
+ # HelloJob.perform_later('robin')
82
+ # end
83
+ #
84
+ # assert_performed_jobs 2 do
85
+ # HelloJob.perform_later('carlos')
86
+ # HelloJob.perform_later('sean')
87
+ # end
88
+ # end
89
+ #
90
+ # See also Minitest::Rails::Expectations#must_perform_jobs
91
+ #
92
+ # :method: assert_performed_jobs
93
+ # :call-seq: assert_performed_jobs(number)
94
+
95
+ ##
96
+ # Asserts that no jobs have been performed.
97
+ #
98
+ # def test_jobs
99
+ # refute_performed_jobs
100
+ #
101
+ # perform_enqueued_jobs do
102
+ # HelloJob.perform_later('matthew')
103
+ # assert_performed_jobs 1
104
+ # end
105
+ # end
106
+ #
107
+ # If a block is passed, that block should not cause any job to be performed.
108
+ #
109
+ # def test_jobs_again
110
+ # refute_performed_jobs do
111
+ # # No job should be performed from this block
112
+ # end
113
+ # end
114
+ #
115
+ # Note: This assertion is simply a shortcut for:
116
+ #
117
+ # assert_performed_jobs 0, &block
118
+ #
119
+ # See also Minitest::Rails::Expectations#wont_perform_jobs
120
+ #
121
+ # :args: number
122
+ alias refute_performed_jobs assert_no_performed_jobs
123
+
124
+ ##
125
+ # Asserts that the job passed in the block has been enqueued with the given arguments.
126
+ #
127
+ # def test_assert_enqueued_with
128
+ # assert_enqueued_with(job: MyJob, args: [1,2,3], queue: 'low') do
129
+ # MyJob.perform_later(1,2,3)
130
+ # end
131
+ # end
132
+ #
133
+ # See also Minitest::Rails::Expectations#must_enqueue_with
134
+ #
135
+ # :method: assert_enqueued_with
136
+ # :call-seq: assert_enqueued_with(args)
137
+
138
+ ##
139
+ # Asserts that the job passed in the block has been performed with the given arguments.
140
+ #
141
+ # def test_assert_performed_with
142
+ # assert_performed_with(job: MyJob, args: [1,2,3], queue: 'high') do
143
+ # MyJob.perform_later(1,2,3)
144
+ # end
145
+ # end
146
+ #
147
+ # See also Minitest::Rails::Expectations#must_perform_with
148
+ #
149
+ # :method: assert_performed_with
150
+ # :call-seq: assert_performed_with(args)
151
+ end