Skip to content

Instantly share code, notes, and snippets.

@balexand
Created July 24, 2011 01:30
Show Gist options
  • Save balexand/1102083 to your computer and use it in GitHub Desktop.
Save balexand/1102083 to your computer and use it in GitHub Desktop.
Test both Ajax and Javascript-disabled version with the same test using RSpec, Capybara, and Selenium
describe "Pages" do
# a trivial example that follows a link from "Page A" to "Page B"
shared_examples "an example page" do
it "should follow link from Page A to Page B" do
visit page_a_path
click_link "Link to B"
page.should have_content("Page B")
current_path.should == page_b_path
end
end
# shared examples will be run in Rack::Test driver with no Javascript
context "javascript disabled" do
it_behaves_like "an example page"
end
# shared examples will be run in Firefox (via Selenium) with full Javascript support
context "javascript enabled", :js => true do
it_behaves_like "an example page"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment