rspec-rails 4.0.0.beta2 → 4.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/Changelog.md +105 -83
  5. data/README.md +1 -1
  6. data/lib/generators/rspec/channel/channel_generator.rb +12 -0
  7. data/lib/generators/rspec/channel/templates/channel_spec.rb.erb +7 -0
  8. data/lib/generators/rspec/controller/controller_generator.rb +11 -2
  9. data/lib/generators/rspec/controller/templates/routing_spec.rb +13 -0
  10. data/lib/generators/rspec/mailbox/mailbox_generator.rb +14 -0
  11. data/lib/generators/rspec/mailbox/templates/mailbox_spec.rb.erb +7 -0
  12. data/lib/generators/rspec/model/templates/fixtures.yml +1 -1
  13. data/lib/rspec/rails/configuration.rb +15 -5
  14. data/lib/rspec/rails/example.rb +2 -0
  15. data/lib/rspec/rails/example/channel_example_group.rb +93 -0
  16. data/lib/rspec/rails/example/feature_example_group.rb +1 -1
  17. data/lib/rspec/rails/example/mailbox_example_group.rb +80 -0
  18. data/lib/rspec/rails/example/mailer_example_group.rb +1 -1
  19. data/lib/rspec/rails/example/system_example_group.rb +14 -2
  20. data/lib/rspec/rails/example/view_example_group.rb +29 -8
  21. data/lib/rspec/rails/feature_check.rb +16 -0
  22. data/lib/rspec/rails/matchers.rb +10 -0
  23. data/lib/rspec/rails/matchers/action_cable.rb +65 -0
  24. data/lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb +170 -0
  25. data/lib/rspec/rails/matchers/action_cable/have_streams.rb +58 -0
  26. data/lib/rspec/rails/matchers/action_mailbox.rb +64 -0
  27. data/lib/rspec/rails/matchers/active_job.rb +16 -5
  28. data/lib/rspec/rails/matchers/have_enqueued_mail.rb +44 -22
  29. data/lib/rspec/rails/matchers/routing_matchers.rb +1 -1
  30. data/lib/rspec/rails/version.rb +1 -1
  31. metadata +15 -4
  32. metadata.gz.sig +0 -0
@@ -14,20 +14,19 @@ module RSpec
14
14
  include RSpec::Mocks::ExampleMethods
15
15
 
16
16
  def initialize(mailer_class, method_name)
17
- super(mailer_job)
17
+ super(nil)
18
18
  @mailer_class = mailer_class
19
19
  @method_name = method_name
20
20
  @mail_args = []
21
- @args = mailer_args
22
21
  end
23
22
 
24
23
  def description
25
- "enqueues #{@mailer_class.name}.#{@method_name}"
24
+ "enqueues #{mailer_class_name}.#{@method_name}"
26
25
  end
27
26
 
28
27
  def with(*args, &block)
29
28
  @mail_args = args
30
- block.nil? ? super(*mailer_args) : super(*mailer_args, &yield_mail_args(block))
29
+ block.nil? ? super : super(&yield_mail_args(block))
31
30
  end
32
31
 
33
32
  def matches?(block)
@@ -50,7 +49,7 @@ module RSpec
50
49
  private
51
50
 
52
51
  def base_message
53
- "#{@mailer_class.name}.#{@method_name}".tap do |msg|
52
+ [mailer_class_name, @method_name].compact.join('.').tap do |msg|
54
53
  msg << " #{expected_count_message}"
55
54
  msg << " with #{@mail_args}," if @mail_args.any?
56
55
  msg << " on queue #{@queue}," if @queue
@@ -63,24 +62,31 @@ module RSpec
63
62
  "#{message_expectation_modifier} #{@expected_number} #{@expected_number == 1 ? 'time' : 'times'}"
64
63
  end
65
64
 
66
- def mailer_args
67
- if @mail_args.any?
68
- base_mailer_args + @mail_args
69
- else
70
- mailer_method_arity = @mailer_class.instance_method(@method_name).arity
65
+ def mailer_class_name
66
+ @mailer_class ? @mailer_class.name : 'ActionMailer::Base'
67
+ end
68
+
69
+ def job_match?(job)
70
+ legacy_mail?(job) || parameterized_mail?(job) || unified_mail?(job)
71
+ end
71
72
 
72
- number_of_args = if mailer_method_arity < 0
73
- (mailer_method_arity + 1).abs
74
- else
75
- mailer_method_arity
76
- end
73
+ def arguments_match?(job)
74
+ @args =
75
+ if @mail_args.any?
76
+ base_mailer_args + @mail_args
77
+ elsif @mailer_class && @method_name
78
+ base_mailer_args + [any_args]
79
+ elsif @mailer_class
80
+ [mailer_class_name, any_args]
81
+ else
82
+ []
83
+ end
77
84
 
78
- base_mailer_args + Array.new(number_of_args) { anything }
79
- end
85
+ super(job)
80
86
  end
81
87
 
82
88
  def base_mailer_args
83
- [@mailer_class.name, @method_name.to_s, MAILER_JOB_METHOD]
89
+ [mailer_class_name, @method_name.to_s, MAILER_JOB_METHOD]
84
90
  end
85
91
 
86
92
  def yield_mail_args(block)
@@ -95,7 +101,7 @@ module RSpec
95
101
 
96
102
  def unmatching_mail_jobs
97
103
  @unmatching_jobs.select do |job|
98
- job[:job] == mailer_job
104
+ job_match?(job)
99
105
  end
100
106
  end
101
107
 
@@ -121,8 +127,16 @@ module RSpec
121
127
  "#{mailer_method} #{msg_parts.join(', ')}".strip
122
128
  end
123
129
 
124
- def mailer_job
125
- ActionMailer::DeliveryJob
130
+ def legacy_mail?(job)
131
+ job[:job] == ActionMailer::DeliveryJob
132
+ end
133
+
134
+ def parameterized_mail?(job)
135
+ RSpec::Rails::FeatureCheck.has_action_mailer_parameterized? && job[:job] == ActionMailer::Parameterized::DeliveryJob
136
+ end
137
+
138
+ def unified_mail?(job)
139
+ RSpec::Rails::FeatureCheck.has_action_mailer_unified_delivery? && job[:job] == ActionMailer::MailDeliveryJob
126
140
  end
127
141
  end
128
142
  # @api public
@@ -135,6 +149,14 @@ module RSpec
135
149
  # @example
136
150
  # expect {
137
151
  # MyMailer.welcome(user).deliver_later
152
+ # }.to have_enqueued_mail
153
+ #
154
+ # expect {
155
+ # MyMailer.welcome(user).deliver_later
156
+ # }.to have_enqueued_mail(MyMailer)
157
+ #
158
+ # expect {
159
+ # MyMailer.welcome(user).deliver_later
138
160
  # }.to have_enqueued_mail(MyMailer, :welcome)
139
161
  #
140
162
  # # Using alias
@@ -162,7 +184,7 @@ module RSpec
162
184
  # expect {
163
185
  # MyMailer.welcome(user).deliver_later(queue: :urgent_mail)
164
186
  # }.to have_enqueued_mail(MyMailer, :welcome).on_queue(:urgent_mail)
165
- def have_enqueued_mail(mailer_class, mail_method_name)
187
+ def have_enqueued_mail(mailer_class = nil, mail_method_name = nil)
166
188
  HaveEnqueuedMail.new(mailer_class, mail_method_name)
167
189
  end
168
190
  alias_method :have_enqueued_email, :have_enqueued_mail
@@ -57,7 +57,7 @@ module RSpec
57
57
  #
58
58
  # expect(:get => "/things/special").to route_to("things#special")
59
59
  #
60
- # @see http://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html#method-i-assert_recognizes
60
+ # @see https://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html#method-i-assert_recognizes
61
61
  def route_to(*expected)
62
62
  RouteToMatcher.new(self, *expected)
63
63
  end
@@ -3,7 +3,7 @@ module RSpec
3
3
  # Version information for RSpec Rails.
4
4
  module Version
5
5
  # Current version of RSpec Rails, in semantic versioning format.
6
- STRING = '4.0.0.beta2'
6
+ STRING = '4.0.0.beta3'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.beta2
4
+ version: 4.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chelimsky
@@ -44,7 +44,7 @@ cert_chain:
44
44
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
45
45
  F3MdtaDehhjC
46
46
  -----END CERTIFICATE-----
47
- date: 2019-04-26 00:00:00.000000000 Z
47
+ date: 2019-10-18 00:00:00.000000000 Z
48
48
  dependencies:
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: activesupport
@@ -199,8 +199,11 @@ files:
199
199
  - LICENSE.md
200
200
  - README.md
201
201
  - lib/generators/rspec.rb
202
+ - lib/generators/rspec/channel/channel_generator.rb
203
+ - lib/generators/rspec/channel/templates/channel_spec.rb.erb
202
204
  - lib/generators/rspec/controller/controller_generator.rb
203
205
  - lib/generators/rspec/controller/templates/controller_spec.rb
206
+ - lib/generators/rspec/controller/templates/routing_spec.rb
204
207
  - lib/generators/rspec/controller/templates/view_spec.rb
205
208
  - lib/generators/rspec/feature/feature_generator.rb
206
209
  - lib/generators/rspec/feature/templates/feature_singular_spec.rb
@@ -215,6 +218,8 @@ files:
215
218
  - lib/generators/rspec/integration/templates/request_spec.rb
216
219
  - lib/generators/rspec/job/job_generator.rb
217
220
  - lib/generators/rspec/job/templates/job_spec.rb.erb
221
+ - lib/generators/rspec/mailbox/mailbox_generator.rb
222
+ - lib/generators/rspec/mailbox/templates/mailbox_spec.rb.erb
218
223
  - lib/generators/rspec/mailer/mailer_generator.rb
219
224
  - lib/generators/rspec/mailer/templates/fixture
220
225
  - lib/generators/rspec/mailer/templates/mailer_spec.rb
@@ -243,10 +248,12 @@ files:
243
248
  - lib/rspec/rails/adapters.rb
244
249
  - lib/rspec/rails/configuration.rb
245
250
  - lib/rspec/rails/example.rb
251
+ - lib/rspec/rails/example/channel_example_group.rb
246
252
  - lib/rspec/rails/example/controller_example_group.rb
247
253
  - lib/rspec/rails/example/feature_example_group.rb
248
254
  - lib/rspec/rails/example/helper_example_group.rb
249
255
  - lib/rspec/rails/example/job_example_group.rb
256
+ - lib/rspec/rails/example/mailbox_example_group.rb
250
257
  - lib/rspec/rails/example/mailer_example_group.rb
251
258
  - lib/rspec/rails/example/model_example_group.rb
252
259
  - lib/rspec/rails/example/rails_example_group.rb
@@ -261,6 +268,10 @@ files:
261
268
  - lib/rspec/rails/fixture_file_upload_support.rb
262
269
  - lib/rspec/rails/fixture_support.rb
263
270
  - lib/rspec/rails/matchers.rb
271
+ - lib/rspec/rails/matchers/action_cable.rb
272
+ - lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb
273
+ - lib/rspec/rails/matchers/action_cable/have_streams.rb
274
+ - lib/rspec/rails/matchers/action_mailbox.rb
264
275
  - lib/rspec/rails/matchers/active_job.rb
265
276
  - lib/rspec/rails/matchers/base_matcher.rb
266
277
  - lib/rspec/rails/matchers/be_a_new.rb
@@ -284,7 +295,7 @@ licenses:
284
295
  - MIT
285
296
  metadata:
286
297
  bug_tracker_uri: https://github.com/rspec/rspec-rails/issues
287
- changelog_uri: https://github.com/rspec/rspec-rails/blob/v4.0.0.beta2/Changelog.md
298
+ changelog_uri: https://github.com/rspec/rspec-rails/blob/v4.0.0.beta3/Changelog.md
288
299
  documentation_uri: https://rspec.info/documentation/
289
300
  mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
290
301
  source_code_uri: https://github.com/rspec/rspec-rails
@@ -304,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
304
315
  - !ruby/object:Gem::Version
305
316
  version: 1.3.1
306
317
  requirements: []
307
- rubygems_version: 3.0.3
318
+ rubygems_version: 3.0.6
308
319
  signing_key:
309
320
  specification_version: 4
310
321
  summary: RSpec for Rails
metadata.gz.sig CHANGED
Binary file