Sha256: c37e5cf5b3055ed75d83b1e41f17f11858517221a3848b9646abb13caf0cfbb8

Contents?: true

Size: 1.43 KB

Versions: 6

Compression:

Stored size: 1.43 KB

Contents

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rspec-rails-2.1.0 lib/rspec/rails/example/request_example_group.rb
rspec-rails-2.0.1 lib/rspec/rails/example/request_example_group.rb
rspec-rails-2.0.0 lib/rspec/rails/example/request_example_group.rb
rspec-rails-2.0.0.rc lib/rspec/rails/example/request_example_group.rb
rspec-rails-2.0.0.beta.22 lib/rspec/rails/example/request_example_group.rb
rspec-rails-2.0.0.beta.20 lib/rspec/rails/example/request_example_group.rb