Skip to content

Commit 4908241

Browse files
committed
Assert headers order-agnostically.
1 parent 1fc5c9f commit 4908241

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

features/callbacks.feature

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Feature: Document callbacks
1212
request = Net::HTTP::Post.new(uri.path)
1313
request.body = '{"message":"Something interesting happened!"}'
1414
request.add_field("Content-Type", "application/json")
15+
request.add_field("User-Agent", "InterestingThingApp")
1516
http.request request
1617
end
1718
200
@@ -65,11 +66,9 @@ Feature: Document callbacks
6566
And I navigate to "Receiving a callback when interesting things happen"
6667
Then I should see the route is "POST /callback"
6768
And I should see the following request headers:
68-
"""
69-
Content-Type: application/json
70-
Accept: */*
71-
User-Agent: Ruby
72-
"""
69+
| Content-Type | application/json |
70+
| Accept | */* |
71+
| User-Agent | InterestingThingApp |
7372
And I should see the following request body:
7473
"""
7574
{

features/html_documentation.feature

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ Feature: Generate HTML documentation from test examples
7171
And I navigate to "Greeting your favorite gem"
7272
Then I should see the route is "GET /greetings?target=rspec_api_documentation"
7373
And I should see the following request headers:
74-
"""
75-
Host: example.org
76-
Cookie:
77-
"""
74+
| Host | example.org |
75+
| Cookie | |
7876
And I should see the following query parameters:
7977
"""
8078
target: rspec_api_documentation
@@ -85,10 +83,8 @@ Feature: Generate HTML documentation from test examples
8583
And I navigate to "Greeting your favorite gem"
8684
Then I should see the response status is "200 OK"
8785
And I should see the following response headers:
88-
"""
89-
Content-Type: application/json
90-
Content-Length: 35
91-
"""
86+
| Content-Type | application/json |
87+
| Content-Length | 35 |
9288
And I should see the following response body:
9389
"""
9490
{

features/step_definitions/html_steps.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
names.zip(descriptions).should == table.rows
1717
end
1818

19-
Then /^I should see the following (request|response) headers:$/ do |part, headers|
20-
page.should have_css("pre.#{part}.headers", :text => headers)
19+
Then /^I should see the following (request|response) headers:$/ do |part, table|
20+
text = page.find("pre.#{part}.headers").text
21+
actual_headers = text.split("\n")
22+
expected_headers = table.raw.map { |row| row.join(": ") }
23+
actual_headers.should =~ expected_headers
2124
end
2225

2326
Then /^I should see the route is "([^"]*)"$/ do |route|

0 commit comments

Comments
 (0)