Skip to content

Instantly share code, notes, and snippets.

@andrewhavens
Created August 30, 2013 21:20
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 andrewhavens/6394386 to your computer and use it in GitHub Desktop.
Save andrewhavens/6394386 to your computer and use it in GitHub Desktop.
Cucumber example, declarative style
Feature: Widget Management
Background:
Given I am logged in as a user
Scenario: Creating a new widget
When I create a widget
Then I should see "Widget was successfully created."
Given /^I am logged in as an user/ do
@user = Fabricate(:user)
visit auth_login_path
fill_in "Username", with: @user.username
fill_in "Password", with: "password"
click_button "Log In"
end
When /^I create a widget/ do
visit root_url
click_link "New Widget"
fill_in "Name", with: "Awesome Widget"
click_button "Create Widget"
end
Then /^I (should|should not) see "(.*)"$/ do |action, text|
if action == 'should'
page.should have_content(text)
else
page.should_not have_content(text)
end
end
@andrewhavens
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment