Sha256: e74efde2acb6087b94b18056ddebbc9741bf915031da6dde39134d41694666ef

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require 'action_controller/test_case'

module Test
  module Spec
    module Rails
      module Controller
        module ClassMethods
          # Sets up the test environment before every functional test
          def tests(controller_class)
            setups << lambda { setup_request_environment(controller_class) }
          end
        end
        module InstanceMethods
          include ActionController::TestProcess
          include ActionController::TestCase::Assertions
          
          attr_reader :controller
          
          # Sets up the test environment for functional tests
          def setup_request_environment(controller_class)
            controller_class.class_eval do
              def rescue_action(e)
                raise e
              end
            end
            @controller = controller_class.new
            @controller.request = @request = ActionController::TestRequest.new
            @response = ActionController::TestResponse.new
            
            @controller.params = {}
            @controller.send(:initialize_current_url)
          end
        end
      end
    end
  end
end

ActiveSupport::TestCase.send(:extend, Test::Spec::Rails::Controller::ClassMethods)
ActiveSupport::TestCase.send(:include, Test::Spec::Rails::Controller::InstanceMethods)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
Fingertips-on-test-spec-0.1.2 lib/test/spec/rails/controller_helpers.rb