Skip to content

Commit

Permalink
Consolidate steps that create records.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewtodd committed Feb 10, 2011
1 parent 885e02b commit 98a71ef
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 71 deletions.
71 changes: 71 additions & 0 deletions features/step_definitions/blueprint_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Given /^the following children exist:$/ do |table|
table.hashes.each do |hash|
child = Child.make(:name => hash['Child'])
end
end

Given /^the following children with no headshot exist:$/ do |table|
table.hashes.each do |hash|
child = Child.make(:name => hash['Child'], :headshot => nil)
end
end

Given /^the following children with no social worker exist:$/ do |table|
table.hashes.each do |hash|
child = Child.make(:name => hash['Child'], :social_worker => nil)
end
end

Given /^the following events exist:$/ do |table|
table.hashes.each do |hash|
child = Child.find_by_name!(hash['Child'])
hash['Event'].constantize.make(
:child => child,
:happened_on => parse_date(hash['Date'])
)
child.recalculate_state!
end
end

Given /^the following users exist:$/ do |table|
table.hashes.each do |user_hash|
Caregiver.make(
:name => user_hash['Name'],
:role => user_hash['Role'].downcase.tr(' ', '_')
)
end
end

Given /^the following scheduled visits exist:$/ do |table|
table.hashes.each do |hash|
social_worker = Caregiver.find_by_name(hash['Social Worker'])
ScheduledVisit.make(
:scheduled_for => parse_date(hash['Date']),
:child => Child.make(
:name => hash['Child'],
:location => hash['Location'] || "Moshi",
:social_worker => social_worker))
end
end

Given /^the following recommended visits exist:$/ do |table|
table.hashes.each do |hash|
social_worker = Caregiver.find_by_name(hash['Social Worker'])
Child.make(
:name => hash['Child'],
:social_worker => social_worker,
:state => 'on_site')
end
end

Given /^the following non-recommended children exist:$/ do |table|
table.hashes.each do |hash|
social_worker = Caregiver.find_by_name(hash['Social Worker'])
child = Child.make(
:name => hash['Child'],
:social_worker => social_worker,
:state => 'on_site')
child.home_visits.make
end
end

18 changes: 0 additions & 18 deletions features/step_definitions/child_steps.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
Given /^the following children exist:$/ do |table|
table.hashes.each do |hash|
child = Child.make(:name => hash['Child'])
end
end

Given /^the following children with no headshot exist:$/ do |table|
table.hashes.each do |hash|
child = Child.make(:name => hash['Child'], :headshot => nil)
end
end

Given /^the following children with no social worker exist:$/ do |table|
table.hashes.each do |hash|
child = Child.make(:name => hash['Child'], :social_worker => nil)
end
end

Then /^I should see "([^\"]*)" in the new children list$/ do |name|
Then %{I should see "#{name}" within ".new-children"}
end
Expand Down
11 changes: 0 additions & 11 deletions features/step_definitions/event_steps.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
Given /^the following events exist:$/ do |table|
table.hashes.each do |hash|
child = Child.find_by_name!(hash['Child'])
hash['Event'].constantize.make(
:child => child,
:happened_on => parse_date(hash['Date'])
)
child.recalculate_state!
end
end

When /^I follow "([^\"]*)" for the event that happened on "([^\"]*)"$/ do |link, day|
selector = "tr[data-happened_on='#{parse_date(day).to_s(:db)}']"
When %{I follow "#{link}" within "#{selector}"}
Expand Down
9 changes: 0 additions & 9 deletions features/step_definitions/user_steps.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
Given /^the following users exist:$/ do |table|
table.hashes.each do |user_hash|
Caregiver.make(
:name => user_hash['Name'],
:role => user_hash['Role'].downcase.tr(' ', '_')
)
end
end

Given /^I am not signed in$/ do
visit path_to("the english dashboard")
unless current_url.ends_with?("/session/new")
Expand Down
33 changes: 0 additions & 33 deletions features/step_definitions/visit_steps.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
Given /^the following scheduled visits exist:$/ do |table|
table.hashes.each do |hash|
social_worker = Caregiver.find_by_name(hash['Social Worker'])
ScheduledVisit.make(
:scheduled_for => parse_date(hash['Date']),
:child => Child.make(
:name => hash['Child'],
:location => hash['Location'] || "Moshi",
:social_worker => social_worker))
end
end

Given /^the following recommended visits exist:$/ do |table|
table.hashes.each do |hash|
social_worker = Caregiver.find_by_name(hash['Social Worker'])
Child.make(
:name => hash['Child'],
:social_worker => social_worker,
:state => 'on_site')
end
end

Given /^the following non-recommended children exist:$/ do |table|
table.hashes.each do |hash|
social_worker = Caregiver.find_by_name(hash['Social Worker'])
child = Child.make(
:name => hash['Child'],
:social_worker => social_worker,
:state => 'on_site')
child.home_visits.make
end
end

When /^I drag "([^\"]*)" to "([^\"]*)"$/ do |child_name, date|
date = parse_date(date).to_date.to_s(:db)
source = page.find(:xpath, "//a[contains(text(),'#{child_name}')]/ancestor::li")
Expand Down

0 comments on commit 98a71ef

Please sign in to comment.