Test the content-type of a response in Cucumber

Posted Over 13 years ago. Visible to the public.

The step definitions below allow you to write this in both Webrat and Capybara:

When I follow "Download as PDF"
Then I should get a response with content-type "application/pdf"

Capybara

Then /^I should get a response with content-type "([^"]*)"$/ do |content_type|
  page.response_headers['Content-Type'].should == content_type
end

Webrat

Then /^I should get a response with content-type "([^"]*)"$/ do |content_type|
  response.content_type.should == content_type
end

Unfortunatly this does not work with the Selenium webdriver.

Henning Koch
Last edit
About 9 years ago
Deleted user #4117
Keywords
internet, media, type, mime
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2010-12-30 13:57)