Skip to content
This repository
tag: v2.0.0
Fetching contributors…

Cannot retrieve contributors at this time

file 63 lines (52 sloc) 1.469 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
module RSpec::Rails
  # Extends ActionDispatch::Integration::Runner to work with RSpec.
  #
  # == Matchers
  #
  # In addition to the stock matchers from rspec-expectations, request
  # specs add these matchers, which delegate to rails' assertions:
  #
  # response.should render_template(*args)
  # => delegates to assert_template(*args)
  #
  # response.should redirect_to(destination)
  # => delegates to assert_redirected_to(destination)
  module RequestExampleGroup
    extend ActiveSupport::Concern
    extend RSpec::Rails::ModuleInclusion

    include RSpec::Rails::RailsExampleGroup

    include ActionDispatch::Integration::Runner
    include ActionDispatch::Assertions
    include RSpec::Rails::BrowserSimulators

    webrat do
      include Webrat::Matchers
      include Webrat::Methods
    end

    capybara do
      include Capybara
    end

    include RSpec::Rails::Matchers::RedirectTo
    include RSpec::Rails::Matchers::RenderTemplate
    include ActionController::TemplateAssertions

    module InstanceMethods
      def app
        ::Rails.application
      end

      def last_response
        response
      end
    end

    included do
      metadata[:type] = :request

      before do
        @router = ::Rails.application.routes
      end

      webrat do
        Webrat.configure do |config|
          config.mode = :rack
        end
      end
    end

    RSpec.configure &include_self_when_dir_matches('spec','requests')
  end
end
Something went wrong with that request. Please try again.