Sha256: 67e375af2d334ab2e92ed5de4cddbfc8a902be37faf28e4bfbc13cc5b1fe5210

Contents?: true

Size: 1.56 KB

Versions: 26

Compression:

Stored size: 1.56 KB

Contents

require "rubygems"
require "bundler/setup"

require "codeclimate-test-reporter"
CodeClimate::TestReporter.start

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

26 entries across 25 versions & 12 rubygems

Version Path
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/rack-test-0.6.3/spec/spec_helper.rb
tdiary-5.0.5 vendor/bundle/gems/rack-test-0.6.3/spec/spec_helper.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/rack-test-0.6.3/spec/spec_helper.rb
tdiary-5.0.4 vendor/bundle/gems/rack-test-0.6.3/spec/spec_helper.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/rack-test-0.6.3/spec/spec_helper.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-test-0.6.3/spec/spec_helper.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-test-0.6.3/spec/spec_helper.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-test-0.6.3/spec/spec_helper.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-test-0.6.3/spec/spec_helper.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-test-0.6.3/spec/spec_helper.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-test-0.6.3/spec/spec_helper.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-test-0.6.3/spec/spec_helper.rb
abaci-0.3.0 vendor/bundle/gems/rack-test-0.6.3/spec/spec_helper.rb
arcabouco-0.2.13 vendor/bundle/gems/rack-test-0.6.3/spec/spec_helper.rb
tdiary-5.0.2 vendor/bundle/gems/rack-test-0.6.3/spec/spec_helper.rb
tdiary-5.0.1 vendor/bundle/gems/rack-test-0.6.3/spec/spec_helper.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/rack-test-0.6.3/spec/spec_helper.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/rack-test-0.6.3/spec/spec_helper.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/rack-test-0.6.3/spec/spec_helper.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/rack-test-0.6.3/spec/spec_helper.rb