Skip to content

Instantly share code, notes, and snippets.

@chrismdp
Created September 16, 2011 10:41
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 chrismdp/1221825 to your computer and use it in GitHub Desktop.
Save chrismdp/1221825 to your computer and use it in GitHub Desktop.
Given /^an employee called "([^"]+)"$/ do |employee_name|
create_employee(employee_name)
end
Then /^I should be able to pay "([^"]+)" his salary$/ do |employee_name|
pay_salary_to(employee_)
end
Feature: Paul pays employees
In order to retain staff
As Paul the Payroll Manager I want to pay my staff
Scenario:
Given an admin user called "Paul" with a password "password"
And a user called "Bob"
And "Bob" is an employee
And "Bob" gets paid "$2,000" a month
When I visit the homepage
And I click on "Log in"
And I fill in "username" with "Paul"
And I fill in "password" with "password"
And I click "Log in"
And I click "Payroll"
And I click "Bob"
And I click "Pay"
And I enter "$2,000"
And I click "Pay"
Then I should see "Bob has been paid"
Feature: Paul pays employees
In order to retain staff
As Paul the Payroll Manager I want to pay my staff
@paul_signed_in
Scenario:
Given an employee called "Bob"
Then I should be able to pay "Bob" his salary
Before("@paul_signed_in") do
paul = create_employee("Paul")
paul.assign_role("payroll")
sign_in_as(paul)
end
def create_employee(name)
Employee.create!(:name => name, :username => name,
:password => "password")
end
def pay_salary_to(name)
payee = Employee.find_by_name(name)
visit payroll_employee_path(payee)
fill_ :salary, :with => payee.salary
click_button "Pay"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment