Sha256: ae8f30a1cb1731a25c4077a58070a46c499f82ae81f1116329257e264de499ae

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

require 'focused_controller/test_helper'
require 'focused_controller/rspec_controller_class'

begin
  # Requiring specific files rather than just 'rspec/rails' because I don't
  # want to force the configuration that 'rspec/rails' adds on people if they
  # haven't specifically chosen to receive it.
  require 'rails/version' unless defined?(Rails)
  require 'rspec/rails/matchers'
  require 'rspec/rails/adapters'
rescue LoadError
end

module FocusedController
  module RSpecHelper
    def self.append_features(base)
      base.class_eval do
        # This must get included higher in the ancestor chain than
        # this module so that inheritance works as desired
        include FocusedController::TestHelper
        extend ClassMethods
        subject { controller }
      end

      super
    end

    if defined?(RSpec::Rails)
      include RSpec::Rails::SetupAndTeardownAdapter
      include RSpec::Rails::TestUnitAssertionAdapter
      include RSpec::Rails::Matchers
      include RSpec::Rails::Matchers::RedirectTo
      include RSpec::Rails::Matchers::RenderTemplate
    end

    module ClassMethods
      include FocusedController::RSpecControllerClass

      def stub_url(*helper_names)
        before { stub_url(*helper_names) }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
focused_controller-1.2.1 lib/focused_controller/rspec_helper.rb
focused_controller-1.2.0 lib/focused_controller/rspec_helper.rb