Skip to content

Instantly share code, notes, and snippets.

@chrismdp
Created September 16, 2011 10:40
Show Gist options
  • Save chrismdp/1221824 to your computer and use it in GitHub Desktop.
Save chrismdp/1221824 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
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment