rspec-rails 3.6.1 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Changelog.md +12 -2
- data/README.md +21 -50
- data/lib/generators/rspec/install/templates/spec/rails_helper.rb +1 -1
- data/lib/rspec/rails/active_record.rb +1 -1
- data/lib/rspec/rails/configuration.rb +6 -1
- data/lib/rspec/rails/example.rb +3 -0
- data/lib/rspec/rails/example/system_example_group.rb +88 -0
- data/lib/rspec/rails/matchers/be_a_new.rb +5 -4
- data/lib/rspec/rails/vendor/capybara.rb +4 -0
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec/rails/view_path_builder.rb +1 -1
- metadata +12 -11
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af8e2712271eef87e27c945e5d3752b46c0c6c44
|
4
|
+
data.tar.gz: f7a2803d48fd6e3130f2e3a3acccd083d13e615b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7246455923effd2d777053e85788a72d979528422466821432257dc1d564c8ec2206f51199d2846dd66b7d201723d5c4e6405bc588321f8bd3c09c13f4a7c0e9
|
7
|
+
data.tar.gz: ee14397f82807074ac6c979272083d336ca8e76f1a62d1dee8dfcc41d3856a7a0c9f4e09e7be54eede82dee4da609bc75ae7cb5b813d977040e5f4c6dd870494
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
-
###
|
2
|
-
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.
|
1
|
+
### Development
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.7.0...master)
|
3
|
+
|
4
|
+
### 3.7.0 / 2017-10-17
|
5
|
+
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.6.0...v3.7.0)
|
3
6
|
|
4
7
|
Bug Fixes:
|
5
8
|
|
@@ -7,6 +10,13 @@ Bug Fixes:
|
|
7
10
|
environments. (Samuel Cochran, #1831)
|
8
11
|
* Correctly generate job name in error message. (Wojciech Wnętrzak, #1814)
|
9
12
|
|
13
|
+
Enhancements:
|
14
|
+
|
15
|
+
* Allow `be_a_new(...).with(...)` matcher to accept matchers for
|
16
|
+
attribute values. (Britni Alexander, #1811)
|
17
|
+
* Only configure RSpec Mocks if it is fully loaded. (James Adam, #1856)
|
18
|
+
* Integrate with `ActionDispatch::SystemTestCase`. (Sam Phippen, #1813)
|
19
|
+
|
10
20
|
### 3.6.0 / 2017-05-04
|
11
21
|
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.6.0.beta2...v3.6.0)
|
12
22
|
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Add `rspec-rails` to **both** the `:development` and `:test` groups in the
|
|
11
11
|
|
12
12
|
```ruby
|
13
13
|
group :development, :test do
|
14
|
-
gem 'rspec-rails', '~> 3.
|
14
|
+
gem 'rspec-rails', '~> 3.6'
|
15
15
|
end
|
16
16
|
```
|
17
17
|
|
@@ -160,57 +160,12 @@ end
|
|
160
160
|
For more information, see [cucumber scenarios for model
|
161
161
|
specs](https://www.relishapp.com/rspec/rspec-rails/docs/model-specs).
|
162
162
|
|
163
|
-
## Controller Specs
|
164
|
-
|
165
|
-
Use controller specs to describe behavior of Rails controllers.
|
166
|
-
|
167
|
-
Controller specs default to residing in the `spec/controllers` folder. Tagging
|
168
|
-
any context with the metadata `:type => :controller` treats its examples as
|
169
|
-
controller specs.
|
170
|
-
|
171
|
-
For example:
|
172
|
-
|
173
|
-
```ruby
|
174
|
-
require "rails_helper"
|
175
|
-
|
176
|
-
RSpec.describe PostsController, :type => :controller do
|
177
|
-
describe "GET #index" do
|
178
|
-
it "responds successfully with an HTTP 200 status code" do
|
179
|
-
get :index
|
180
|
-
expect(response).to be_success
|
181
|
-
expect(response).to have_http_status(200)
|
182
|
-
end
|
183
|
-
|
184
|
-
it "renders the index template" do
|
185
|
-
get :index
|
186
|
-
expect(response).to render_template("index")
|
187
|
-
end
|
188
|
-
|
189
|
-
it "loads all of the posts into @posts" do
|
190
|
-
post1, post2 = Post.create!, Post.create!
|
191
|
-
get :index
|
192
|
-
|
193
|
-
expect(assigns(:posts)).to match_array([post1, post2])
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
```
|
198
|
-
|
199
|
-
For more information, see [cucumber scenarios for controller
|
200
|
-
specs](https://www.relishapp.com/rspec/rspec-rails/docs/controller-specs).
|
201
|
-
|
202
|
-
**Note:** To encourage more isolated testing, views are not rendered by default
|
203
|
-
in controller specs. If you are verifying discrete view logic, use a [view
|
204
|
-
spec](#view-specs). If you are verifying the behaviour of a controller and view
|
205
|
-
together, consider a [request spec](#request-specs). You can use
|
206
|
-
[render\_views](https://www.relishapp.com/rspec/rspec-rails/docs/controller-specs/render-views)
|
207
|
-
if you must verify the rendered view contents within a controller spec, but
|
208
|
-
this is not recommended.
|
209
|
-
|
210
163
|
## Request Specs
|
211
164
|
|
212
|
-
Use request specs to
|
213
|
-
|
165
|
+
Use request specs to describe the client-facing behavior of the application —
|
166
|
+
specifically, the HTTP response to be issued for a given request (a.k.a.
|
167
|
+
integration tests). Since such client-facing behavior encompasses controller
|
168
|
+
actions, this is the type of spec to use for controller testing.
|
214
169
|
|
215
170
|
Request specs default to residing in the `spec/requests`, `spec/api`, and
|
216
171
|
`spec/integration` directories. Tagging any context with the metadata `:type =>
|
@@ -277,6 +232,22 @@ FactoryGirl and Capybara seem to be the most widely used. Whether you choose
|
|
277
232
|
these or other libs, we strongly recommend using something for each of these
|
278
233
|
roles.
|
279
234
|
|
235
|
+
For more information, see [cucumber scenarios for request
|
236
|
+
specs](https://relishapp.com/rspec/rspec-rails/docs/request-specs/request-spec).
|
237
|
+
|
238
|
+
## Controller Specs
|
239
|
+
|
240
|
+
Controller specs can be used to describe the behavior of Rails controllers. As
|
241
|
+
of version 3.5, however, controller specs are discouraged in favor of request
|
242
|
+
specs (which also focus largely on controllers, but capture other critical
|
243
|
+
aspects of application behavior as well). Controller specs will continue to be
|
244
|
+
supported until at least version 4.0 (see the [release
|
245
|
+
notes](http://rspec.info/blog/2016/07/rspec-3-5-has-been-released/#rails-support-for-rails-5)
|
246
|
+
for details).
|
247
|
+
|
248
|
+
For more information, see [cucumber scenarios for controller
|
249
|
+
specs](https://www.relishapp.com/rspec/rspec-rails/docs/controller-specs).
|
250
|
+
|
280
251
|
## Feature Specs
|
281
252
|
|
282
253
|
Feature specs test your application from the outside by simulating a browser.
|
@@ -23,7 +23,7 @@ require 'rspec/rails'
|
|
23
23
|
# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
24
24
|
|
25
25
|
<% if RSpec::Rails::FeatureCheck.can_maintain_test_schema? -%>
|
26
|
-
# Checks for pending
|
26
|
+
# Checks for pending migrations and applies them before tests are run.
|
27
27
|
# If you are not using ActiveRecord, you can remove this line.
|
28
28
|
ActiveRecord::Migration.maintain_test_schema!
|
29
29
|
|
@@ -7,7 +7,7 @@ module RSpec
|
|
7
7
|
def self.initialize_activerecord_configuration(config)
|
8
8
|
config.before :suite do
|
9
9
|
# This allows dynamic columns etc to be used on ActiveRecord models when creating instance_doubles
|
10
|
-
if defined?(ActiveRecord) && defined?(ActiveRecord::Base) && defined?(::RSpec::Mocks)
|
10
|
+
if defined?(ActiveRecord) && defined?(ActiveRecord::Base) && defined?(::RSpec::Mocks) && (::RSpec::Mocks.respond_to?(:configuration))
|
11
11
|
::RSpec::Mocks.configuration.when_declaring_verifying_double do |possible_model|
|
12
12
|
target = possible_model.target
|
13
13
|
|
@@ -33,7 +33,8 @@ module RSpec
|
|
33
33
|
:request => %w[spec (requests|integration|api)],
|
34
34
|
:routing => %w[spec routing],
|
35
35
|
:view => %w[spec views],
|
36
|
-
:feature => %w[spec features]
|
36
|
+
:feature => %w[spec features],
|
37
|
+
:system => %w[spec system]
|
37
38
|
}
|
38
39
|
|
39
40
|
# Sets up the different example group modules for the different spec types
|
@@ -48,6 +49,10 @@ module RSpec
|
|
48
49
|
config.include RSpec::Rails::ViewExampleGroup, :type => :view
|
49
50
|
config.include RSpec::Rails::FeatureExampleGroup, :type => :feature
|
50
51
|
config.include RSpec::Rails::Matchers
|
52
|
+
|
53
|
+
if ActionPack::VERSION::STRING >= "5.1"
|
54
|
+
config.include RSpec::Rails::SystemExampleGroup, :type => :system
|
55
|
+
end
|
51
56
|
end
|
52
57
|
|
53
58
|
# @private
|
data/lib/rspec/rails/example.rb
CHANGED
@@ -8,3 +8,6 @@ require 'rspec/rails/example/routing_example_group'
|
|
8
8
|
require 'rspec/rails/example/model_example_group'
|
9
9
|
require 'rspec/rails/example/job_example_group'
|
10
10
|
require 'rspec/rails/example/feature_example_group'
|
11
|
+
if ActionPack::VERSION::STRING >= "5.1"
|
12
|
+
require 'rspec/rails/example/system_example_group'
|
13
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
if ActionPack::VERSION::STRING >= "5.1"
|
2
|
+
require 'action_dispatch/system_test_case'
|
3
|
+
module RSpec
|
4
|
+
module Rails
|
5
|
+
# @api public
|
6
|
+
# Container class for system tests
|
7
|
+
module SystemExampleGroup
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
include RSpec::Rails::RailsExampleGroup
|
10
|
+
include ActionDispatch::Integration::Runner
|
11
|
+
include ActionDispatch::Assertions
|
12
|
+
include RSpec::Rails::Matchers::RedirectTo
|
13
|
+
include RSpec::Rails::Matchers::RenderTemplate
|
14
|
+
include ActionController::TemplateAssertions
|
15
|
+
|
16
|
+
include ActionDispatch::IntegrationTest::Behavior
|
17
|
+
|
18
|
+
# @private
|
19
|
+
module BlowAwayAfterTeardownHook
|
20
|
+
# @private
|
21
|
+
def after_teardown
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
original_after_teardown = ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:after_teardown)
|
26
|
+
|
27
|
+
include ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown
|
28
|
+
include ::ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper
|
29
|
+
include BlowAwayAfterTeardownHook
|
30
|
+
|
31
|
+
# for the SystemTesting Screenshot situation
|
32
|
+
def passed?
|
33
|
+
RSpec.current_example.exception.nil?
|
34
|
+
end
|
35
|
+
|
36
|
+
# @private
|
37
|
+
def method_name
|
38
|
+
@method_name ||= [
|
39
|
+
self.class.name.underscore,
|
40
|
+
RSpec.current_example.description.underscore,
|
41
|
+
rand(1000)
|
42
|
+
].join("_").gsub(/[\/\.:, ]/, "_")
|
43
|
+
end
|
44
|
+
|
45
|
+
# Delegates to `Rails.application`.
|
46
|
+
def app
|
47
|
+
::Rails.application
|
48
|
+
end
|
49
|
+
|
50
|
+
included do
|
51
|
+
attr_reader :driver
|
52
|
+
|
53
|
+
if ActionDispatch::SystemTesting::Server.respond_to?(:silence_puma=)
|
54
|
+
ActionDispatch::SystemTesting::Server.silence_puma = true
|
55
|
+
end
|
56
|
+
|
57
|
+
def initialize(*args, &blk)
|
58
|
+
super(*args, &blk)
|
59
|
+
@driver = nil
|
60
|
+
end
|
61
|
+
|
62
|
+
def driven_by(*args, &blk)
|
63
|
+
@driver = ::ActionDispatch::SystemTestCase.driven_by(*args, &blk).tap(&:use)
|
64
|
+
end
|
65
|
+
|
66
|
+
before do
|
67
|
+
# A user may have already set the driver, so only default if driver
|
68
|
+
# is not set
|
69
|
+
driven_by(:selenium) unless @driver
|
70
|
+
@routes = ::Rails.application.routes
|
71
|
+
end
|
72
|
+
|
73
|
+
after do
|
74
|
+
orig_stdout = $stdout
|
75
|
+
$stdout = StringIO.new
|
76
|
+
begin
|
77
|
+
original_after_teardown.bind(self).call
|
78
|
+
ensure
|
79
|
+
myio = $stdout
|
80
|
+
RSpec.current_example.metadata[:extra_failure_lines] = myio.string
|
81
|
+
$stdout = orig_stdout
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -32,10 +32,11 @@ module RSpec
|
|
32
32
|
message << "expected #{actual.inspect} to be a new #{expected.inspect}"
|
33
33
|
end
|
34
34
|
unless attributes_match?(actual)
|
35
|
+
describe_unmatched_attributes = surface_descriptions_in(unmatched_attributes)
|
35
36
|
if unmatched_attributes.size > 1
|
36
|
-
message << "attributes #{
|
37
|
+
message << "attributes #{describe_unmatched_attributes.inspect} were not set on #{actual.inspect}"
|
37
38
|
else
|
38
|
-
message << "attribute #{
|
39
|
+
message << "attribute #{describe_unmatched_attributes.inspect} was not set on #{actual.inspect}"
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end.join(' and ')
|
@@ -49,13 +50,13 @@ module RSpec
|
|
49
50
|
|
50
51
|
def attributes_match?(actual)
|
51
52
|
attributes.stringify_keys.all? do |key, value|
|
52
|
-
actual.attributes[key]
|
53
|
+
values_match?(value, actual.attributes[key])
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
56
57
|
def unmatched_attributes
|
57
58
|
attributes.stringify_keys.reject do |key, value|
|
58
|
-
actual.attributes[key]
|
59
|
+
values_match?(value, actual.attributes[key])
|
59
60
|
end
|
60
61
|
end
|
61
62
|
end
|
@@ -17,6 +17,9 @@ if defined?(Capybara)
|
|
17
17
|
RSpec.configure do |c|
|
18
18
|
if defined?(Capybara::DSL)
|
19
19
|
c.include Capybara::DSL, :type => :feature
|
20
|
+
if defined?(ActionPack) && ActionPack::VERSION::STRING >= "5.1"
|
21
|
+
c.include Capybara::DSL, :type => :system
|
22
|
+
end
|
20
23
|
end
|
21
24
|
|
22
25
|
if defined?(Capybara::RSpecMatchers)
|
@@ -25,6 +28,7 @@ if defined?(Capybara)
|
|
25
28
|
c.include Capybara::RSpecMatchers, :type => :mailer
|
26
29
|
c.include Capybara::RSpecMatchers, :type => :controller
|
27
30
|
c.include Capybara::RSpecMatchers, :type => :feature
|
31
|
+
c.include Capybara::RSpecMatchers, :type => :system
|
28
32
|
end
|
29
33
|
|
30
34
|
unless defined?(Capybara::RSpecMatchers) || defined?(Capybara::DSL)
|
data/lib/rspec/rails/version.rb
CHANGED
@@ -18,7 +18,7 @@ module RSpec
|
|
18
18
|
# @example
|
19
19
|
# # path cannot be built because the params are missing a required element (:id)
|
20
20
|
# view_path_builder.path_for({ :controller => 'posts', :action => 'delete' })
|
21
|
-
# # =>
|
21
|
+
# # => ActionController::UrlGenerationError: No route matches {:action=>"delete", :controller=>"posts"}
|
22
22
|
def path_for(path_params)
|
23
23
|
url_for(path_params.merge(:only_path => true))
|
24
24
|
rescue => e
|
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.
|
4
|
+
version: 3.7.0
|
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: 2017-
|
47
|
+
date: 2017-10-17 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.
|
97
|
+
version: 3.7.0
|
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.
|
104
|
+
version: 3.7.0
|
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.
|
111
|
+
version: 3.7.0
|
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.
|
118
|
+
version: 3.7.0
|
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.
|
125
|
+
version: 3.7.0
|
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.
|
132
|
+
version: 3.7.0
|
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.
|
139
|
+
version: 3.7.0
|
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.
|
146
|
+
version: 3.7.0
|
147
147
|
- !ruby/object:Gem::Dependency
|
148
148
|
name: cucumber
|
149
149
|
requirement: !ruby/object:Gem::Requirement
|
@@ -248,6 +248,7 @@ files:
|
|
248
248
|
- lib/rspec/rails/example/rails_example_group.rb
|
249
249
|
- lib/rspec/rails/example/request_example_group.rb
|
250
250
|
- lib/rspec/rails/example/routing_example_group.rb
|
251
|
+
- lib/rspec/rails/example/system_example_group.rb
|
251
252
|
- lib/rspec/rails/example/view_example_group.rb
|
252
253
|
- lib/rspec/rails/extensions.rb
|
253
254
|
- lib/rspec/rails/extensions/active_record/proxy.rb
|
@@ -292,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
292
293
|
version: '0'
|
293
294
|
requirements: []
|
294
295
|
rubyforge_project:
|
295
|
-
rubygems_version: 2.6.
|
296
|
+
rubygems_version: 2.6.14
|
296
297
|
signing_key:
|
297
298
|
specification_version: 4
|
298
299
|
summary: RSpec for Rails
|
metadata.gz.sig
CHANGED
Binary file
|