Sha256: 832aef90986cf95f38e524b0b34634d1ccceb428e608a62ed09591dda291631d

Contents?: true

Size: 1.02 KB

Versions: 14

Compression:

Stored size: 1.02 KB

Contents

require 'rspec/rails/view_assigns'

module RSpec
  module Rails
    # Container module for helper specs.
    module HelperExampleGroup
      extend ActiveSupport::Concern
      include RSpec::Rails::RailsExampleGroup
      include ActionView::TestCase::Behavior
      include RSpec::Rails::ViewAssigns

      # @private
      module ClassMethods
        def determine_default_helper_class(_ignore)
          described_class
        end
      end

      # Returns an instance of ActionView::Base with the helper being specified
      # mixed in, along with any of the built-in rails helpers.
      def helper
        _view.tap do |v|
          v.extend(ApplicationHelper) if defined?(ApplicationHelper)
          v.assign(view_assigns)
        end
      end

    private

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

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

Version data entries

14 entries across 13 versions & 3 rubygems

Version Path
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/rspec-rails-3.3.3/lib/rspec/rails/example/helper_example_group.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/rspec-rails-3.3.2/lib/rspec/rails/example/helper_example_group.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/rspec-rails-3.3.2/lib/rspec/rails/example/helper_example_group.rb
rspec-rails-3.3.3 lib/rspec/rails/example/helper_example_group.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/rspec-rails-3.3.2/lib/rspec/rails/example/helper_example_group.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/rspec-rails-3.1.0/lib/rspec/rails/example/helper_example_group.rb
rspec-rails-3.3.2 lib/rspec/rails/example/helper_example_group.rb
rspec-rails-3.3.1 lib/rspec/rails/example/helper_example_group.rb
rspec-rails-3.3.0 lib/rspec/rails/example/helper_example_group.rb
rspec-rails-3.2.3 lib/rspec/rails/example/helper_example_group.rb
rspec-rails-3.2.2 lib/rspec/rails/example/helper_example_group.rb
rspec-rails-3.2.1 lib/rspec/rails/example/helper_example_group.rb
rspec-rails-3.2.0 lib/rspec/rails/example/helper_example_group.rb
rspec-rails-3.1.0 lib/rspec/rails/example/helper_example_group.rb