Sha256: 0296e8760751195c8497b3f3f5bab27f7f7d49a3c528aa9434cd1858bb84a5ca

Contents?: true

Size: 1.5 KB

Versions: 152

Compression:

Stored size: 1.5 KB

Contents

require "rubygems"
require "bundler/setup"

require "rack"
require "rspec"

Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}

require "rack/test"
require File.dirname(__FILE__) + "/fixtures/fake_app"

RSpec.configure do |config|
  config.mock_with :rspec
  config.include Rack::Test::Methods

  def app
    Rack::Lint.new(Rack::Test::FakeApp.new)
  end

  def check(*args)
  end

end

shared_examples_for "any #verb methods" do
  it "requests the URL using VERB" do
    send(verb, "/")

    check last_request.env["REQUEST_METHOD"].should == verb.upcase
    last_response.should be_ok
  end

  it "uses the provided env" do
    send(verb, "/", {}, { "HTTP_USER_AGENT" => "Rack::Test" })
    last_request.env["HTTP_USER_AGENT"].should == "Rack::Test"
  end

  it "yields the response to a given block" do
    yielded = false

    send(verb, "/") do |response|
      response.should be_ok
      yielded = true
    end

    yielded.should be_true
  end

  it "sets the HTTP_HOST header with port" do
    send(verb, "http://example.org:8080/uri")
    last_request.env["HTTP_HOST"].should == "example.org:8080"
  end

  it "sets the HTTP_HOST header without port" do
    send(verb, "/uri")
    last_request.env["HTTP_HOST"].should == "example.org"
  end

  context "for a XHR" do
    it "sends XMLHttpRequest for the X-Requested-With header" do
      send(verb, "/", {}, { :xhr => true })
      last_request.env["HTTP_X_REQUESTED_WITH"].should == "XMLHttpRequest"
      last_request.should be_xhr
    end
  end
end

Version data entries

152 entries across 127 versions & 26 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/rack-test-0.6.1/spec/spec_helper.rb
classiccms-0.7.4 vendor/bundle/gems/rack-test-0.6.1/spec/spec_helper.rb
classiccms-0.7.3 vendor/bundle/gems/rack-test-0.6.1/spec/spec_helper.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-test-0.6.2/spec/spec_helper.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rack-test-0.6.2/spec/spec_helper.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/rack-test-0.6.2/spec/spec_helper.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/rack-test-0.6.2/spec/spec_helper.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/rack-test-0.6.2/spec/spec_helper.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/rack-test-0.6.2/spec/spec_helper.rb
nanumfont-rails-0.1 vendor/bundle/ruby/2.1.0/gems/rack-test-0.6.2/spec/spec_helper.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rack-test-0.6.2/spec/spec_helper.rb
challah-1.0.0 vendor/bundle/gems/rack-test-0.6.2/spec/spec_helper.rb
classiccms-0.7.2 vendor/bundle/gems/rack-test-0.6.1/spec/spec_helper.rb
classiccms-0.7.1 vendor/bundle/gems/rack-test-0.6.1/spec/spec_helper.rb
swipe-rails-0.0.5 vendor/bundle/gems/rack-test-0.6.2/spec/spec_helper.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-test-0.6.2/spec/spec_helper.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-test-0.6.2/spec/spec_helper.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-test-0.6.2/spec/spec_helper.rb
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-test-0.6.2/spec/spec_helper.rb
classiccms-0.7.0 vendor/bundle/gems/rack-test-0.6.1/spec/spec_helper.rb