Created
March 1, 2010 16:14
-
-
Save reagent/318494 to your computer and use it in GitHub Desktop.
Simple Cuke stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'cucumber' | |
require 'capybara' | |
require 'capybara/cucumber' | |
require 'capybara/session' | |
Before do | |
Capybara.current_driver = :selenium | |
Capybara.app_host = 'http://yahoo.com' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Searching Yahoo | |
Scenario: Searching for a single term | |
Given I am on the home page | |
When I search for "Ruby" | |
Then I should see the following results: | |
| Title | | |
| Ruby - Wikipedia, the free encyclopedia | | |
| Ruby (programming language) - Wikipedia, the free encyclopedia | | |
| Ruby Programming Language | | |
| About Ruby | | |
| Ruby's Diner - rubys.com | | |
| Ruby on Rails | | |
| Ruby - english | | |
| Fresh Taste. Fresh Place. Enjoy the New Ruby Tuesday. | | |
| Ruby Annotation | | |
| Ruby Falls | | |
Scenario: Following the first link | |
Given I searched for "Ruby" | |
When I follow "Ruby - Wikipedia, the free encyclopedia" | |
Then I should be on "http://en.wikipedia.org/wiki/Ruby" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given /^I am on the home page$/ do | |
visit "/" | |
end | |
Given /^I searched for "([^\"]*)"$/ do |search_term| | |
Given %{I am on the home page} | |
When %{I search for "#{search_term}"} | |
end | |
When /^I search for "([^\"]*)"$/ do |search_term| | |
fill_in 'p', :with => search_term | |
click_button 'Web Search' | |
end | |
When /^I follow "([^\"]*)"$/ do |link_text| | |
click_link link_text | |
end | |
Then /^I should see the following results:$/ do |table| | |
titles = table.hashes.map {|h| h['Title'] } | |
results = all("//h3/a[contains(@class, 'yschttl')]").map {|l| l.text } | |
results.should == titles | |
end | |
Then /^I should be on "([^\"]*)"$/ do |url| | |
current_url.should == url | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment