Created
May 23, 2012 03:07
-
-
Save alisterscott/2773042 to your computer and use it in GitHub Desktop.
A watir-webdriver rspec example
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 'rspec' | |
require 'watir-webdriver' | |
browser = Watir::Browser.new | |
RSpec.configure do |config| | |
config.before(:each) { @browser = browser } | |
config.after(:suite) { browser.close unless browser.nil? } | |
end | |
describe "a simple demonstration of watir and trad RSpec" do | |
before(:each) do | |
@browser.goto("http://cukes.info/") | |
end | |
describe "that we have hit a valid URL" do | |
it "should not return an invalid error message" do | |
@browser.text.should_not include('The requested URL could not be retrieved') | |
end | |
end | |
describe "the contents of the cukes page" do # the describe() is an example group | |
it "should include aidy's name" do # the it() represents the detail that will be expressed in the code within the block | |
@browser.text.should include('Aidy Lewis') | |
end | |
it "should not include the great Nietchzche's name" do | |
@browser.text.should_not include('Frederick Nietchzche') | |
end | |
end | |
end | |
# run with | |
# rspec -c filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment