Skip to content

Instantly share code, notes, and snippets.

@rimian
Created October 29, 2011 01:37
Show Gist options
  • Save rimian/1323971 to your computer and use it in GitHub Desktop.
Save rimian/1323971 to your computer and use it in GitHub Desktop.
Set headers capybara / mechanize
#env.rb
begin require 'rspec/expectations'; rescue LoadError; require 'spec/expectations'; end
require 'capybara'
require 'capybara/dsl'
require 'capybara/cucumber'
require 'selenium-webdriver'
require 'capybara/mechanize/cucumber'
World do
Capybara.default_driver = :mechanize
Capybara.javascript_driver = :selenium
Capybara.app_host = 'http://example.com'
Capybara
end
# step definition
When /^I visit some URL$/ do
headers = {
'foo' => 'bar'
}
@agent = Mechanize.new
@page = @agent.get('http://example.com', [], nil, headers)
end
Then /^I something should have happened$/ do
@page.body.should have_some_thing
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment