-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example spec showing custom request headers & response header matching.
- Loading branch information
Martin Bilski
authored and
Martin Bilski
committed
Sep 5, 2011
1 parent
daf5197
commit 9e61624
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require File.join(File.dirname(__FILE__), "../spec_helper") | ||
require File.join(File.dirname(__FILE__), "sample_actions") | ||
|
||
describe CustomHeader, :cramp => true do | ||
def app | ||
CustomHeader | ||
end | ||
|
||
it "should render the value of the custom header" do | ||
get("/", :headers => {"Custom-Header" => "SAMPLE VALUE"}).should respond_with :body => /^SAMPLE VALUE$/ | ||
get("/", :headers => {"Custom-Header" => "SAMPLE VALUE"}).should respond_with :body => "SAMPLE VALUE" | ||
end | ||
|
||
it "should include the custom header in response headers" do | ||
# Exact match using string & regex. | ||
get("/", :headers => {"Custom-Header" => "SAMPLE VALUE"}).should respond_with :headers => {"Custom-Header" => "SAMPLE VALUE"} | ||
get("/", :headers => {"Custom-Header" => "SAMPLE VALUE"}).should respond_with :headers => {"Custom-Header" => /^SAMPLE VALUE$/} | ||
|
||
# Header field names are case insensitive - use regex match: | ||
get("/", :headers => {"Custom-Header" => "SAMPLE VALUE"}).should respond_with :headers => {/Custom\-Header/i => "SAMPLE VALUE"} | ||
|
||
# Negative match. | ||
get("/", :headers => {"Custom-Header" => "SAMPLE VALUE"}).should_not respond_with :headers => {"Custom-Header" => "ANOTHER VALUE"} | ||
end | ||
end |