Skip to content

Instantly share code, notes, and snippets.

@alisterscott
Created May 23, 2012 03:07
Show Gist options
  • Save alisterscott/2773042 to your computer and use it in GitHub Desktop.
Save alisterscott/2773042 to your computer and use it in GitHub Desktop.
A watir-webdriver rspec example
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