123456789_123456789_123456789_123456789_123456789_

Module: RSpec::Rails::HelperExampleGroup

Relationships & Source Files
Namespace Children
Modules:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
self, 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/helper_example_group.rb

Overview

Container module for helper specs.

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

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 ]


35
36
37
38
39
# File 'rspec-rails/lib/rspec/rails/example/helper_example_group.rb', line 35

included do
  before do |example|
    controller.controller_path = _controller_path(example)
  end
end

Instance Method Details

#_controller_path(example) (private)

[ GitHub ]

  
# File 'rspec-rails/lib/rspec/rails/example/helper_example_group.rb', line 31

def _controller_path(example)
  example.example_group.described_class.to_s.sub(/Helper/, '').underscore
end

#helper

Returns an instance of ActionView::Base with the helper being specified mixed in, along with any of the built-in rails helpers.

[ GitHub ]

  
# File 'rspec-rails/lib/rspec/rails/example/helper_example_group.rb', line 22

def helper
  _view.tap do |v|
    v.extend(ApplicationHelper) if defined?(ApplicationHelper)
    v.assign(view_assigns)
  end
end