rspec-rails 3.7.1 → 3.7.2
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 +17 -1
- data/README.md +4 -4
- data/lib/rspec/rails.rb +1 -0
- data/lib/rspec/rails/configuration.rb +5 -11
- data/lib/rspec/rails/example.rb +1 -10
- data/lib/rspec/rails/example/system_example_group.rb +84 -67
- data/lib/rspec/rails/fixture_file_upload_support.rb +39 -0
- data/lib/rspec/rails/version.rb +1 -1
- metadata +3 -2
- 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: 7adb1e867de1a32aa2321c7d214157d1624d4b95
|
4
|
+
data.tar.gz: cc75e1a431ac8dd3d91e515394b759aa4eb2de08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77043a4efa1f5df35358d1531605b611ec55c2ac383f3f6c496fcc4afae68122f2cf37a5442061107c55357a29d621fb64913fe23d9e16acec0f468e645758be
|
7
|
+
data.tar.gz: d58a7c5f801e96d26399eedca46faca78d8dfb398b90b0ba1539780d35bf607b359c473e7acfc1daf1dbb4a0080be4474675dbf418bb99bf663f855709ebff9f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
### Development
|
2
|
-
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.7.
|
2
|
+
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.7.2...master)
|
3
|
+
|
4
|
+
### 3.7.2 / 2017-11-20
|
5
|
+
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.7.1...v3.7.2)
|
6
|
+
|
7
|
+
Bug Fixes:
|
8
|
+
|
9
|
+
* Delay loading system test integration until used. (Jon Rowe, #1903)
|
10
|
+
* Ensure specs using the aggregate failures feature take screenshots on failure.
|
11
|
+
(Matt Brictson, #1907)
|
12
|
+
|
13
|
+
### 3.7.1 / 2017-10-18
|
14
|
+
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.7.0...v3.7.1)
|
15
|
+
|
16
|
+
Bug Fixes:
|
17
|
+
|
18
|
+
* Prevent system test integration loading when puma or capybara are missing (Sam Phippen, #1884)
|
3
19
|
|
4
20
|
### 3.7.0 / 2017-10-17
|
5
21
|
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.6.0...v3.7.0)
|
data/README.md
CHANGED
@@ -197,7 +197,7 @@ end
|
|
197
197
|
|
198
198
|
The above example uses only standard Rails and RSpec APIs, but many
|
199
199
|
RSpec/Rails users like to use extension libraries like
|
200
|
-
[
|
200
|
+
[FactoryBot](https://github.com/thoughtbot/factory_bot) and
|
201
201
|
[Capybara](https://github.com/jnicklas/capybara):
|
202
202
|
|
203
203
|
```ruby
|
@@ -205,7 +205,7 @@ require 'rails_helper'
|
|
205
205
|
|
206
206
|
RSpec.describe "home page", :type => :request do
|
207
207
|
it "displays the user's username after successful login" do
|
208
|
-
user =
|
208
|
+
user = FactoryBot.create(:user, :username => "jdoe", :password => "secret")
|
209
209
|
visit "/login"
|
210
210
|
fill_in "Username", :with => "jdoe"
|
211
211
|
fill_in "Password", :with => "secret"
|
@@ -216,7 +216,7 @@ RSpec.describe "home page", :type => :request do
|
|
216
216
|
end
|
217
217
|
```
|
218
218
|
|
219
|
-
|
219
|
+
FactoryBot decouples this example from changes to validation requirements,
|
220
220
|
which can be encoded into the underlying factory definition without requiring
|
221
221
|
changes to this example.
|
222
222
|
|
@@ -228,7 +228,7 @@ docs](http://rubydoc.info/gems/rspec-rails/file/Capybara.md).
|
|
228
228
|
|
229
229
|
There are several other Ruby libs that implement the factory pattern or provide
|
230
230
|
a DSL for request specs (a.k.a. acceptance or integration specs), but
|
231
|
-
|
231
|
+
FactoryBot and Capybara seem to be the most widely used. Whether you choose
|
232
232
|
these or other libs, we strongly recommend using something for each of these
|
233
233
|
roles.
|
234
234
|
|
data/lib/rspec/rails.rb
CHANGED
@@ -10,6 +10,7 @@ require 'rspec/rails/view_rendering'
|
|
10
10
|
require 'rspec/rails/matchers'
|
11
11
|
require 'rspec/rails/fixture_support'
|
12
12
|
require 'rspec/rails/file_fixture_support'
|
13
|
+
require 'rspec/rails/fixture_file_upload_support'
|
13
14
|
require 'rspec/rails/example'
|
14
15
|
require 'rspec/rails/vendor/capybara'
|
15
16
|
require 'rspec/rails/configuration'
|
@@ -49,17 +49,7 @@ module RSpec
|
|
49
49
|
config.include RSpec::Rails::ViewExampleGroup, :type => :view
|
50
50
|
config.include RSpec::Rails::FeatureExampleGroup, :type => :feature
|
51
51
|
config.include RSpec::Rails::Matchers
|
52
|
-
|
53
|
-
if ActionPack::VERSION::STRING >= "5.1"
|
54
|
-
begin
|
55
|
-
require 'puma'
|
56
|
-
require 'capybara'
|
57
|
-
config.include RSpec::Rails::SystemExampleGroup, :type => :system
|
58
|
-
# rubocop:disable Lint/HandleExceptions
|
59
|
-
rescue LoadError
|
60
|
-
# rubocop:enable Lint/HandleExceptions
|
61
|
-
end
|
62
|
-
end
|
52
|
+
config.include RSpec::Rails::SystemExampleGroup, :type => :system
|
63
53
|
end
|
64
54
|
|
65
55
|
# @private
|
@@ -91,6 +81,10 @@ module RSpec
|
|
91
81
|
config.add_setting :file_fixture_path, :default => 'spec/fixtures/files'
|
92
82
|
config.include RSpec::Rails::FileFixtureSupport
|
93
83
|
end
|
84
|
+
|
85
|
+
# Add support for fixture_path on fixture_file_upload
|
86
|
+
config.include RSpec::Rails::FixtureFileUploadSupport
|
87
|
+
|
94
88
|
# This allows us to expose `render_views` as a config option even though it
|
95
89
|
# breaks the convention of other options by using `render_views` as a
|
96
90
|
# command (i.e. `render_views = true`), where it would normally be used
|
data/lib/rspec/rails/example.rb
CHANGED
@@ -8,13 +8,4 @@ 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
|
-
|
12
|
-
begin
|
13
|
-
require 'puma'
|
14
|
-
require 'capybara'
|
15
|
-
require 'rspec/rails/example/system_example_group'
|
16
|
-
# rubocop:disable Lint/HandleExceptions
|
17
|
-
rescue LoadError
|
18
|
-
# rubocop:enable Lint/HandleExceptions
|
19
|
-
end
|
20
|
-
end
|
11
|
+
require 'rspec/rails/example/system_example_group'
|
@@ -1,85 +1,102 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
include RSpec::Rails::Matchers::RenderTemplate
|
14
|
-
include ActionController::TemplateAssertions
|
15
|
-
|
16
|
-
include ActionDispatch::IntegrationTest::Behavior
|
1
|
+
module RSpec
|
2
|
+
module Rails
|
3
|
+
# @api public
|
4
|
+
# Container class for system tests
|
5
|
+
module SystemExampleGroup
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
include RSpec::Rails::RailsExampleGroup
|
8
|
+
include RSpec::Rails::Matchers::RedirectTo
|
9
|
+
include RSpec::Rails::Matchers::RenderTemplate
|
10
|
+
include ActionDispatch::Integration::Runner
|
11
|
+
include ActionDispatch::Assertions
|
12
|
+
include ActionController::TemplateAssertions
|
17
13
|
|
14
|
+
# @private
|
15
|
+
module BlowAwayAfterTeardownHook
|
18
16
|
# @private
|
19
|
-
|
20
|
-
# @private
|
21
|
-
def after_teardown
|
22
|
-
end
|
17
|
+
def after_teardown
|
23
18
|
end
|
19
|
+
end
|
24
20
|
|
25
|
-
|
21
|
+
# for the SystemTesting Screenshot situation
|
22
|
+
def passed?
|
23
|
+
return false if RSpec.current_example.exception
|
24
|
+
return true unless defined?(::RSpec::Expectations::FailureAggregator)
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
include BlowAwayAfterTeardownHook
|
26
|
+
failure_notifier = ::RSpec::Support.failure_notifier
|
27
|
+
return true unless failure_notifier.is_a?(::RSpec::Expectations::FailureAggregator)
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
RSpec.current_example.exception.nil?
|
34
|
-
end
|
29
|
+
failure_notifier.failures.empty? && failure_notifier.other_errors.empty?
|
30
|
+
end
|
35
31
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
32
|
+
# @private
|
33
|
+
def method_name
|
34
|
+
@method_name ||= [
|
35
|
+
self.class.name.underscore,
|
36
|
+
RSpec.current_example.description.underscore,
|
37
|
+
rand(1000)
|
38
|
+
].join("_").gsub(/[\/\.:, ]/, "_")
|
39
|
+
end
|
40
|
+
|
41
|
+
# Delegates to `Rails.application`.
|
42
|
+
def app
|
43
|
+
::Rails.application
|
44
|
+
end
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
included do |other|
|
47
|
+
begin
|
48
|
+
require 'capybara'
|
49
|
+
require 'action_dispatch/system_test_case'
|
50
|
+
# rubocop:disable Lint/HandleExceptions
|
51
|
+
rescue LoadError
|
52
|
+
# rubocop:enable Lint/HandleExceptions
|
53
|
+
abort """
|
54
|
+
System test integration requires Rails >= 5.1 and has a hard
|
55
|
+
dependency on a webserver and `capybara`, please add capybara to
|
56
|
+
your Gemfile and configure a webserver (e.g. `Capybara.server =
|
57
|
+
:webrick`) before attempting to use system tests.
|
58
|
+
""".gsub(/\s+/, ' ').strip
|
48
59
|
end
|
49
60
|
|
50
|
-
|
51
|
-
|
61
|
+
original_after_teardown =
|
62
|
+
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:after_teardown)
|
52
63
|
|
53
|
-
|
54
|
-
|
55
|
-
|
64
|
+
other.include ActionDispatch::IntegrationTest::Behavior
|
65
|
+
other.include ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown
|
66
|
+
other.include ::ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper
|
67
|
+
other.include BlowAwayAfterTeardownHook
|
56
68
|
|
57
|
-
|
58
|
-
super(*args, &blk)
|
59
|
-
@driver = nil
|
60
|
-
end
|
69
|
+
attr_reader :driver
|
61
70
|
|
62
|
-
|
63
|
-
|
64
|
-
|
71
|
+
if ActionDispatch::SystemTesting::Server.respond_to?(:silence_puma=)
|
72
|
+
ActionDispatch::SystemTesting::Server.silence_puma = true
|
73
|
+
end
|
65
74
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
75
|
+
def initialize(*args, &blk)
|
76
|
+
super(*args, &blk)
|
77
|
+
@driver = nil
|
78
|
+
end
|
79
|
+
|
80
|
+
def driven_by(*args, &blk)
|
81
|
+
@driver = ::ActionDispatch::SystemTestCase.driven_by(*args, &blk).tap(&:use)
|
82
|
+
end
|
83
|
+
|
84
|
+
before do
|
85
|
+
# A user may have already set the driver, so only default if driver
|
86
|
+
# is not set
|
87
|
+
driven_by(:selenium) unless @driver
|
88
|
+
@routes = ::Rails.application.routes
|
89
|
+
end
|
72
90
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
91
|
+
after do
|
92
|
+
orig_stdout = $stdout
|
93
|
+
$stdout = StringIO.new
|
94
|
+
begin
|
95
|
+
original_after_teardown.bind(self).call
|
96
|
+
ensure
|
97
|
+
myio = $stdout
|
98
|
+
RSpec.current_example.metadata[:extra_failure_lines] = myio.string
|
99
|
+
$stdout = orig_stdout
|
83
100
|
end
|
84
101
|
end
|
85
102
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module RSpec
|
2
|
+
module Rails
|
3
|
+
# @private
|
4
|
+
module FixtureFileUploadSupport
|
5
|
+
delegate :fixture_file_upload, :to => :rails_fixture_file_wrapper
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def rails_fixture_file_wrapper
|
10
|
+
resolved_fixture_path = (fixture_path || RSpec.configuration.fixture_path || '')
|
11
|
+
RailsFixtureFileWrapper.fixture_path = File.join(resolved_fixture_path, '')
|
12
|
+
RailsFixtureFileWrapper.instance
|
13
|
+
end
|
14
|
+
|
15
|
+
class RailsFixtureFileWrapper
|
16
|
+
include ActionDispatch::TestProcess if defined?(ActionDispatch::TestProcess)
|
17
|
+
|
18
|
+
class << self
|
19
|
+
attr_reader :fixture_path
|
20
|
+
|
21
|
+
# Get the instance of wrapper
|
22
|
+
def instance
|
23
|
+
@instance ||= new
|
24
|
+
end
|
25
|
+
|
26
|
+
# Override fixture_path set
|
27
|
+
# to support Rails 3.0->3.1 using ActionController::TestCase class to resolve fixture_path
|
28
|
+
# see https://apidock.com/rails/v3.0.0/ActionDispatch/TestProcess/fixture_file_upload
|
29
|
+
def fixture_path=(value)
|
30
|
+
if ActionController::TestCase.respond_to?(:fixture_path)
|
31
|
+
ActionController::TestCase.fixture_path = value
|
32
|
+
end
|
33
|
+
@fixture_path = value
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/rspec/rails/version.rb
CHANGED
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.7.
|
4
|
+
version: 3.7.2
|
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-11-20 00:00:00.000000000 Z
|
48
48
|
dependencies:
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: activesupport
|
@@ -254,6 +254,7 @@ files:
|
|
254
254
|
- lib/rspec/rails/extensions/active_record/proxy.rb
|
255
255
|
- lib/rspec/rails/feature_check.rb
|
256
256
|
- lib/rspec/rails/file_fixture_support.rb
|
257
|
+
- lib/rspec/rails/fixture_file_upload_support.rb
|
257
258
|
- lib/rspec/rails/fixture_support.rb
|
258
259
|
- lib/rspec/rails/matchers.rb
|
259
260
|
- lib/rspec/rails/matchers/active_job.rb
|
metadata.gz.sig
CHANGED
Binary file
|