rspec-rails 4.0.0.beta3 → 4.0.0.beta4
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/Capybara.md +1 -1
- data/Changelog.md +48 -12
- data/README.md +3 -4
- data/lib/generators/rspec.rb +0 -6
- data/lib/generators/rspec/controller/controller_generator.rb +13 -5
- data/lib/generators/rspec/controller/templates/request_spec.rb +14 -0
- data/lib/generators/rspec/controller/templates/routing_spec.rb +1 -1
- data/lib/generators/rspec/feature/feature_generator.rb +2 -2
- data/lib/generators/rspec/generators/generator_generator.rb +1 -1
- data/lib/generators/rspec/helper/helper_generator.rb +1 -1
- data/lib/generators/rspec/install/install_generator.rb +4 -4
- data/lib/generators/rspec/install/templates/spec/rails_helper.rb +2 -15
- data/lib/generators/rspec/integration/integration_generator.rb +3 -3
- data/lib/generators/rspec/mailer/mailer_generator.rb +1 -1
- data/lib/generators/rspec/model/model_generator.rb +4 -4
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +10 -10
- data/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +0 -36
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +10 -10
- data/lib/generators/rspec/scaffold/templates/edit_spec.rb +1 -1
- data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -2
- data/lib/generators/rspec/scaffold/templates/new_spec.rb +1 -1
- data/lib/generators/rspec/scaffold/templates/routing_spec.rb +8 -10
- data/lib/generators/rspec/scaffold/templates/show_spec.rb +1 -1
- data/lib/generators/rspec/system/system_generator.rb +1 -1
- data/lib/generators/rspec/view/view_generator.rb +2 -2
- data/lib/rspec-rails.rb +4 -7
- data/lib/rspec/rails/adapters.rb +8 -74
- data/lib/rspec/rails/configuration.rb +32 -32
- data/lib/rspec/rails/example/controller_example_group.rb +4 -4
- data/lib/rspec/rails/example/feature_example_group.rb +5 -7
- data/lib/rspec/rails/example/helper_example_group.rb +2 -10
- data/lib/rspec/rails/example/rails_example_group.rb +1 -1
- data/lib/rspec/rails/example/system_example_group.rb +6 -3
- data/lib/rspec/rails/example/view_example_group.rb +38 -48
- data/lib/rspec/rails/extensions/active_record/proxy.rb +1 -9
- data/lib/rspec/rails/feature_check.rb +1 -28
- data/lib/rspec/rails/fixture_file_upload_support.rb +1 -1
- data/lib/rspec/rails/fixture_support.rb +8 -13
- data/lib/rspec/rails/matchers/action_cable.rb +1 -1
- data/lib/rspec/rails/matchers/active_job.rb +124 -14
- data/lib/rspec/rails/matchers/base_matcher.rb +4 -10
- data/lib/rspec/rails/matchers/have_enqueued_mail.rb +5 -2
- data/lib/rspec/rails/matchers/have_http_status.rb +7 -7
- data/lib/rspec/rails/matchers/routing_matchers.rb +10 -10
- data/lib/rspec/rails/tasks/rspec.rake +3 -13
- data/lib/rspec/rails/vendor/capybara.rb +10 -10
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec/rails/view_path_builder.rb +1 -1
- data/lib/rspec/rails/view_rendering.rb +3 -3
- metadata +16 -17
- metadata.gz.sig +0 -0
- data/lib/generators/rspec/observer/observer_generator.rb +0 -13
- data/lib/generators/rspec/observer/templates/observer_spec.rb +0 -7
@@ -1,7 +1,9 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Rails
|
3
3
|
module Matchers
|
4
|
-
# @
|
4
|
+
# @api private
|
5
|
+
#
|
6
|
+
# Base class to build matchers. Should not be instantiated directly.
|
5
7
|
class BaseMatcher
|
6
8
|
include RSpec::Matchers::Composable
|
7
9
|
|
@@ -119,15 +121,7 @@ module RSpec
|
|
119
121
|
raise "#{self.class.name} needs to supply#{ivar_list}"
|
120
122
|
end
|
121
123
|
|
122
|
-
|
123
|
-
# :nocov:
|
124
|
-
def present_ivars
|
125
|
-
instance_variables.map(&:to_sym)
|
126
|
-
end
|
127
|
-
# :nocov:
|
128
|
-
else
|
129
|
-
alias present_ivars instance_variables
|
130
|
-
end
|
124
|
+
alias present_ivars instance_variables
|
131
125
|
|
132
126
|
# @private
|
133
127
|
module HashFormatting
|
@@ -1,4 +1,7 @@
|
|
1
|
-
require
|
1
|
+
# We require the minimum amount of rspec-mocks possible to avoid
|
2
|
+
# conflicts with other mocking frameworks.
|
3
|
+
# See: https://github.com/rspec/rspec-rails/issues/2252
|
4
|
+
require "rspec/mocks/argument_matchers"
|
2
5
|
require "rspec/rails/matchers/active_job"
|
3
6
|
|
4
7
|
module RSpec
|
@@ -11,7 +14,7 @@ module RSpec
|
|
11
14
|
class HaveEnqueuedMail < ActiveJob::HaveEnqueuedJob
|
12
15
|
MAILER_JOB_METHOD = 'deliver_now'.freeze
|
13
16
|
|
14
|
-
include RSpec::Mocks::
|
17
|
+
include RSpec::Mocks::ArgumentMatchers
|
15
18
|
|
16
19
|
def initialize(mailer_class, method_name)
|
17
20
|
super(nil)
|
@@ -73,7 +73,7 @@ module RSpec
|
|
73
73
|
# @example
|
74
74
|
# expect(response).to have_http_status(404)
|
75
75
|
#
|
76
|
-
# @see RSpec::Rails::Matchers
|
76
|
+
# @see RSpec::Rails::Matchers#have_http_status
|
77
77
|
class NumericCode < RSpec::Rails::Matchers::BaseMatcher
|
78
78
|
include HaveHttpStatus
|
79
79
|
|
@@ -123,7 +123,7 @@ module RSpec
|
|
123
123
|
# @example
|
124
124
|
# expect(response).to have_http_status(:created)
|
125
125
|
#
|
126
|
-
# @see RSpec::Rails::Matchers
|
126
|
+
# @see RSpec::Rails::Matchers#have_http_status
|
127
127
|
# @see https://github.com/rack/rack/blob/master/lib/rack/utils.rb `Rack::Utils::SYMBOL_TO_STATUS_CODE`
|
128
128
|
class SymbolicStatus < RSpec::Rails::Matchers::BaseMatcher
|
129
129
|
include HaveHttpStatus
|
@@ -236,8 +236,8 @@ module RSpec
|
|
236
236
|
# expect(response).to have_http_status(:missing)
|
237
237
|
# expect(response).to have_http_status(:redirect)
|
238
238
|
#
|
239
|
-
# @see RSpec::Rails::Matchers
|
240
|
-
# @see ActionDispatch::TestResponse
|
239
|
+
# @see RSpec::Rails::Matchers#have_http_status
|
240
|
+
# @see https://github.com/rails/rails/blob/6-0-stable/actionpack/lib/action_dispatch/testing/test_response.rb `ActionDispatch::TestResponse`
|
241
241
|
class GenericStatus < RSpec::Rails::Matchers::BaseMatcher
|
242
242
|
include HaveHttpStatus
|
243
243
|
|
@@ -293,9 +293,9 @@ module RSpec
|
|
293
293
|
protected
|
294
294
|
|
295
295
|
RESPONSE_METHODS = {
|
296
|
-
:
|
297
|
-
:
|
298
|
-
:
|
296
|
+
success: 'successful',
|
297
|
+
error: 'server_error',
|
298
|
+
missing: 'not_found'
|
299
299
|
}.freeze
|
300
300
|
|
301
301
|
def check_expected_status(test_response, expected)
|
@@ -14,7 +14,7 @@ module RSpec
|
|
14
14
|
@expected.merge!(expected[0])
|
15
15
|
else
|
16
16
|
controller, action = expected[0].split('#')
|
17
|
-
@expected.merge!(:
|
17
|
+
@expected.merge!(controller: controller, action: action)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -26,7 +26,7 @@ module RSpec
|
|
26
26
|
path, query = *verb_to_path_map.values.first.split('?')
|
27
27
|
@scope.assert_recognizes(
|
28
28
|
@expected,
|
29
|
-
{ :
|
29
|
+
{ method: verb_to_path_map.keys.first, path: path },
|
30
30
|
Rack::Utils.parse_nested_query(query)
|
31
31
|
)
|
32
32
|
end
|
@@ -50,12 +50,12 @@ module RSpec
|
|
50
50
|
#
|
51
51
|
# @example
|
52
52
|
#
|
53
|
-
# expect(:
|
54
|
-
# :
|
55
|
-
# :
|
53
|
+
# expect(get: "/things/special").to route_to(
|
54
|
+
# controller: "things",
|
55
|
+
# action: "special"
|
56
56
|
# )
|
57
57
|
#
|
58
|
-
# expect(:
|
58
|
+
# expect(get: "/things/special").to route_to("things#special")
|
59
59
|
#
|
60
60
|
# @see https://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html#method-i-assert_recognizes
|
61
61
|
def route_to(*expected)
|
@@ -72,7 +72,7 @@ module RSpec
|
|
72
72
|
@actual = path
|
73
73
|
match_unless_raises ActionController::RoutingError do
|
74
74
|
@routing_options = @scope.routes.recognize_path(
|
75
|
-
path.values.first, :
|
75
|
+
path.values.first, method: path.keys.first
|
76
76
|
)
|
77
77
|
end
|
78
78
|
end
|
@@ -95,9 +95,9 @@ module RSpec
|
|
95
95
|
# `RouteSet#recognize_path`.
|
96
96
|
#
|
97
97
|
# @example You can use route helpers provided by rspec-rails.
|
98
|
-
# expect(:
|
99
|
-
# expect(:
|
100
|
-
# expect(:
|
98
|
+
# expect(get: "/a/path").to be_routable
|
99
|
+
# expect(post: "/another/path").to be_routable
|
100
|
+
# expect(put: "/yet/another/path").to be_routable
|
101
101
|
def be_routable
|
102
102
|
BeRoutableMatcher.new(self)
|
103
103
|
end
|
@@ -3,12 +3,12 @@ if default = Rake.application.instance_variable_get('@tasks')['default']
|
|
3
3
|
default.prerequisites.delete('test')
|
4
4
|
end
|
5
5
|
|
6
|
-
task :
|
6
|
+
task default: :spec
|
7
7
|
|
8
|
-
task :
|
8
|
+
task stats: "spec:statsetup"
|
9
9
|
|
10
10
|
desc "Run all specs in spec directory (excluding plugin specs)"
|
11
|
-
RSpec::Core::RakeTask.new(:
|
11
|
+
RSpec::Core::RakeTask.new(spec: "spec:prepare")
|
12
12
|
|
13
13
|
namespace :spec do
|
14
14
|
types = begin
|
@@ -35,16 +35,6 @@ namespace :spec do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
# RCov task only enabled for Ruby 1.8
|
39
|
-
if RUBY_VERSION < '1.9'
|
40
|
-
desc "Run all specs with rcov"
|
41
|
-
RSpec::Core::RakeTask.new(:rcov => "spec:prepare") do |t|
|
42
|
-
t.rcov = true
|
43
|
-
t.pattern = "./spec/**/*_spec.rb"
|
44
|
-
t.rcov_opts = '--exclude /gems/,/Library/,/usr/,lib/tasks,.bundle,config,/lib/rspec/,/lib/rspec-,spec'
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
38
|
task :statsetup do
|
49
39
|
require 'rails/code_statistics'
|
50
40
|
types.each do |type, dir|
|
@@ -16,24 +16,24 @@ if defined?(Capybara)
|
|
16
16
|
|
17
17
|
RSpec.configure do |c|
|
18
18
|
if defined?(Capybara::DSL)
|
19
|
-
c.include Capybara::DSL, :
|
19
|
+
c.include Capybara::DSL, type: :feature
|
20
20
|
if defined?(ActionPack) && ActionPack::VERSION::STRING >= "5.1"
|
21
|
-
c.include Capybara::DSL, :
|
21
|
+
c.include Capybara::DSL, type: :system
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
if defined?(Capybara::RSpecMatchers)
|
26
|
-
c.include Capybara::RSpecMatchers, :
|
27
|
-
c.include Capybara::RSpecMatchers, :
|
28
|
-
c.include Capybara::RSpecMatchers, :
|
29
|
-
c.include Capybara::RSpecMatchers, :
|
30
|
-
c.include Capybara::RSpecMatchers, :
|
31
|
-
c.include Capybara::RSpecMatchers, :
|
26
|
+
c.include Capybara::RSpecMatchers, type: :view
|
27
|
+
c.include Capybara::RSpecMatchers, type: :helper
|
28
|
+
c.include Capybara::RSpecMatchers, type: :mailer
|
29
|
+
c.include Capybara::RSpecMatchers, type: :controller
|
30
|
+
c.include Capybara::RSpecMatchers, type: :feature
|
31
|
+
c.include Capybara::RSpecMatchers, type: :system
|
32
32
|
end
|
33
33
|
|
34
34
|
unless defined?(Capybara::RSpecMatchers) || defined?(Capybara::DSL)
|
35
|
-
c.include Capybara, :
|
36
|
-
c.include Capybara, :
|
35
|
+
c.include Capybara, type: :request
|
36
|
+
c.include Capybara, type: :controller
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/lib/rspec/rails/version.rb
CHANGED
@@ -20,7 +20,7 @@ module RSpec
|
|
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
|
-
url_for(path_params.merge(:
|
23
|
+
url_for(path_params.merge(only_path: true))
|
24
24
|
rescue => e
|
25
25
|
e.message
|
26
26
|
end
|
@@ -55,9 +55,9 @@ module RSpec
|
|
55
55
|
"",
|
56
56
|
template.identifier,
|
57
57
|
EmptyTemplateHandler,
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
58
|
+
virtual_path: template.virtual_path,
|
59
|
+
format: template_format(template),
|
60
|
+
locals: []
|
61
61
|
)
|
62
62
|
end
|
63
63
|
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.
|
4
|
+
version: 4.0.0.beta4
|
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:
|
47
|
+
date: 2020-01-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.
|
97
|
+
version: '3.9'
|
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.9'
|
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.9'
|
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.9'
|
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.9'
|
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.9'
|
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.9'
|
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.9'
|
147
147
|
- !ruby/object:Gem::Dependency
|
148
148
|
name: cucumber
|
149
149
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,14 +164,14 @@ dependencies:
|
|
164
164
|
requirements:
|
165
165
|
- - "~>"
|
166
166
|
- !ruby/object:Gem::Version
|
167
|
-
version: 0.
|
167
|
+
version: 0.14.12
|
168
168
|
type: :development
|
169
169
|
prerelease: false
|
170
170
|
version_requirements: !ruby/object:Gem::Requirement
|
171
171
|
requirements:
|
172
172
|
- - "~>"
|
173
173
|
- !ruby/object:Gem::Version
|
174
|
-
version: 0.
|
174
|
+
version: 0.14.12
|
175
175
|
- !ruby/object:Gem::Dependency
|
176
176
|
name: ammeter
|
177
177
|
requirement: !ruby/object:Gem::Requirement
|
@@ -186,7 +186,7 @@ dependencies:
|
|
186
186
|
- - "~>"
|
187
187
|
- !ruby/object:Gem::Version
|
188
188
|
version: 1.1.2
|
189
|
-
description: rspec-rails is a testing framework for Rails
|
189
|
+
description: rspec-rails is a testing framework for Rails 5+.
|
190
190
|
email: rspec@googlegroups.com
|
191
191
|
executables: []
|
192
192
|
extensions: []
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- lib/generators/rspec/channel/templates/channel_spec.rb.erb
|
204
204
|
- lib/generators/rspec/controller/controller_generator.rb
|
205
205
|
- lib/generators/rspec/controller/templates/controller_spec.rb
|
206
|
+
- lib/generators/rspec/controller/templates/request_spec.rb
|
206
207
|
- lib/generators/rspec/controller/templates/routing_spec.rb
|
207
208
|
- lib/generators/rspec/controller/templates/view_spec.rb
|
208
209
|
- lib/generators/rspec/feature/feature_generator.rb
|
@@ -227,8 +228,6 @@ files:
|
|
227
228
|
- lib/generators/rspec/model/model_generator.rb
|
228
229
|
- lib/generators/rspec/model/templates/fixtures.yml
|
229
230
|
- lib/generators/rspec/model/templates/model_spec.rb
|
230
|
-
- lib/generators/rspec/observer/observer_generator.rb
|
231
|
-
- lib/generators/rspec/observer/templates/observer_spec.rb
|
232
231
|
- lib/generators/rspec/request/request_generator.rb
|
233
232
|
- lib/generators/rspec/scaffold/scaffold_generator.rb
|
234
233
|
- lib/generators/rspec/scaffold/templates/api_controller_spec.rb
|
@@ -295,7 +294,7 @@ licenses:
|
|
295
294
|
- MIT
|
296
295
|
metadata:
|
297
296
|
bug_tracker_uri: https://github.com/rspec/rspec-rails/issues
|
298
|
-
changelog_uri: https://github.com/rspec/rspec-rails/blob/v4.0.0.
|
297
|
+
changelog_uri: https://github.com/rspec/rspec-rails/blob/v4.0.0.beta4/Changelog.md
|
299
298
|
documentation_uri: https://rspec.info/documentation/
|
300
299
|
mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
|
301
300
|
source_code_uri: https://github.com/rspec/rspec-rails
|
@@ -315,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
315
314
|
- !ruby/object:Gem::Version
|
316
315
|
version: 1.3.1
|
317
316
|
requirements: []
|
318
|
-
rubygems_version: 3.
|
317
|
+
rubygems_version: 3.1.2
|
319
318
|
signing_key:
|
320
319
|
specification_version: 4
|
321
320
|
summary: RSpec for Rails
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'generators/rspec'
|
2
|
-
|
3
|
-
module Rspec
|
4
|
-
module Generators
|
5
|
-
# @private
|
6
|
-
class ObserverGenerator < Base
|
7
|
-
def generate_observer_spec
|
8
|
-
template 'observer_spec.rb',
|
9
|
-
File.join('spec', 'models', class_path, "#{file_name}_observer_spec.rb")
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|