Module: RSpec::Rails::SystemExampleGroup
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Classes:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
MinitestAssertionAdapter::ClassMethods ,
SetupAndTeardownAdapter::ClassMethods ,
ActiveSupport::Concern
|
|
Instance Chain:
self,
ActionController::TemplateAssertions,
ActionDispatch::Assertions,
ActionDispatch::Integration::Runner,
Matchers::RenderTemplate ,
Matchers::RedirectTo ,
RailsExampleGroup ,
ActiveSupport::ExecutionContext::TestHelper,
ActiveSupport::CurrentAttributes::TestHelper,
TaggedLoggingAdapter ,
FixtureSupport::Fixtures ,
FixtureSupport ,
ActiveRecord::TestFixtures,
MinitestAssertionAdapter ,
MinitestLifecycleAdapter ,
SetupAndTeardownAdapter
|
|
Defined in: | rspec-rails/lib/rspec/rails/example/system_example_group.rb |
Overview
Container class for system tests
Constant Summary
-
CHARS_TO_TRANSLATE =
Special characters to translate into underscores for #method_name
['/', '.', ':', ',', "'", '"', " "].freeze
-
DEFAULT_DRIVER =
Default driver to assign if none specified.
if ::Rails::VERSION::STRING.to_f >= 7.2 :selenium_chrome_headless else :selenium end
Class Method Summary
MinitestAssertionAdapter::ClassMethods
- Extended
assertion_method_names | Returns the names of assertion methods that we want to expose to examples without exposing non-assertion methods in Test::Unit or Minitest. |
define_assertion_delegators |
SetupAndTeardownAdapter::ClassMethods
- Extended
Instance Attribute Summary
-
#passed? ⇒ Boolean
readonly
for the SystemTesting Screenshot situation.
FixtureSupport
- Included
#run_in_transaction? | Monkey patched to avoid collisions with ‘let(:name)’ since |
Instance Method Summary
-
#app
Delegates to
Rails.application
. - #metadata Internal use only Internal use only
- #method_name Internal use only Internal use only
Matchers::RenderTemplate
- Included
#have_rendered | Delegates to |
#render_template | Alias for Matchers::RenderTemplate#have_rendered. |
Matchers::RedirectTo
- Included
#redirect_to | Delegates to |
TaggedLoggingAdapter
- Included
#tagged_logger | Vendored from activesupport/lib/active_support/testing/tagged_logging.rb This implements the tagged_logger method where it is expected, but doesn’t call |
MinitestAssertionAdapter
- Included
MinitestLifecycleAdapter
- Included
SetupAndTeardownAdapter
- Included
DSL Calls
included
[ GitHub ]106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
# File 'rspec-rails/lib/rspec/rails/example/system_example_group.rb', line 106
included do |other| ActiveSupport.on_load(:action_dispatch_system_test_case) do ActionDispatch::SystemTesting::Server.silence_puma = true end require 'action_dispatch/system_test_case' begin require 'capybara' rescue LoadError => e abort """ LoadError: #{e.} System test integration has a hard dependency on a webserver and `capybara`, please add capybara to your Gemfile and configure a webserver (e.g. `Capybara.server = :puma`) before attempting to use system specs. """.gsub(/\s+/, ' ').strip end original_before_teardown = ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:before_teardown) original_after_teardown = ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:after_teardown) other.include ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown other.include ::ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper other.include BlowAwayTeardownHooks attr_reader :driver if ActionDispatch::SystemTesting::Server.respond_to?(:silence_puma=) ActionDispatch::SystemTesting::Server.silence_puma = true end def initialize(*args, &blk) super(*args, &blk) @driver = nil self.class.before do # A user may have already set the driver, so only default if driver # is not set driven_by(DEFAULT_DRIVER) unless @driver end end def driven_by(driver, **, &blk) @driver = ::ActionDispatch::SystemTestCase.driven_by(driver, **, &blk).tap(&:use) end before do @routes = ::Rails.application.routes end after do orig_stdout = $stdout $stdout = StringIO.new begin original_before_teardown.bind(self).call ensure myio = $stdout myio.rewind RSpec.current_example. [:extra_failure_lines] = myio.readlines $stdout = orig_stdout end end around do |example| example.run original_after_teardown.bind(self).call end end
Instance Attribute Details
#passed? ⇒ Boolean
(readonly)
for the SystemTesting Screenshot situation
# File 'rspec-rails/lib/rspec/rails/example/system_example_group.rb', line 29
def passed? return false if RSpec.current_example.exception return true unless defined?(::RSpec::Expectations::FailureAggregator) failure_notifier = ::RSpec::Support.failure_notifier return true unless failure_notifier.is_a?(::RSpec::Expectations::FailureAggregator) failure_notifier.failures.empty? && failure_notifier.other_errors.empty? end
Instance Method Details
#app
Delegates to Rails.application
.
# File 'rspec-rails/lib/rspec/rails/example/system_example_group.rb', line 94
def app ::Rails.application end
#metadata
# File 'rspec-rails/lib/rspec/rails/example/system_example_group.rb', line 88
def @metadata ||= SuppressRailsScreenshotMetadata.new end
#method_name
# File 'rspec-rails/lib/rspec/rails/example/system_example_group.rb', line 40
def method_name @method_name ||= [ self.class.name.underscore, RSpec.current_example.description.underscore ].join("_").tr(CHARS_TO_TRANSLATE.join, "_").byteslice(0...200).scrub("") + "_#{rand(1000)}" end