minitest-rails 5.1.0 → 7.1.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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -2
  3. data/README.md +47 -6
  4. data/lib/generators/minitest/controller/controller_generator.rb +2 -0
  5. data/lib/generators/minitest/controller/templates/functional_spec.rb.tt +2 -2
  6. data/lib/generators/minitest/controller/templates/functional_test.rb.tt +1 -1
  7. data/lib/generators/minitest/generator/generator_generator.rb +4 -2
  8. data/lib/generators/minitest/generator/templates/generator_spec.rb.tt +2 -2
  9. data/lib/generators/minitest/install/install_generator.rb +1 -0
  10. data/lib/generators/minitest/install/templates/test/channels/application_cable/connection_test.rb.tt +25 -0
  11. data/lib/generators/minitest/install/templates/test/test_helper.rb.tt +14 -6
  12. data/lib/generators/minitest/integration/templates/integration_spec.rb.tt +1 -1
  13. data/lib/generators/minitest/integration/templates/integration_test.rb.tt +1 -1
  14. data/lib/generators/minitest/job/templates/unit_spec.rb.tt +1 -1
  15. data/lib/generators/minitest/job/templates/unit_test.rb.tt +1 -1
  16. data/lib/generators/minitest/mailer/templates/functional_test.rb.tt +1 -1
  17. data/lib/generators/minitest/model/templates/unit_test.rb.tt +1 -1
  18. data/lib/generators/minitest/plugin/templates/%file_name%_test.rb.tt +1 -1
  19. data/lib/generators/minitest/scaffold/scaffold_generator.rb +9 -4
  20. data/lib/generators/minitest/scaffold/templates/api_functional_spec.rb.tt +3 -3
  21. data/lib/generators/minitest/scaffold/templates/api_functional_test.rb.tt +3 -3
  22. data/lib/generators/minitest/scaffold/templates/functional_spec.rb.tt +5 -5
  23. data/lib/generators/minitest/scaffold/templates/functional_test.rb.tt +5 -5
  24. data/lib/generators/minitest/scaffold/templates/system_spec.rb.tt +10 -12
  25. data/lib/generators/minitest/scaffold/templates/system_test.rb.tt +6 -8
  26. data/lib/generators/minitest/system/templates/system_spec.rb.tt +3 -4
  27. data/lib/generators/minitest/system/templates/system_test.rb.tt +2 -3
  28. data/lib/generators/minitest.rb +1 -1
  29. data/lib/minitest/rails/assertions/action_cable.rb +232 -0
  30. data/lib/minitest/rails/assertions/action_mailer.rb +42 -4
  31. data/lib/minitest/rails/assertions/active_job.rb +5 -0
  32. data/lib/minitest/rails/assertions/active_support.rb +4 -4
  33. data/lib/minitest/rails/assertions.rb +1 -0
  34. data/lib/minitest/rails/capybara.rb +1 -0
  35. data/lib/minitest/rails/expectations/action_cable.rb +197 -0
  36. data/lib/minitest/rails/expectations/action_mailer.rb +43 -4
  37. data/lib/minitest/rails/expectations/active_job.rb +4 -0
  38. data/lib/minitest/rails/expectations/active_support.rb +4 -4
  39. data/lib/minitest/rails/expectations.rb +1 -0
  40. data/lib/minitest/rails/parallelize.rb +41 -0
  41. data/lib/minitest/rails/version.rb +1 -1
  42. data/lib/minitest/rails.rb +44 -8
  43. metadata +26 -21
@@ -0,0 +1,232 @@
1
+ class ActionCable::TestCase
2
+ ##
3
+ # Asserts that the number of broadcasted messages to the stream matches the given number.
4
+ #
5
+ # def test_broadcasts
6
+ # assert_broadcasts 'messages', 0
7
+ # ActionCable.server.broadcast 'messages', { text: 'hello' }
8
+ # assert_broadcasts 'messages', 1
9
+ # ActionCable.server.broadcast 'messages', { text: 'world' }
10
+ # assert_broadcasts 'messages', 2
11
+ # end
12
+ #
13
+ # If a block is passed, that block should cause the specified number of
14
+ # messages to be broadcasted.
15
+ #
16
+ # def test_broadcasts_again
17
+ # assert_broadcasts('messages', 1) do
18
+ # ActionCable.server.broadcast 'messages', { text: 'hello' }
19
+ # end
20
+ #
21
+ # assert_broadcasts('messages', 2) do
22
+ # ActionCable.server.broadcast 'messages', { text: 'hi' }
23
+ # ActionCable.server.broadcast 'messages', { text: 'how are you?' }
24
+ # end
25
+ # end
26
+ #
27
+ # See also Minitest::Rails::Expectations::ActionCable::TestHelper#must_have_broadcasts
28
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/TestHelper.html#method-i-assert_broadcasts
29
+ #
30
+ # :method: assert_broadcasts
31
+ # :call-seq: assert_broadcasts(stream, number)
32
+
33
+ ##
34
+ # Asserts that no messages have been sent to the stream.
35
+ #
36
+ # def test_no_broadcasts
37
+ # refute_broadcasts 'messages'
38
+ # ActionCable.server.broadcast 'messages', { text: 'hi' }
39
+ # assert_broadcasts 'messages', 1
40
+ # end
41
+ #
42
+ # If a block is passed, that block should not cause any message to be sent.
43
+ #
44
+ # def test_broadcasts_again
45
+ # refute_broadcasts 'messages' do
46
+ # # No job messages should be sent from this block
47
+ # end
48
+ # end
49
+ #
50
+ # Note: This assertion is simply a shortcut for:
51
+ #
52
+ # assert_broadcasts 'messages', 0, &block
53
+ #
54
+ # See also Minitest::Rails::Expectations::ActionCable::TestHelper#wont_have_broadcasts
55
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/TestHelper.html#method-i-assert_no_broadcasts
56
+ #
57
+ # :method: refute_broadcasts
58
+ # :call-seq: refute_broadcasts(stream, &block)
59
+ alias refute_broadcasts assert_no_broadcasts
60
+
61
+ ##
62
+ # Asserts that the specified message has been sent to the stream.
63
+ #
64
+ # def test_assert_transmitted_message
65
+ # ActionCable.server.broadcast 'messages', text: 'hello'
66
+ # assert_broadcast_on('messages', text: 'hello')
67
+ # end
68
+ #
69
+ # If a block is passed, that block should cause a message with the specified data to be sent.
70
+ #
71
+ # def test_assert_broadcast_on_again
72
+ # assert_broadcast_on('messages', text: 'hello') do
73
+ # ActionCable.server.broadcast 'messages', text: 'hello'
74
+ # end
75
+ # end
76
+ #
77
+ # See also Minitest::Rails::Expectations::ActionCable::TestHelper#must_broadcast_on
78
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/TestHelper.html#method-i-assert_broadcast_on
79
+ #
80
+ # :method: assert_broadcast_on
81
+ # :call-seq: assert_broadcast_on(stream, data)
82
+ end
83
+
84
+ class ActionCable::Channel::TestCase
85
+ ##
86
+ # Asserts that the number of broadcasted messages to the stream matches the given number.
87
+ #
88
+ # def test_broadcasts
89
+ # assert_broadcasts 'messages', 0
90
+ # ActionCable.server.broadcast 'messages', { text: 'hello' }
91
+ # assert_broadcasts 'messages', 1
92
+ # ActionCable.server.broadcast 'messages', { text: 'world' }
93
+ # assert_broadcasts 'messages', 2
94
+ # end
95
+ #
96
+ # If a block is passed, that block should cause the specified number of
97
+ # messages to be broadcasted.
98
+ #
99
+ # def test_broadcasts_again
100
+ # assert_broadcasts('messages', 1) do
101
+ # ActionCable.server.broadcast 'messages', { text: 'hello' }
102
+ # end
103
+ #
104
+ # assert_broadcasts('messages', 2) do
105
+ # ActionCable.server.broadcast 'messages', { text: 'hi' }
106
+ # ActionCable.server.broadcast 'messages', { text: 'how are you?' }
107
+ # end
108
+ # end
109
+ #
110
+ # See also Minitest::Rails::Expectations::ActionCable::TestHelper#must_have_broadcasts
111
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/TestHelper.html#method-i-assert_broadcasts
112
+ #
113
+ # :method: assert_broadcasts
114
+ # :call-seq: assert_broadcasts(stream, number)
115
+
116
+ ##
117
+ # Asserts that no messages have been sent to the stream.
118
+ #
119
+ # def test_no_broadcasts
120
+ # refute_broadcasts 'messages'
121
+ # ActionCable.server.broadcast 'messages', { text: 'hi' }
122
+ # assert_broadcasts 'messages', 1
123
+ # end
124
+ #
125
+ # If a block is passed, that block should not cause any message to be sent.
126
+ #
127
+ # def test_broadcasts_again
128
+ # refute_broadcasts 'messages' do
129
+ # # No job messages should be sent from this block
130
+ # end
131
+ # end
132
+ #
133
+ # Note: This assertion is simply a shortcut for:
134
+ #
135
+ # assert_broadcasts 'messages', 0, &block
136
+ #
137
+ # See also Minitest::Rails::Expectations::ActionCable::TestHelper#wont_have_broadcasts
138
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/TestHelper.html#method-i-assert_no_broadcasts
139
+ #
140
+ # :method: refute_broadcasts
141
+ # :call-seq: refute_broadcasts(stream, &block)
142
+ alias refute_broadcasts assert_no_broadcasts
143
+
144
+ ##
145
+ # Asserts that the specified message has been sent to the stream.
146
+ #
147
+ # def test_assert_transmitted_message
148
+ # ActionCable.server.broadcast 'messages', text: 'hello'
149
+ # assert_broadcast_on('messages', text: 'hello')
150
+ # end
151
+ #
152
+ # If a block is passed, that block should cause a message with the specified data to be sent.
153
+ #
154
+ # def test_assert_broadcast_on_again
155
+ # assert_broadcast_on('messages', text: 'hello') do
156
+ # ActionCable.server.broadcast 'messages', text: 'hello'
157
+ # end
158
+ # end
159
+ #
160
+ # See also Minitest::Rails::Expectations::ActionCable::TestHelper#must_broadcast_on
161
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/TestHelper.html#method-i-assert_broadcast_on
162
+ #
163
+ # :method: assert_broadcast_on
164
+ # :call-seq: assert_broadcast_on(stream, data)
165
+
166
+ ##
167
+ # Asserts that no streams have been started.
168
+ #
169
+ # def test_assert_no_started_stream
170
+ # subscribe
171
+ # assert_no_streams
172
+ # end
173
+ #
174
+ # See also Minitest::Rails::Expectations::ActionCable::Channel#wont_have_streams
175
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/Channel/TestCase/Behavior.html#method-i-assert_no_streams
176
+ #
177
+ # :method: refute_streams
178
+ alias refute_streams assert_no_streams
179
+
180
+ ##
181
+ # Asserts that the specified stream has been started.
182
+ #
183
+ # def test_assert_started_stream
184
+ # subscribe
185
+ # assert_has_stream 'messages'
186
+ # end
187
+ #
188
+ # See also Minitest::Rails::Expectations::ActionCable::Channel#must_have_streams
189
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/Channel/TestCase/Behavior.html#method-i-assert_has_stream
190
+ #
191
+ # :method: assert_has_stream
192
+ # :call-seq: assert_has_stream(stream)
193
+
194
+ ##
195
+ # Asserts that the specified stream for a model has started.
196
+ #
197
+ # def test_assert_started_stream_for
198
+ # subscribe id: 42
199
+ # assert_has_stream_for User.find(42)
200
+ # end
201
+ #
202
+ # See also Minitest::Rails::Expectations::ActionCable::Channel#must_have_stream_for
203
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/Channel/TestCase/Behavior.html#method-i-assert_has_stream_for
204
+ #
205
+ # :method: assert_has_stream_for
206
+ # :call-seq: assert_has_stream_for(object)
207
+ end
208
+
209
+ class ActionCable::Connection::TestCase
210
+ # Asserts that the connection is rejected (via +reject_unauthorized_connection+).
211
+ #
212
+ # class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase
213
+ # def test_connects_with_proper_cookie
214
+ # # Simulate the connection request with a cookie.
215
+ # cookies["user_id"] = users(:john).id
216
+ #
217
+ # connect
218
+ #
219
+ # # Assert the connection identifier matches the fixture.
220
+ # assert_equal users(:john).id, connection.user.id
221
+ # end
222
+ #
223
+ # def test_rejects_connection_without_proper_cookie
224
+ # assert_reject_connection { connect }
225
+ # end
226
+ # end
227
+ #
228
+ # See also Minitest::Rails::Expectations::ActionCable#must_reject_connection
229
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/Connection/Assertions.html#method-i-assert_reject_connection
230
+ #
231
+ # :method: assert_reject_connection
232
+ end
@@ -25,7 +25,7 @@ class ActionMailer::TestCase
25
25
  # end
26
26
  #
27
27
  # See also Minitest::Rails::Expectations::ActionMailer#must_have_emails
28
- # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_emails
28
+ # See https://api.rubyonrails.org/v7.1/classes/ActionMailer/TestHelper.html#method-i-assert_emails
29
29
  #
30
30
  # :method: assert_emails
31
31
  # :call-seq: assert_emails(number, &block)
@@ -51,7 +51,7 @@ class ActionMailer::TestCase
51
51
  # assert_emails 0, &block
52
52
  #
53
53
  # See also Minitest::Rails::Expectations::ActionMailer#wont_have_emails
54
- # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_no_emails
54
+ # See https://api.rubyonrails.org/v7.1/classes/ActionMailer/TestHelper.html#method-i-assert_no_emails
55
55
  #
56
56
  # :method: refute_emails
57
57
  # :call-seq: refute_emails(&block)
@@ -84,11 +84,49 @@ class ActionMailer::TestCase
84
84
  # end
85
85
  #
86
86
  # See also Minitest::Rails::Expectations::ActionMailer#must_have_enqueued_emails
87
- # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_enqueued_emails
87
+ # See https://api.rubyonrails.org/v7.1/classes/ActionMailer/TestHelper.html#method-i-assert_enqueued_emails
88
88
  #
89
89
  # :method: assert_enqueued_emails
90
90
  # :call-seq: assert_enqueued_emails(number, &block)
91
91
 
92
+ ##
93
+ # Asserts that a specific email has been enqueued, optionally
94
+ # matching arguments.
95
+ #
96
+ # def test_email
97
+ # ContactMailer.welcome.deliver_later
98
+ # assert_enqueued_email_with ContactMailer, :welcome
99
+ # end
100
+ #
101
+ # def test_email_with_arguments
102
+ # ContactMailer.welcome("Hello", "Goodbye").deliver_later
103
+ # assert_enqueued_email_with ContactMailer, :welcome, args: ["Hello", "Goodbye"]
104
+ # end
105
+ #
106
+ # If a block is passed, that block should cause the specified email
107
+ # to be enqueued.
108
+ #
109
+ # def test_email_in_block
110
+ # assert_enqueued_email_with ContactMailer, :welcome do
111
+ # ContactMailer.welcome.deliver_later
112
+ # end
113
+ # end
114
+ #
115
+ # If +args+ is provided as a Hash, a parameterized email is matched.
116
+ #
117
+ # def test_parameterized_email
118
+ # assert_enqueued_email_with ContactMailer, :welcome,
119
+ # args: {email: 'user@example.com'} do
120
+ # ContactMailer.with(email: 'user@example.com').welcome.deliver_later
121
+ # end
122
+ # end
123
+ #
124
+ # See also Minitest::Rails::Expectations::ActionMailer#must_enqueue_email_with
125
+ # See https://api.rubyonrails.org/v7.1/classes/ActionMailer/TestHelper.html#method-i-assert_enqueued_email_with
126
+ #
127
+ # :method: assert_enqueued_email_with
128
+ # :call-seq: assert_enqueued_email_with(mailer, method, args: nil, queue: "mailers", &block)
129
+
92
130
  ##
93
131
  # Asserts that no emails are enqueued for later delivery.
94
132
  #
@@ -107,7 +145,7 @@ class ActionMailer::TestCase
107
145
  # end
108
146
  #
109
147
  # See also Minitest::Rails::Expectations::ActionMailer#wont_have_enqueued_emails
110
- # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_no_enqueued_emails
148
+ # See https://api.rubyonrails.org/v7.1/classes/ActionMailer/TestHelper.html#method-i-assert_no_enqueued_emails
111
149
  #
112
150
  # :method: refute_enqueued_emails
113
151
  # :call-seq: refute_enqueued_emails(&block)
@@ -149,3 +149,8 @@ class ActiveJob::TestCase
149
149
  # :method: assert_performed_with
150
150
  # :call-seq: assert_performed_with(args)
151
151
  end
152
+
153
+ module ActiveJob::TestHelper # :nodoc:
154
+ alias refute_enqueued_jobs assert_no_enqueued_jobs # :nodoc:
155
+ alias refute_performed_jobs assert_no_performed_jobs # :nodoc:
156
+ end
@@ -8,7 +8,7 @@ class ActiveSupport::TestCase
8
8
  # end
9
9
  #
10
10
  # See also Minitest::Rails::Expectations::ActiveSupport#must_change
11
- # See https://api.rubyonrails.org/v5.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_changes
11
+ # See https://api.rubyonrails.org/v7.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_changes
12
12
  #
13
13
  # :method: assert_changes
14
14
  # :call-seq: assert_changes(expression, message = nil, from: UNTRACKED, to: UNTRACKED, &block)
@@ -22,7 +22,7 @@ class ActiveSupport::TestCase
22
22
  # end
23
23
  #
24
24
  # See also Minitest::Rails::Expectations::ActiveSupport#wont_change
25
- # See https://api.rubyonrails.org/v5.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_changes
25
+ # See https://api.rubyonrails.org/v7.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_changes
26
26
  #
27
27
  # :args: expression, message = nil, &block
28
28
  alias refute_changes assert_no_changes
@@ -36,7 +36,7 @@ class ActiveSupport::TestCase
36
36
  # end
37
37
  #
38
38
  # See also Minitest::Rails::Expectations::ActiveSupport#must_change
39
- # See https://api.rubyonrails.org/v5.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_difference
39
+ # See https://api.rubyonrails.org/v7.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_difference
40
40
  #
41
41
  # :method: assert_difference
42
42
  # :call-seq: assert_difference(expression, *args, &block)
@@ -50,7 +50,7 @@ class ActiveSupport::TestCase
50
50
  # end
51
51
  #
52
52
  # See also Minitest::Rails::Expectations::ActiveSupport#wont_change
53
- # See https://api.rubyonrails.org/v5.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_difference
53
+ # See https://api.rubyonrails.org/v7.1/classes/ActiveSupport/Testing/Assertions.html#method-i-assert_no_difference
54
54
  #
55
55
  # :args: expression, message = nil, &block
56
56
  alias refute_difference assert_no_difference
@@ -2,4 +2,5 @@ require "minitest/rails/assertions/active_support"
2
2
  require "minitest/rails/assertions/action_view"
3
3
  require "minitest/rails/assertions/action_dispatch"
4
4
  require "minitest/rails/assertions/active_job" if defined? ActiveJob
5
+ require "minitest/rails/assertions/action_cable" if defined? ActionCable
5
6
  require "minitest/rails/assertions/action_mailer" if defined? ActionMailer
@@ -1,3 +1,4 @@
1
+ require "minitest/rails"
1
2
  require "capybara/minitest"
2
3
  require "capybara/minitest/spec"
3
4
 
@@ -0,0 +1,197 @@
1
+ require "active_support/concern"
2
+
3
+ module Minitest
4
+ module Rails
5
+ module Expectations
6
+ module ActionCable
7
+ module TestHelper
8
+ ##
9
+ # Asserts that the number of broadcasted messages to the stream matches the given number.
10
+ #
11
+ # def test_broadcasts
12
+ # must_have_broadcasts 'messages', 0
13
+ # ActionCable.server.broadcast 'messages', { text: 'hello' }
14
+ # must_have_broadcasts 'messages', 1
15
+ # ActionCable.server.broadcast 'messages', { text: 'world' }
16
+ # must_have_broadcasts 'messages', 2
17
+ # end
18
+ #
19
+ # If a block is passed, that block should cause the specified number of
20
+ # messages to be broadcasted.
21
+ #
22
+ # def test_broadcasts_again
23
+ # must_have_broadcasts('messages', 1) do
24
+ # ActionCable.server.broadcast 'messages', { text: 'hello' }
25
+ # end
26
+ #
27
+ # must_have_broadcasts('messages', 2) do
28
+ # ActionCable.server.broadcast 'messages', { text: 'hi' }
29
+ # ActionCable.server.broadcast 'messages', { text: 'how are you?' }
30
+ # end
31
+ # end
32
+ #
33
+ # See also ActionCable::TestHelper#assert_broadcasts
34
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/TestHelper.html#method-i-assert_broadcasts
35
+ #
36
+ # :method: must_have_broadcasts
37
+ # :call-seq: must_have_broadcasts(stream, number)
38
+
39
+ ##
40
+ # Asserts that no messages have been sent to the stream.
41
+ #
42
+ # def test_no_broadcasts
43
+ # wont_have_broadcasts 'messages'
44
+ # ActionCable.server.broadcast 'messages', { text: 'hi' }
45
+ # must_have_broadcasts 'messages', 1
46
+ # end
47
+ #
48
+ # If a block is passed, that block should not cause any message to be sent.
49
+ #
50
+ # def test_broadcasts_again
51
+ # wont_have_broadcasts 'messages' do
52
+ # # No job messages should be sent from this block
53
+ # end
54
+ # end
55
+ #
56
+ # Note: This assertion is simply a shortcut for:
57
+ #
58
+ # must_have_broadcasts 'messages', 0, &block
59
+ #
60
+ # See also ActionCable::TestHelper#wont_have_broadcasts
61
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/TestHelper.html#method-i-assert_no_broadcasts
62
+ #
63
+ # :method: wont_have_broadcasts
64
+ # :call-seq: wont_have_broadcasts(stream, &block)
65
+
66
+ ##
67
+ # Asserts that the specified message has been sent to the stream.
68
+ #
69
+ # def test_assert_transmitted_message
70
+ # ActionCable.server.broadcast 'messages', text: 'hello'
71
+ # must_broadcast_on('messages', text: 'hello')
72
+ # end
73
+ #
74
+ # If a block is passed, that block should cause a message with the specified data to be sent.
75
+ #
76
+ # def test_assert_broadcast_on_again
77
+ # must_broadcast_on('messages', text: 'hello') do
78
+ # ActionCable.server.broadcast 'messages', text: 'hello'
79
+ # end
80
+ # end
81
+ #
82
+ # See also ActionCable::TestHelper#assert_broadcast_on
83
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/TestHelper.html#method-i-assert_broadcast_on
84
+ #
85
+ # :method: must_broadcast_on
86
+ # :call-seq: must_broadcast_on(stream, data)
87
+
88
+ extend ::ActiveSupport::Concern
89
+
90
+ included do
91
+ alias_method :must_have_broadcasts, :assert_broadcasts
92
+ alias_method :wont_have_broadcasts, :assert_no_broadcasts
93
+ alias_method :must_broadcast_on, :assert_broadcast_on
94
+ end
95
+ end
96
+
97
+ module Channel
98
+ ##
99
+ # Asserts that no streams have been started.
100
+ #
101
+ # def test_assert_no_started_stream
102
+ # subscribe
103
+ # wont_have_streams
104
+ # end
105
+ #
106
+ # See also ActionCable::Channel::TestCase#assert_no_streams
107
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/Channel/TestCase/Behavior.html#method-i-assert_no_streams
108
+ #
109
+ # :method: wont_have_streams
110
+
111
+ ##
112
+ # Asserts that the specified stream has been started.
113
+ #
114
+ # def test_assert_started_stream
115
+ # subscribe
116
+ # must_have_streams 'messages'
117
+ # end
118
+ #
119
+ # See also ActionCable::Channel::TestCase#assert_has_stream
120
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/Channel/TestCase/Behavior.html#method-i-assert_has_stream
121
+ #
122
+ # :method: must_have_streams
123
+ # :call-seq: must_have_streams(stream)
124
+
125
+ ##
126
+ # Asserts that the specified stream for a model has started.
127
+ #
128
+ # def test_assert_started_stream_for
129
+ # subscribe id: 42
130
+ # must_have_stream_for User.find(42)
131
+ # end
132
+ #
133
+ # See also ActionCable::Channel::TestCase#assert_has_stream_for
134
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/Channel/TestCase/Behavior.html#method-i-assert_has_stream_for
135
+ #
136
+ # :method: must_have_stream_for
137
+ # :call-seq: must_have_stream_for(object)
138
+
139
+ extend ::ActiveSupport::Concern
140
+
141
+ included do
142
+ alias_method :wont_have_streams, :assert_no_streams
143
+ alias_method :must_have_streams, :assert_has_stream
144
+ alias_method :must_have_stream_for, :assert_has_stream_for
145
+ end
146
+ end
147
+
148
+ module Connection
149
+ ##
150
+ # Asserts that the connection is rejected (via +reject_unauthorized_connection+).
151
+ #
152
+ # describe "Application Connections", :connection do
153
+ # it "connects with proper cookie" do
154
+ # # Simulate the connection request with a cookie.
155
+ # cookies["user_id"] = users(:john).id
156
+ #
157
+ # connect
158
+ #
159
+ # # Assert the connection identifier matches the fixture.
160
+ # value(connection.user.id).must_equal users(:john).id
161
+ # end
162
+ #
163
+ # it "rejects connection without proper cookie" do
164
+ # must_reject_connection { connect }
165
+ # end
166
+ # end
167
+ #
168
+ # See also ActionCable::Connection::TestCase#assert_reject_connection
169
+ # See https://api.rubyonrails.org/v7.1/classes/ActionCable/Connection/Assertions.html#method-i-assert_reject_connection
170
+ #
171
+ # :method: must_reject_connection
172
+
173
+ extend ::ActiveSupport::Concern
174
+
175
+ included do
176
+ alias_method :must_reject_connection, :assert_reject_connection
177
+ end
178
+ end
179
+ end
180
+ end
181
+ end
182
+ end
183
+
184
+ unless ENV["MT_NO_EXPECTATIONS"]
185
+ class ActionCable::TestCase # :nodoc:
186
+ include Minitest::Rails::Expectations::ActionCable::TestHelper
187
+ end
188
+
189
+ class ActionCable::Channel::TestCase # :nodoc:
190
+ include Minitest::Rails::Expectations::ActionCable::TestHelper
191
+ include Minitest::Rails::Expectations::ActionCable::Channel
192
+ end
193
+
194
+ class ActionCable::Connection::TestCase # :nodoc:
195
+ include Minitest::Rails::Expectations::ActionCable::Connection
196
+ end
197
+ end
@@ -30,7 +30,7 @@ module Minitest
30
30
  # end
31
31
  #
32
32
  # See also ActionMailer::TestClass#assert_emails
33
- # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_emails
33
+ # See https://api.rubyonrails.org/v7.1/classes/ActionMailer/TestHelper.html#method-i-assert_emails
34
34
  #
35
35
  # :method: must_have_emails
36
36
  # :call-seq: must_have_emails(number, &block)
@@ -56,7 +56,7 @@ module Minitest
56
56
  # must_have_emails 0, &block
57
57
  #
58
58
  # See also ActionMailer::TestClass#wont_have_emails
59
- # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_no_emails
59
+ # See https://api.rubyonrails.org/v7.1/classes/ActionMailer/TestHelper.html#method-i-assert_no_emails
60
60
  #
61
61
  # :method: wont_have_emails
62
62
  # :call-seq: wont_have_emails(&block)
@@ -88,11 +88,49 @@ module Minitest
88
88
  # end
89
89
  #
90
90
  # See also ActionMailer::TestClass#assert_enqueued_emails
91
- # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_enqueued_emails
91
+ # See https://api.rubyonrails.org/v7.1/classes/ActionMailer/TestHelper.html#method-i-assert_enqueued_emails
92
92
  #
93
93
  # :method: must_have_enqueued_emails
94
94
  # :call-seq: must_have_enqueued_emails(number, &block)
95
95
 
96
+ ##
97
+ # Asserts that a specific email has been enqueued, optionally
98
+ # matching arguments.
99
+ #
100
+ # def test_email
101
+ # ContactMailer.welcome.deliver_later
102
+ # must_enqueue_email_with ContactMailer, :welcome
103
+ # end
104
+ #
105
+ # def test_email_with_arguments
106
+ # ContactMailer.welcome("Hello", "Goodbye").deliver_later
107
+ # must_enqueue_email_with ContactMailer, :welcome, args: ["Hello", "Goodbye"]
108
+ # end
109
+ #
110
+ # If a block is passed, that block should cause the specified email
111
+ # to be enqueued.
112
+ #
113
+ # def test_email_in_block
114
+ # must_enqueue_email_with ContactMailer, :welcome do
115
+ # ContactMailer.welcome.deliver_later
116
+ # end
117
+ # end
118
+ #
119
+ # If +args+ is provided as a Hash, a parameterized email is matched.
120
+ #
121
+ # def test_parameterized_email
122
+ # must_enqueue_email_with ContactMailer, :welcome,
123
+ # args: {email: 'user@example.com'} do
124
+ # ContactMailer.with(email: 'user@example.com').welcome.deliver_later
125
+ # end
126
+ # end
127
+ #
128
+ # See also ActionMailer::TestClass#assert_enqueued_email_with
129
+ # See https://api.rubyonrails.org/v7.1/classes/ActionMailer/TestHelper.html#method-i-assert_enqueued_email_with
130
+ #
131
+ # :method: must_enqueue_email_with
132
+ # :call-seq: must_enqueue_email_with(mailer, method, args: nil, queue: "mailers", &block)
133
+
96
134
  ##
97
135
  # Asserts that no emails are enqueued for later delivery.
98
136
  #
@@ -111,7 +149,7 @@ module Minitest
111
149
  # end
112
150
  #
113
151
  # See also ActionMailer::TestClass#assert_no_enqueued_emails
114
- # See https://api.rubyonrails.org/v5.1/classes/ActionMailer/TestHelper.html#method-i-assert_no_enqueued_emails
152
+ # See https://api.rubyonrails.org/v7.1/classes/ActionMailer/TestHelper.html#method-i-assert_no_enqueued_emails
115
153
  #
116
154
  # :method: wont_have_enqueued_emails
117
155
  # :call-seq: wont_have_enqueued_emails(&block)
@@ -122,6 +160,7 @@ module Minitest
122
160
  alias_method :must_have_emails, :assert_emails
123
161
  alias_method :wont_have_emails, :assert_no_emails
124
162
  alias_method :must_have_enqueued_emails, :assert_enqueued_emails
163
+ alias_method :must_enqueue_email_with, :assert_enqueued_email_with
125
164
  alias_method :wont_have_enqueued_emails, :assert_no_enqueued_emails
126
165
  end
127
166
  end
@@ -176,6 +176,10 @@ module Minitest
176
176
  end
177
177
 
178
178
  unless ENV["MT_NO_EXPECTATIONS"]
179
+ class ActionDispatch::IntegrationTest # :nodoc:
180
+ include Minitest::Rails::Expectations::ActiveJob
181
+ end
182
+
179
183
  class ActiveJob::TestCase # :nodoc:
180
184
  include Minitest::Rails::Expectations::ActiveJob
181
185
  end