mini-quick-sys 0.0.1
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 +7 -0
- data/mini-quick-sys.gemspec +12 -0
- data/rspec-rails-8.0.4/Capybara.md +28 -0
- data/rspec-rails-8.0.4/Changelog.md +1408 -0
- data/rspec-rails-8.0.4/LICENSE.md +25 -0
- data/rspec-rails-8.0.4/README.md +386 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/authentication/authentication_generator.rb +25 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/authentication/templates/user_spec.rb +5 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/authentication/templates/users.yml +11 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/channel/channel_generator.rb +12 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/channel/templates/channel_spec.rb.erb +7 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/controller/controller_generator.rb +51 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/controller/templates/controller_spec.rb +16 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/controller/templates/request_spec.rb +19 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/controller/templates/routing_spec.rb +13 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/controller/templates/view_spec.rb +5 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/feature/feature_generator.rb +29 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/feature/templates/feature_singular_spec.rb +5 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/feature/templates/feature_spec.rb +5 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/generator/generator_generator.rb +24 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/generator/templates/generator_spec.rb +5 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/helper/helper_generator.rb +16 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/helper/templates/helper_spec.rb +17 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/install/install_generator.rb +80 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/install/templates/spec/rails_helper.rb +91 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/job/job_generator.rb +13 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/job/templates/job_spec.rb.erb +7 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/mailbox/mailbox_generator.rb +14 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/mailbox/templates/mailbox_spec.rb.erb +7 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/mailer/mailer_generator.rb +30 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/mailer/templates/fixture +3 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/mailer/templates/mailer_spec.rb +25 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/mailer/templates/preview.rb +13 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/model/model_generator.rb +37 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/model/templates/fixtures.yml +19 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/model/templates/model_spec.rb +7 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/request/request_generator.rb +17 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/request/templates/request_spec.rb +10 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/scaffold_generator.rb +136 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +129 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/api_request_spec.rb +131 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/controller_spec.rb +145 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/edit_spec.rb +27 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/index_spec.rb +26 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/new_spec.rb +22 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/request_spec.rb +138 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/routing_spec.rb +46 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/scaffold/templates/show_spec.rb +21 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/system/system_generator.rb +24 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/system/templates/system_spec.rb +9 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/view/templates/view_spec.rb +5 -0
- data/rspec-rails-8.0.4/lib/generators/rspec/view/view_generator.rb +22 -0
- data/rspec-rails-8.0.4/lib/generators/rspec.rb +56 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/active_record.rb +25 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/adapters.rb +196 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/configuration.rb +158 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/channel_example_group.rb +93 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/controller_example_group.rb +217 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/feature_example_group.rb +53 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/helper_example_group.rb +42 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/job_example_group.rb +23 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/mailbox_example_group.rb +80 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/mailer_example_group.rb +38 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/model_example_group.rb +11 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/rails_example_group.rb +23 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/request_example_group.rb +27 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/routing_example_group.rb +61 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/system_example_group.rb +177 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example/view_example_group.rb +214 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/example.rb +13 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/extensions/active_record/proxy.rb +11 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/extensions.rb +1 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/feature_check.rb +51 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/file_fixture_support.rb +18 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/fixture_file_upload_support.rb +39 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/fixture_support.rb +58 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb +180 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/action_cable/have_streams.rb +58 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/action_cable.rb +70 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/action_mailbox.rb +73 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/active_job.rb +534 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/base_matcher.rb +179 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/be_a_new.rb +83 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/be_new_record.rb +30 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/be_valid.rb +49 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/have_enqueued_mail.rb +259 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/have_http_status.rb +381 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/have_rendered.rb +64 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/redirect_to.rb +38 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/relation_match_array.rb +3 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/routing_matchers.rb +125 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers/send_email.rb +122 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/matchers.rb +36 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/tasks/rspec.rake +49 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/vendor/capybara.rb +32 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/version.rb +9 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/view_assigns.rb +27 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/view_path_builder.rb +29 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/view_rendering.rb +166 -0
- data/rspec-rails-8.0.4/lib/rspec/rails/view_spec_methods.rb +56 -0
- data/rspec-rails-8.0.4/lib/rspec/rails.rb +18 -0
- data/rspec-rails-8.0.4/lib/rspec-rails.rb +91 -0
- metadata +142 -0
|
@@ -0,0 +1,177 @@
|
|
|
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
|
|
13
|
+
|
|
14
|
+
# Special characters to translate into underscores for #method_name
|
|
15
|
+
CHARS_TO_TRANSLATE = ['/', '.', ':', ',', "'", '"', " "].freeze
|
|
16
|
+
|
|
17
|
+
# @private
|
|
18
|
+
module BlowAwayTeardownHooks
|
|
19
|
+
# @private
|
|
20
|
+
def before_teardown
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# @private
|
|
24
|
+
def after_teardown
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# for the SystemTesting Screenshot situation
|
|
29
|
+
def passed?
|
|
30
|
+
return false if RSpec.current_example.exception
|
|
31
|
+
return true unless defined?(::RSpec::Expectations::FailureAggregator)
|
|
32
|
+
|
|
33
|
+
failure_notifier = ::RSpec::Support.failure_notifier
|
|
34
|
+
return true unless failure_notifier.is_a?(::RSpec::Expectations::FailureAggregator)
|
|
35
|
+
|
|
36
|
+
failure_notifier.failures.empty? && failure_notifier.other_errors.empty?
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# @private
|
|
40
|
+
def method_name
|
|
41
|
+
@method_name ||= [
|
|
42
|
+
self.class.name.underscore,
|
|
43
|
+
RSpec.current_example.description.underscore
|
|
44
|
+
].join("_").tr(CHARS_TO_TRANSLATE.join, "_").byteslice(0...200).scrub("") + "_#{rand(1000)}"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# @private
|
|
48
|
+
# Allows failure screenshot to work whilst not exposing metadata
|
|
49
|
+
class SuppressRailsScreenshotMetadata
|
|
50
|
+
def initialize
|
|
51
|
+
@example_data = {}
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def [](key)
|
|
55
|
+
if @example_data.key?(key)
|
|
56
|
+
@example_data[key]
|
|
57
|
+
else
|
|
58
|
+
raise_wrong_scope_error
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def []=(key, value)
|
|
63
|
+
if key == :failure_screenshot_path
|
|
64
|
+
@example_data[key] = value
|
|
65
|
+
else
|
|
66
|
+
raise_wrong_scope_error
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def method_missing(_name, *_args, &_block)
|
|
71
|
+
raise_wrong_scope_error
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
private
|
|
75
|
+
|
|
76
|
+
def raise_wrong_scope_error
|
|
77
|
+
raise RSpec::Core::ExampleGroup::WrongScopeError,
|
|
78
|
+
"`metadata` is not available from within an example " \
|
|
79
|
+
"(e.g. an `it` block) or from constructs that run in the " \
|
|
80
|
+
"scope of an example (e.g. `before`, `let`, etc). It is " \
|
|
81
|
+
"only available on an example group (e.g. a `describe` or "\
|
|
82
|
+
"`context` block)"
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# @private
|
|
87
|
+
def metadata
|
|
88
|
+
@metadata ||= SuppressRailsScreenshotMetadata.new
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Delegates to `Rails.application`.
|
|
92
|
+
def app
|
|
93
|
+
::Rails.application
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Default driver to assign if none specified.
|
|
97
|
+
DEFAULT_DRIVER = :selenium_chrome_headless
|
|
98
|
+
|
|
99
|
+
included do |other|
|
|
100
|
+
ActiveSupport.on_load(:action_dispatch_system_test_case) do
|
|
101
|
+
ActionDispatch::SystemTesting::Server.silence_puma = true
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
require 'action_dispatch/system_test_case'
|
|
105
|
+
|
|
106
|
+
begin
|
|
107
|
+
require 'capybara'
|
|
108
|
+
rescue LoadError => e
|
|
109
|
+
abort """
|
|
110
|
+
LoadError: #{e.message}
|
|
111
|
+
System test integration has a hard
|
|
112
|
+
dependency on a webserver and `capybara`, please add capybara to
|
|
113
|
+
your Gemfile and configure a webserver (e.g. `Capybara.server =
|
|
114
|
+
:puma`) before attempting to use system specs.
|
|
115
|
+
""".gsub(/\s+/, ' ').strip
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
original_before_teardown =
|
|
119
|
+
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:before_teardown)
|
|
120
|
+
|
|
121
|
+
original_after_teardown =
|
|
122
|
+
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:after_teardown)
|
|
123
|
+
|
|
124
|
+
other.include ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown
|
|
125
|
+
other.include ::ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper
|
|
126
|
+
other.include BlowAwayTeardownHooks
|
|
127
|
+
|
|
128
|
+
attr_reader :driver
|
|
129
|
+
|
|
130
|
+
if ActionDispatch::SystemTesting::Server.respond_to?(:silence_puma=)
|
|
131
|
+
ActionDispatch::SystemTesting::Server.silence_puma = true
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def initialize(*args, &blk)
|
|
135
|
+
super(*args, &blk)
|
|
136
|
+
@driver = nil
|
|
137
|
+
|
|
138
|
+
self.class.before do
|
|
139
|
+
# A user may have already set the driver, so only default if driver
|
|
140
|
+
# is not set
|
|
141
|
+
driven_by(DEFAULT_DRIVER) unless @driver
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def driven_by(driver, **driver_options, &blk)
|
|
146
|
+
@driver = ::ActionDispatch::SystemTestCase.driven_by(driver, **driver_options, &blk).tap(&:use)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def served_by(**options)
|
|
150
|
+
::ActionDispatch::SystemTestCase.served_by(**options)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
before do
|
|
154
|
+
@routes = ::Rails.application.routes
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
after do
|
|
158
|
+
orig_stdout = $stdout
|
|
159
|
+
$stdout = StringIO.new
|
|
160
|
+
begin
|
|
161
|
+
original_before_teardown.bind(self).call
|
|
162
|
+
ensure
|
|
163
|
+
myio = $stdout
|
|
164
|
+
myio.rewind
|
|
165
|
+
RSpec.current_example.metadata[:extra_failure_lines] = myio.readlines
|
|
166
|
+
$stdout = orig_stdout
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
around do |example|
|
|
171
|
+
example.run
|
|
172
|
+
original_after_teardown.bind(self).call
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
require 'rspec/rails/view_assigns'
|
|
2
|
+
require 'rspec/rails/view_spec_methods'
|
|
3
|
+
require 'rspec/rails/view_path_builder'
|
|
4
|
+
|
|
5
|
+
module RSpec
|
|
6
|
+
module Rails
|
|
7
|
+
# @api public
|
|
8
|
+
# Container class for view spec functionality.
|
|
9
|
+
module ViewExampleGroup
|
|
10
|
+
extend ActiveSupport::Concern
|
|
11
|
+
include RSpec::Rails::RailsExampleGroup
|
|
12
|
+
include ActionView::TestCase::Behavior
|
|
13
|
+
include RSpec::Rails::ViewAssigns
|
|
14
|
+
include RSpec::Rails::Matchers::RenderTemplate
|
|
15
|
+
|
|
16
|
+
# @private
|
|
17
|
+
module StubResolverCache
|
|
18
|
+
def self.resolver_for(hash)
|
|
19
|
+
@resolvers ||= {}
|
|
20
|
+
@resolvers[hash] ||= ActionView::FixtureResolver.new(hash)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @private
|
|
25
|
+
module ClassMethods
|
|
26
|
+
def _default_helper
|
|
27
|
+
base = metadata[:description].split('/')[0..-2].join('/')
|
|
28
|
+
(base.camelize + 'Helper').constantize unless base.to_s.empty?
|
|
29
|
+
rescue NameError
|
|
30
|
+
nil
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def _default_helpers
|
|
34
|
+
helpers = [_default_helper].compact
|
|
35
|
+
helpers << ApplicationHelper if Object.const_defined?('ApplicationHelper')
|
|
36
|
+
helpers
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# DSL exposed to view specs.
|
|
41
|
+
module ExampleMethods
|
|
42
|
+
extend ActiveSupport::Concern
|
|
43
|
+
|
|
44
|
+
included do
|
|
45
|
+
include ::Rails.application.routes.url_helpers
|
|
46
|
+
include ::Rails.application.routes.mounted_helpers
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# @overload render
|
|
50
|
+
# @overload render({partial: path_to_file})
|
|
51
|
+
# @overload render({partial: path_to_file}, {... locals ...})
|
|
52
|
+
# @overload render({partial: path_to_file}, {... locals ...}) do ... end
|
|
53
|
+
#
|
|
54
|
+
# Delegates to ActionView::Base#render, so see documentation on that
|
|
55
|
+
# for more info.
|
|
56
|
+
#
|
|
57
|
+
# The only addition is that you can call render with no arguments, and
|
|
58
|
+
# RSpec will pass the top level description to render:
|
|
59
|
+
#
|
|
60
|
+
# describe "widgets/new.html.erb" do
|
|
61
|
+
# it "shows all the widgets" do
|
|
62
|
+
# render # => view.render(file: "widgets/new.html.erb")
|
|
63
|
+
# # ...
|
|
64
|
+
# end
|
|
65
|
+
# end
|
|
66
|
+
def render(options = {}, local_assigns = {}, &block)
|
|
67
|
+
options = _default_render_options if Hash === options && options.empty?
|
|
68
|
+
options = options.merge(_default_render_options) if Hash === options && options.keys == [:locals]
|
|
69
|
+
super(options, local_assigns, &block)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# The instance of `ActionView::Base` that is used to render the template.
|
|
73
|
+
# Use this to stub methods _before_ calling `render`.
|
|
74
|
+
#
|
|
75
|
+
# describe "widgets/new.html.erb" do
|
|
76
|
+
# it "shows all the widgets" do
|
|
77
|
+
# view.stub(:foo) { "foo" }
|
|
78
|
+
# render
|
|
79
|
+
# # ...
|
|
80
|
+
# end
|
|
81
|
+
# end
|
|
82
|
+
def view
|
|
83
|
+
_view
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Simulates the presence of a template on the file system by adding a
|
|
87
|
+
# Rails' FixtureResolver to the front of the view_paths list. Designed to
|
|
88
|
+
# help isolate view examples from partials rendered by the view template
|
|
89
|
+
# that is the subject of the example.
|
|
90
|
+
#
|
|
91
|
+
# stub_template("widgets/_widget.html.erb" => "This content.")
|
|
92
|
+
def stub_template(hash)
|
|
93
|
+
controller.prepend_view_path(StubResolverCache.resolver_for(hash))
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Provides access to the params hash that will be available within the
|
|
97
|
+
# view.
|
|
98
|
+
#
|
|
99
|
+
# params[:foo] = 'bar'
|
|
100
|
+
def params
|
|
101
|
+
controller.params
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# @deprecated Use `view` instead.
|
|
105
|
+
def template
|
|
106
|
+
RSpec.deprecate("template", replacement: "view")
|
|
107
|
+
view
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# @deprecated Use `rendered` instead.
|
|
111
|
+
def response
|
|
112
|
+
# `assert_template` expects `response` to implement a #body method
|
|
113
|
+
# like an `ActionDispatch::Response` does to force the view to
|
|
114
|
+
# render. For backwards compatibility, we use #response as an alias
|
|
115
|
+
# for #rendered, but it needs to implement #body to avoid
|
|
116
|
+
# `assert_template` raising a `NoMethodError`.
|
|
117
|
+
unless rendered.respond_to?(:body)
|
|
118
|
+
def rendered.body
|
|
119
|
+
self
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
rendered
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
private
|
|
127
|
+
|
|
128
|
+
def _default_render_options
|
|
129
|
+
formats = if ActionView::Template::Types.respond_to?(:symbols)
|
|
130
|
+
ActionView::Template::Types.symbols
|
|
131
|
+
else
|
|
132
|
+
[:html, :text, :js, :css, :xml, :json].map(&:to_s)
|
|
133
|
+
end.map { |x| Regexp.escape(x) }.join("|")
|
|
134
|
+
|
|
135
|
+
handlers = ActionView::Template::Handlers.extensions.map { |x| Regexp.escape(x) }.join("|")
|
|
136
|
+
locales = "[a-z]{2}(?:-[A-Z]{2})?"
|
|
137
|
+
variants = "[^.]*"
|
|
138
|
+
path_regex = %r{
|
|
139
|
+
\A
|
|
140
|
+
(?<template>.*?)
|
|
141
|
+
(?:\.(?<locale>#{locales}))??
|
|
142
|
+
(?:\.(?<format>#{formats}))??
|
|
143
|
+
(?:\+(?<variant>#{variants}))??
|
|
144
|
+
(?:\.(?<handler>#{handlers}))?
|
|
145
|
+
\z
|
|
146
|
+
}x
|
|
147
|
+
|
|
148
|
+
# This regex should always find a match.
|
|
149
|
+
# Worst case, everything will be nil, and :template will just be
|
|
150
|
+
# the original string.
|
|
151
|
+
match = path_regex.match(_default_file_to_render)
|
|
152
|
+
|
|
153
|
+
render_options = { template: match[:template] }
|
|
154
|
+
render_options[:handlers] = [match[:handler].to_sym] if match[:handler]
|
|
155
|
+
render_options[:formats] = [match[:format].to_sym] if match[:format]
|
|
156
|
+
render_options[:locales] = [match[:locale].to_sym] if match[:locale]
|
|
157
|
+
render_options[:variants] = [match[:variant].to_sym] if match[:variant]
|
|
158
|
+
|
|
159
|
+
render_options
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def _path_parts
|
|
163
|
+
_default_file_to_render.split("/")
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def _controller_path
|
|
167
|
+
_path_parts[0..-2].join("/")
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def _inferred_action
|
|
171
|
+
_path_parts.last.split(".").first
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def _include_controller_helpers
|
|
175
|
+
helpers = controller._helpers
|
|
176
|
+
view.singleton_class.class_exec do
|
|
177
|
+
include helpers unless included_modules.include?(helpers)
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
included do
|
|
183
|
+
include ExampleMethods
|
|
184
|
+
|
|
185
|
+
helper(*_default_helpers)
|
|
186
|
+
|
|
187
|
+
before do
|
|
188
|
+
_include_controller_helpers
|
|
189
|
+
view.lookup_context.prefixes.prepend(_controller_path)
|
|
190
|
+
|
|
191
|
+
controller.controller_path = _controller_path
|
|
192
|
+
|
|
193
|
+
path_params_to_merge = {}
|
|
194
|
+
path_params_to_merge[:controller] = _controller_path
|
|
195
|
+
path_params_to_merge[:action] = _inferred_action unless _inferred_action =~ /^_/
|
|
196
|
+
|
|
197
|
+
path_params = controller.request.path_parameters
|
|
198
|
+
|
|
199
|
+
controller.request.path_parameters = path_params.reverse_merge(path_params_to_merge)
|
|
200
|
+
controller.request.path = ViewPathBuilder.new(::Rails.application.routes).path_for(controller.request.path_parameters)
|
|
201
|
+
ViewSpecMethods.add_to(::ActionView::TestCase::TestController)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
after do
|
|
205
|
+
ViewSpecMethods.remove_from(::ActionView::TestCase::TestController)
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
let(:_default_file_to_render) do |example|
|
|
209
|
+
example.example_group.top_level_description
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'rspec/rails/example/rails_example_group'
|
|
2
|
+
require 'rspec/rails/example/controller_example_group'
|
|
3
|
+
require 'rspec/rails/example/request_example_group'
|
|
4
|
+
require 'rspec/rails/example/helper_example_group'
|
|
5
|
+
require 'rspec/rails/example/view_example_group'
|
|
6
|
+
require 'rspec/rails/example/mailer_example_group'
|
|
7
|
+
require 'rspec/rails/example/routing_example_group'
|
|
8
|
+
require 'rspec/rails/example/model_example_group'
|
|
9
|
+
require 'rspec/rails/example/job_example_group'
|
|
10
|
+
require 'rspec/rails/example/feature_example_group'
|
|
11
|
+
require 'rspec/rails/example/system_example_group'
|
|
12
|
+
require 'rspec/rails/example/channel_example_group'
|
|
13
|
+
require 'rspec/rails/example/mailbox_example_group'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
RSpec.configure do |rspec|
|
|
2
|
+
# Delay this in order to give users a chance to configure `expect_with`...
|
|
3
|
+
rspec.before(:suite) do
|
|
4
|
+
if defined?(RSpec::Matchers) &&
|
|
5
|
+
RSpec::Matchers.configuration.respond_to?(:syntax) && # RSpec 4 dropped support for monkey-patching `should` syntax
|
|
6
|
+
RSpec::Matchers.configuration.syntax.include?(:should) &&
|
|
7
|
+
defined?(ActiveRecord::Associations)
|
|
8
|
+
RSpec::Matchers.configuration.add_should_and_should_not_to ActiveRecord::Associations::CollectionProxy
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'rspec/rails/extensions/active_record/proxy'
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module RSpec
|
|
2
|
+
module Rails
|
|
3
|
+
# @private
|
|
4
|
+
module FeatureCheck
|
|
5
|
+
module_function
|
|
6
|
+
def has_active_job?
|
|
7
|
+
defined?(::ActiveJob)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def has_active_record?
|
|
11
|
+
defined?(::ActiveRecord)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def has_active_record_migration?
|
|
15
|
+
has_active_record? && defined?(::ActiveRecord::Migration)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def has_action_mailer?
|
|
19
|
+
defined?(::ActionMailer)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def has_action_mailer_preview?
|
|
23
|
+
has_action_mailer? && defined?(::ActionMailer::Preview)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def has_action_cable_testing?
|
|
27
|
+
defined?(::ActionCable)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def has_action_mailer_parameterized?
|
|
31
|
+
has_action_mailer? && defined?(::ActionMailer::Parameterized::DeliveryJob)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def has_action_mailer_unified_delivery?
|
|
35
|
+
has_action_mailer? && defined?(::ActionMailer::MailDeliveryJob)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def has_action_mailer_legacy_delivery_job?
|
|
39
|
+
defined?(ActionMailer::DeliveryJob)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def has_action_mailbox?
|
|
43
|
+
defined?(::ActionMailbox)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def type_metatag(type)
|
|
47
|
+
"type: :#{type}"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'active_support/testing/file_fixtures'
|
|
2
|
+
|
|
3
|
+
module RSpec
|
|
4
|
+
module Rails
|
|
5
|
+
# @private
|
|
6
|
+
module FileFixtureSupport
|
|
7
|
+
extend ActiveSupport::Concern
|
|
8
|
+
include ActiveSupport::Testing::FileFixtures
|
|
9
|
+
|
|
10
|
+
included do
|
|
11
|
+
self.file_fixture_path = RSpec.configuration.file_fixture_path
|
|
12
|
+
if defined?(ActiveStorage::FixtureSet)
|
|
13
|
+
ActiveStorage::FixtureSet.file_fixture_path = RSpec.configuration.file_fixture_path
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
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
|
+
# In Rails 7.0 fixture file path needs to be relative to `file_fixture_path` instead, this change
|
|
10
|
+
# was brought in with a deprecation warning on 6.1. In Rails 7.0 expect to rework this to remove
|
|
11
|
+
# the old accessor.
|
|
12
|
+
def rails_fixture_file_wrapper
|
|
13
|
+
RailsFixtureFileWrapper.file_fixture_path = nil
|
|
14
|
+
resolved_fixture_path =
|
|
15
|
+
if respond_to?(:file_fixture_path) && !file_fixture_path.nil?
|
|
16
|
+
file_fixture_path.to_s
|
|
17
|
+
else
|
|
18
|
+
(RSpec.configuration.fixture_paths&.first || '').to_s
|
|
19
|
+
end
|
|
20
|
+
RailsFixtureFileWrapper.file_fixture_path = File.join(resolved_fixture_path, '') unless resolved_fixture_path.strip.empty?
|
|
21
|
+
RailsFixtureFileWrapper.instance
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class RailsFixtureFileWrapper
|
|
25
|
+
include ActionDispatch::TestProcess if defined?(ActionDispatch::TestProcess)
|
|
26
|
+
include ActiveSupport::Testing::FileFixtures
|
|
27
|
+
|
|
28
|
+
class << self
|
|
29
|
+
attr_accessor :fixture_paths
|
|
30
|
+
|
|
31
|
+
# Get instance of wrapper
|
|
32
|
+
def instance
|
|
33
|
+
@instance ||= new
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
module RSpec
|
|
2
|
+
module Rails
|
|
3
|
+
# @private
|
|
4
|
+
module FixtureSupport
|
|
5
|
+
if defined?(ActiveRecord::TestFixtures)
|
|
6
|
+
extend ActiveSupport::Concern
|
|
7
|
+
include RSpec::Rails::SetupAndTeardownAdapter
|
|
8
|
+
include RSpec::Rails::MinitestLifecycleAdapter
|
|
9
|
+
include RSpec::Rails::MinitestAssertionAdapter
|
|
10
|
+
include ActiveRecord::TestFixtures
|
|
11
|
+
|
|
12
|
+
# @private prevent ActiveSupport::TestFixtures to start a DB transaction.
|
|
13
|
+
# Monkey patched to avoid collisions with 'let(:name)' since Rails 6.1
|
|
14
|
+
def run_in_transaction?
|
|
15
|
+
current_example_name = (RSpec.current_example && RSpec.current_example.metadata[:description])
|
|
16
|
+
use_transactional_tests && !self.class.uses_transaction?(current_example_name)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
included do
|
|
20
|
+
if RSpec.configuration.use_active_record?
|
|
21
|
+
include Fixtures
|
|
22
|
+
|
|
23
|
+
self.fixture_paths = RSpec.configuration.fixture_paths
|
|
24
|
+
|
|
25
|
+
self.use_transactional_tests = RSpec.configuration.use_transactional_fixtures
|
|
26
|
+
self.use_instantiated_fixtures = RSpec.configuration.use_instantiated_fixtures
|
|
27
|
+
|
|
28
|
+
fixtures RSpec.configuration.global_fixtures if RSpec.configuration.global_fixtures
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
module Fixtures
|
|
33
|
+
extend ActiveSupport::Concern
|
|
34
|
+
|
|
35
|
+
class_methods do
|
|
36
|
+
def fixtures(*args)
|
|
37
|
+
super.tap do
|
|
38
|
+
fixture_sets.each_pair do |method_name, fixture_name|
|
|
39
|
+
proxy_method_warning_if_called_in_before_context_scope(method_name, fixture_name)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def proxy_method_warning_if_called_in_before_context_scope(method_name, fixture_name)
|
|
45
|
+
define_method(method_name) do |*args, **kwargs, &blk|
|
|
46
|
+
if RSpec.current_scope == :before_context_hook
|
|
47
|
+
RSpec.warn_with("Calling fixture method in before :context ")
|
|
48
|
+
else
|
|
49
|
+
access_fixture(fixture_name, *args, **kwargs, &blk)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|