123456789_123456789_123456789_123456789_123456789_

Module: RSpec::Rails::ViewExampleGroup

Relationships & Source Files
Namespace Children
Modules:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
self, Matchers::RenderTemplate, ViewAssigns, ActionView::TestCase::Behavior, RailsExampleGroup, ActiveSupport::ExecutionContext::TestHelper, ActiveSupport::CurrentAttributes::TestHelper, TaggedLoggingAdapter, FixtureSupport::Fixtures, FixtureSupport, ActiveRecord::TestFixtures, MinitestAssertionAdapter, MinitestLifecycleAdapter, SetupAndTeardownAdapter
Defined in: rspec-rails/lib/rspec/rails/example/view_example_group.rb

Overview

Container class for view spec functionality.

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

setup

Wraps ‘setup` calls from within Rails’ testing framework in ‘before` hooks.

teardown

Wraps ‘teardown` calls from within Rails’ testing framework in ‘after` hooks.

Instance Attribute Summary

FixtureSupport - Included

#run_in_transaction?

Monkey patched to avoid collisions with ‘let(:name)’ in ::RSpec::Rails 6.1 and after and let(:method_name) before ::RSpec::Rails 6.1.

Instance Method Summary

Matchers::RenderTemplate - Included

#have_rendered

Delegates to ‘assert_template`.

#render_template

ViewAssigns - Included

#assign

Assigns a value to an instance variable in the scope of the view being rendered.

#view_assigns

Compat-shim for AbstractController::Rendering#view_assigns.

#_encapsulated_assigns

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 ‘name` or set it up like ::RSpec::Rails does.

MinitestAssertionAdapter - Included

MinitestLifecycleAdapter - Included

SetupAndTeardownAdapter - Included

DSL Calls

included

[ GitHub ]


182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'rspec-rails/lib/rspec/rails/example/view_example_group.rb', line 182

included do
  include ExampleMethods

  helper(*_default_helpers)

  before do
    _include_controller_helpers
    view.lookup_context.prefixes << _controller_path

    controller.controller_path = _controller_path

    path_params_to_merge = {}
    path_params_to_merge[:controller] = _controller_path
    path_params_to_merge[:action] = _inferred_action unless _inferred_action =~ /^_/

    path_params = controller.request.path_parameters

    controller.request.path_parameters = path_params.reverse_merge(path_params_to_merge)
    controller.request.path = ViewPathBuilder.new(::Rails.application.routes).path_for(controller.request.path_parameters)
    ViewSpecMethods.add_to(::ActionView::TestCase::TestController)
  end

  after do
    ViewSpecMethods.remove_from(::ActionView::TestCase::TestController)
  end

  let(:_default_file_to_render) do |example|
    example.example_group.top_level_description
  end
end