Sha256: 78c383ac2b76bc094bc8e13085509991b2f43b31f191b3d8ffee494041144c0b

Contents?: true

Size: 975 Bytes

Versions: 6

Compression:

Stored size: 975 Bytes

Contents

require 'rspec/rails/view_assigns'

module RSpec::Rails
  module HelperExampleGroup
    extend ActiveSupport::Concern
    include RSpec::Rails::RailsExampleGroup
    include ActionView::TestCase::Behavior
    include RSpec::Rails::ViewAssigns

    module ClassMethods
      # @api private
      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
      metadata[:type] = :helper

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rspec-rails-2.99.0 lib/rspec/rails/example/helper_example_group.rb
rspec-rails-2.99.0.rc1 lib/rspec/rails/example/helper_example_group.rb
rspec-rails-3.0.0.beta2 lib/rspec/rails/example/helper_example_group.rb
rspec-rails-2.99.0.beta2 lib/rspec/rails/example/helper_example_group.rb
rspec-rails-3.0.0.beta1 lib/rspec/rails/example/helper_example_group.rb
rspec-rails-2.99.0.beta1 lib/rspec/rails/example/helper_example_group.rb