Created
April 20, 2012 08:52
-
-
Save quad/2427199 to your computer and use it in GitHub Desktop.
RSpec vs. Cucumber
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
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 |
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 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 |
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: 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