Sha256: f6548045fa238d6c8db29b08e0b51c1b72fd912cd2ede4f796d8e42d2491178d

Contents?: true

Size: 1.39 KB

Versions: 15

Compression:

Stored size: 1.39 KB

Contents

require File.expand_path("spec_helper", File.dirname(File.dirname(__FILE__)))

describe "accept matcher" do
  it "should accept mimetypes and set response Content-Type" do
    app(:header_matchers) do |r|
      r.on :accept=>"application/xml" do
        response["Content-Type"]
      end
    end

    body("HTTP_ACCEPT" => "application/xml").should ==  "application/xml"
    status.should == 404
  end
end

describe "header matcher" do
  it "should match if header present" do
    app(:header_matchers) do |r|
      r.on :header=>"http-accept" do
        "bar"
      end
    end

    body("HTTP_ACCEPT" => "application/xml").should ==  "bar"
    status.should == 404
  end
end

describe "host matcher" do
  it "should match a host" do
    app(:header_matchers) do |r|
      r.on :host=>"example.com" do
        "worked"
      end
    end

    body("HTTP_HOST" => "example.com").should == 'worked'
    status("HTTP_HOST" => "foo.com").should == 404
  end

  it "should match a host with a regexp" do
    app(:header_matchers) do |r|
      r.on :host=>/example/ do
        "worked"
      end
    end

    body("HTTP_HOST" => "example.com").should == 'worked'
    status("HTTP_HOST" => "foo.com").should == 404
  end

  it "doesn't yield HOST" do
    app(:header_matchers) do |r|
      r.on :host=>"example.com" do |*args|
        args.size.to_s
      end
    end

    body("HTTP_HOST" => "example.com").should == '0'
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
roda-1.1.0 spec/plugin/header_matchers_spec.rb
roda-cj-1.0.5 spec/plugin/header_matchers_spec.rb
roda-cj-1.0.4 spec/plugin/header_matchers_spec.rb
roda-cj-1.0.3 spec/plugin/header_matchers_spec.rb
roda-cj-1.0.2 spec/plugin/header_matchers_spec.rb
roda-cj-1.0.1 spec/plugin/header_matchers_spec.rb
roda-cj-1.0.0 spec/plugin/header_matchers_spec.rb
roda-1.0.0 spec/plugin/header_matchers_spec.rb
roda-cj-0.9.6 spec/plugin/header_matchers_spec.rb
roda-cj-0.9.5 spec/plugin/header_matchers_spec.rb
roda-cj-0.9.4 spec/plugin/header_matchers_spec.rb
roda-cj-0.9.3 spec/plugin/header_matchers_spec.rb
roda-cj-0.9.2 spec/plugin/header_matchers_spec.rb
roda-cj-0.9.1 spec/plugin/header_matchers_spec.rb
roda-0.9.0 spec/plugin/header_matchers_spec.rb