Skip to content

Instantly share code, notes, and snippets.

@quad
Created April 20, 2012 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quad/2427199 to your computer and use it in GitHub Desktop.
Save quad/2427199 to your computer and use it in GitHub Desktop.
RSpec vs. Cucumber
Describe "Logging In" do
Context "Successful Login" do
before do
User.create(:username => "Scott", :password => "Tiger")
visit :login_page
on_page_with(:login_form) do |login_form|
login_form.login("Scott", "Tiger")
end
end
it "greets the user" do
on_page_with(:message) do |message|
message.should eql("Hello Scott!")
end
end
end
end
Given /^I have registered as '([^']*)' with password '([^']*)'$/ do |name, password|
User.create(:username => name, :password => password)
end
When /^I login as '([^']*)'\/'([^']*)'$/ do |user, password|
visit :login_page
on_page_with(:login_form) do |login_form|
login_form.login(user, password)
end
end
Then /^I will be greeted with "([^"]*)"$/ do |message|
on_page_with(:message) do |message|
message.should eql(expected_greeting)
end
end
Feature: Who cares?
Scenario: User is greeted upon successful login
Given I have registered as 'Scott' with password 'Tiger'
When I login as 'Scott'/'Tiger'
Then I will be greeted with "Hello Scott!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment