rspec-rails 3.6.0.beta1 → 3.6.0.beta2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ebf54e513b2bfad6ffe14c36afa43056012db04
4
- data.tar.gz: 9418672e115bde33c829fa68f68d2c44af25be19
3
+ metadata.gz: 92a487b773b69d4298893756136ed2ec3bbc1082
4
+ data.tar.gz: 175a3d8803f8c795b0b01e5f47f486d4822a9abb
5
5
  SHA512:
6
- metadata.gz: 8716e97798de2b89ae70a4602bc635957af4bb4e0350ee9e8a1396c23eb978093ed6076c4786793cee571c5874a3fd84659edf98f69f521fd2461c18dc45b89e
7
- data.tar.gz: 24f17af3d57c74e592fece81e6af00b0588dee7f9a5d5e279e95bde85d4ddbe341512ea997fe110166bb027da087b1e0de46c088628d4cdc2a3cfffa68c0a0d0
6
+ metadata.gz: caa44ae7581f7d2ed130b86ec3159c4e2d08c131373a2c293799bf160661e9cffc4efb59623265730eb4402ce27b1e9076c1a6dad844469e6475640ca3c934fb
7
+ data.tar.gz: f27164ec0efea4782a452ef0aab36b50147d22946a348b9b36aa36eb0ac24c9b2ae2e63b398b89af9eeee09337dc4d4ca109fe320a3d87ae963bef35f3ed3bdc
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,4 +1,4 @@
1
- rspec-rails supports integration with Capbyara out of the box by adding
1
+ rspec-rails supports integration with Capybara out of the box by adding
2
2
  its Capybara::DSL (visit/page) and Capybara::RSpecMatchers to the
3
3
  examples in the applicable directories, which differ slightly between
4
4
  Capybara 1.x and Capybara >= 2.x.
@@ -1,3 +1,11 @@
1
+ ### 3.6.0.beta2 / 2016-12-12
2
+ [Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.6.0.beta1...v3.6.0.beta2)
3
+
4
+ Enhancements:
5
+
6
+ * Improve failure output of ActiveJob matchers by listing queued jobs.
7
+ (Wojciech Wnętrzak, #1722)
8
+
1
9
  ### 3.6.0.beta1 / 2016-10-09
2
10
  [Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.5.2...v3.6.0.beta1)
3
11
 
data/README.md CHANGED
@@ -62,6 +62,9 @@ bundle exec rspec spec/models
62
62
 
63
63
  # Run only specs for AccountsController
64
64
  bundle exec rspec spec/controllers/accounts_controller_spec.rb
65
+
66
+ # Run only spec on line 8 of AccountsController
67
+ bundle exec rspec spec/controllers/accounts_controller_spec.rb:8
65
68
  ```
66
69
 
67
70
  Specs can also be run via `rake spec`, though this command may be slower to
@@ -87,6 +90,12 @@ There are three particular `rspec-rails` specific changes to be aware of:
87
90
  4. Extraction of `stub_model` and `mock_model` to
88
91
  [`rspec-activemodel-mocks`](https://github.com/rspec/rspec-activemodel-mocks)
89
92
  5. In Rails 5.x, controller testing has been moved to its own gem which is [rails-controller-testing](https://github.com/rails/rails-controller-testing). Using `assigns` in your controller specs without adding this gem will no longer work.
93
+ 6. `rspec-rails` now includes two helpers, `spec_helper.rb` and `rails_helper.rb`.
94
+ `spec_helper.rb` is the conventional RSpec configuration helper, whilst the
95
+ Rails specific loading and bootstrapping has moved to the `rails_helper.rb`
96
+ file. Rails specs now need this file required beforehand either at the top
97
+ of the specific file (recommended) or a common configuration location such
98
+ as your `.rspec` file.
90
99
 
91
100
  Please see the [RSpec Rails Upgrade
92
101
  docs](https://www.relishapp.com/rspec/rspec-rails/docs/upgrade) for full
@@ -318,6 +327,28 @@ end
318
327
  For more information, see the [cucumber scenarios for mailer specs
319
328
  ](https://relishapp.com/rspec/rspec-rails/v/3-4/docs/mailer-specs).
320
329
 
330
+ ## Job specs
331
+
332
+ Tagging a context with the metadata `:type => :job` treats its examples as job
333
+ specs. Typically these specs will live in `spec/jobs`.
334
+
335
+ ```ruby
336
+ require 'rails_helper'
337
+
338
+ RSpec.describe UploadBackupsJob, :type => :job do
339
+ describe "#perform_later" do
340
+ it "uploads a backup" do
341
+ ActiveJob::Base.queue_adapter = :test
342
+ UploadBackupsJob.perform_later('backup')
343
+ expect(UploadBackupsJob).to have_been_enqueued
344
+ end
345
+ end
346
+ end
347
+ ```
348
+
349
+ For more information, see the [cucumber scenarios for job specs
350
+ ](https://relishapp.com/rspec/rspec-rails/docs/job-specs).
351
+
321
352
  ## View specs
322
353
 
323
354
  View specs default to residing in the `spec/views` folder. Tagging any context
@@ -1,10 +1,10 @@
1
1
  require "rails_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
- RSpec.describe <%= class_name %><%= Rails.version.to_f >= 5.0 ? "Mailer" : "" %>, <%= type_metatag(:mailer) %> do
4
+ RSpec.describe <%= Rails.version.to_f >= 5.0 ? class_name.sub(/(Mailer)?$/, 'Mailer') : class_name %>, <%= type_metatag(:mailer) %> do
5
5
  <% for action in actions -%>
6
6
  describe "<%= action %>" do
7
- let(:mail) { <%= class_name %><%= Rails.version.to_f >= 5.0 ? "Mailer" : "" %>.<%= action %> }
7
+ let(:mail) { <%= Rails.version.to_f >= 5.0 ? class_name.sub(/(Mailer)?$/, 'Mailer') : class_name %>.<%= action %> }
8
8
 
9
9
  it "renders the headers" do
10
10
  expect(mail.subject).to eq(<%= action.to_s.humanize.inspect %>)
@@ -67,7 +67,14 @@ module RSpec
67
67
  end
68
68
 
69
69
  def failure_message
70
- "expected to enqueue #{base_message}"
70
+ "expected to enqueue #{base_message}".tap do |msg|
71
+ if @unmatching_jobs.any?
72
+ msg << "\nQueued jobs:"
73
+ @unmatching_jobs.each do |job|
74
+ msg << "\n #{base_job_message(job)}"
75
+ end
76
+ end
77
+ end
71
78
  end
72
79
 
73
80
  def failure_message_when_negated
@@ -89,8 +96,8 @@ module RSpec
89
96
  private
90
97
 
91
98
  def check(jobs)
92
- @matching_jobs_count = jobs.count do |job|
93
- if serialized_attributes.all? { |key, value| value == job[key] }
99
+ @matching_jobs, @unmatching_jobs = jobs.partition do |job|
100
+ if arguments_match?(job) && other_attributes_match?(job)
94
101
  args = ::ActiveJob::Arguments.deserialize(job[:args])
95
102
  @block.call(*args)
96
103
  true
@@ -98,6 +105,7 @@ module RSpec
98
105
  false
99
106
  end
100
107
  end
108
+ @matching_jobs_count = @matching_jobs.size
101
109
 
102
110
  case @expectation_type
103
111
  when :exactly then @expected_number == @matching_jobs_count
@@ -115,9 +123,32 @@ module RSpec
115
123
  end
116
124
  end
117
125
 
126
+ def base_job_message(job)
127
+ msg_parts = []
128
+ msg_parts << "with #{::ActiveJob::Arguments.deserialize(job[:args])}" if job[:args].any?
129
+ msg_parts << "on queue #{job[:queue]}" if job[:queue]
130
+ msg_parts << "at #{Time.at(job[:at])}" if job[:at]
131
+
132
+ "#{job[:job].class.name} job".tap do |msg|
133
+ msg << " #{msg_parts.join(', ')}" if msg_parts.any?
134
+ end
135
+ end
136
+
137
+ def arguments_match?(job)
138
+ if @args.any?
139
+ deserialized_args = ::ActiveJob::Arguments.deserialize(job[:args])
140
+ RSpec::Mocks::ArgumentListMatcher.new(*@args).args_match?(*deserialized_args)
141
+ else
142
+ true
143
+ end
144
+ end
145
+
146
+ def other_attributes_match?(job)
147
+ serialized_attributes.all? { |key, value| value == job[key] }
148
+ end
149
+
118
150
  def serialized_attributes
119
151
  {}.tap do |attributes|
120
- attributes[:args] = ::ActiveJob::Arguments.serialize(@args) if @args.any?
121
152
  attributes[:at] = @at.to_f if @at
122
153
  attributes[:queue] = @queue if @queue
123
154
  attributes[:job] = @job if @job
@@ -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 = '3.6.0.beta1'
6
+ STRING = '3.6.0.beta2'
7
7
  end
8
8
  end
9
9
  end
@@ -61,6 +61,20 @@ module RSpec
61
61
  end
62
62
  end
63
63
 
64
+ # @private
65
+ class LogSubscriber < ::ActiveSupport::LogSubscriber
66
+ def current_example_group
67
+ RSpec.current_example.example_group
68
+ end
69
+
70
+ def render_template(_event)
71
+ return if current_example_group.render_views?
72
+ info(" Template rendering was prevented by rspec-rails. Use `render_views` to verify rendered view contents if necessary.")
73
+ end
74
+ end
75
+
76
+ LogSubscriber.attach_to(:action_view)
77
+
64
78
  # Delegates all methods to the submitted resolver and for all methods
65
79
  # that return a collection of `ActionView::Template` instances, return
66
80
  # templates with modified source
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: 3.6.0.beta1
4
+ version: 3.6.0.beta2
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: 2016-10-10 00:00:00.000000000 Z
47
+ date: 2016-12-12 00:00:00.000000000 Z
48
48
  dependencies:
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: activesupport
@@ -94,56 +94,56 @@ dependencies:
94
94
  requirements:
95
95
  - - '='
96
96
  - !ruby/object:Gem::Version
97
- version: 3.6.0.beta1
97
+ version: 3.6.0.beta2
98
98
  type: :runtime
99
99
  prerelease: false
100
100
  version_requirements: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - '='
103
103
  - !ruby/object:Gem::Version
104
- version: 3.6.0.beta1
104
+ version: 3.6.0.beta2
105
105
  - !ruby/object:Gem::Dependency
106
106
  name: rspec-expectations
107
107
  requirement: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - '='
110
110
  - !ruby/object:Gem::Version
111
- version: 3.6.0.beta1
111
+ version: 3.6.0.beta2
112
112
  type: :runtime
113
113
  prerelease: false
114
114
  version_requirements: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - '='
117
117
  - !ruby/object:Gem::Version
118
- version: 3.6.0.beta1
118
+ version: 3.6.0.beta2
119
119
  - !ruby/object:Gem::Dependency
120
120
  name: rspec-mocks
121
121
  requirement: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - '='
124
124
  - !ruby/object:Gem::Version
125
- version: 3.6.0.beta1
125
+ version: 3.6.0.beta2
126
126
  type: :runtime
127
127
  prerelease: false
128
128
  version_requirements: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - '='
131
131
  - !ruby/object:Gem::Version
132
- version: 3.6.0.beta1
132
+ version: 3.6.0.beta2
133
133
  - !ruby/object:Gem::Dependency
134
134
  name: rspec-support
135
135
  requirement: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - '='
138
138
  - !ruby/object:Gem::Version
139
- version: 3.6.0.beta1
139
+ version: 3.6.0.beta2
140
140
  type: :runtime
141
141
  prerelease: false
142
142
  version_requirements: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - '='
145
145
  - !ruby/object:Gem::Version
146
- version: 3.6.0.beta1
146
+ version: 3.6.0.beta2
147
147
  - !ruby/object:Gem::Dependency
148
148
  name: cucumber
149
149
  requirement: !ruby/object:Gem::Requirement
@@ -292,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
292
292
  version: 1.3.1
293
293
  requirements: []
294
294
  rubyforge_project:
295
- rubygems_version: 2.2.2
295
+ rubygems_version: 2.5.1
296
296
  signing_key:
297
297
  specification_version: 4
298
298
  summary: RSpec for Rails
metadata.gz.sig CHANGED
Binary file