Test the content-type of a response in Cucumber

Updated . Posted . 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
Judith Roth
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)