Skip to content

Instantly share code, notes, and snippets.

@robzolkos
Created January 24, 2012 05:05
Show Gist options
  • Save robzolkos/1668070 to your computer and use it in GitHub Desktop.
Save robzolkos/1668070 to your computer and use it in GitHub Desktop.
Integration test for accept header issue in Rails 3
require 'spec_helper'
describe "Returns page as normal" do
it "with accept header '*/*;q=0.6'" do
page.driver.header "Accept", "*/*;q=0.6"
visit fb_path
page.current_path.should == fb_path
end
it "with accept header 'text/html;q=0.7'" do
page.driver.header "Accept", "text/html;q=0.7"
visit fb_path
page.current_path.should == fb_path
end
it "with accept header 'text/*\\'" do
page.driver.header "Accept", "text/*\\"
visit fb_path
page.current_path.should == fb_path
end
it "with accept header 'text/*'" do
page.driver.header "Accept", "text/*"
visit fb_path
page.current_path.should == fb_path
end
it "with accept header '*/*'" do
page.driver.header "Accept", "*/*"
visit fb_path
page.current_path.should == fb_path
end
end
# put this in config/initializers
module Mime
class Type
def self.lookup(string)
string = string.gsub(/\\/, "")
string = string.gsub(/text\/\*/, "*")
LOOKUP[string.split(';').first]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment