Skip to content

Instantly share code, notes, and snippets.

@aokolish
Created November 25, 2011 16:24
Show Gist options
  • Save aokolish/1393902 to your computer and use it in GitHub Desktop.
Save aokolish/1393902 to your computer and use it in GitHub Desktop.
How to get tests running on an external site that uses HTTP authentication
# /spec/example_spec.rb
require 'rspec'
require 'capybara'
require 'capybara/dsl'
require 'capybara-webkit'
require_relative '../spec_helper.rb'
Capybara.app_host = "http://username:password@dev01.example.com"
describe "The homepage", :js => true do
before :all do
Capybara.current_driver = :webkit
end
it "has header links" do
# puts Capybara.current_driver
visit "/"
page.should have_content "Some Text"
page.should have_content "Other Text"
end
it "allows you to sign up for emails" do
click_link "signup"
find('#emailsignupcontainer').should be_visible
fill_in 'elementId', :with => 'bob'
fill_in 'elementId', :with => '123@example.com'
click_link 'Sign Up'
page.should have_content "Thank you for signing up!"
end
end
# /Gemfile
source 'http://rubygems.org'
gem 'rspec'
gem 'capybara'
gem 'selenium-webdriver'
gem 'capybara-webkit'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment