Skip to content

Commit

Permalink
Refactored with initial factories for our tests, will need to go over…
Browse files Browse the repository at this point in the history
… all our scenarios to make sure they all pass as we expect.
  • Loading branch information
baphled committed Jul 21, 2010
1 parent 473ab30 commit d854dfc
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
4 changes: 2 additions & 2 deletions features/step_definitions/features_steps.rb
Expand Up @@ -3,7 +3,7 @@
end

Given /^there is a feature$/ do
@feature = Feature.first
@feature = Feature.make
end

Given /^the feature has stories$/ do
Expand All @@ -26,7 +26,7 @@
end

When /^there are features$/ do
assert Feature.find :all
Feature.stub(:all).and_return [Feature.make]
end

Then /^I should see a list of features$/ do
Expand Down
20 changes: 20 additions & 0 deletions features/step_definitions/general_steps.rb
@@ -1,3 +1,23 @@
Given /^the "([^\"]*)" has 5 "([^\"]*)"$/ do |model, assoc|
associated = []
case model
when /project/
5.times { associated << assoc.capitalize.singularize.constantize.make }
@project.features = associated
when /feature/
5.times { associated << assoc.capitalize.singularize.constantize.make }
@feature.stories = associated
when /story/
5.times { associated << assoc.capitalize.singularize.constantize.make }
@story.steps = associated
when //
# do nothing
else
raise "Can't instantiate \"#{model}\".\n" +
"Now, go and add a mapping in #{__FILE__}"
end
end

Then /^a flash message '(.*)' should be displayed$/ do |message|
flash[:notice].should contain "#{message}"
end
Expand Down
12 changes: 7 additions & 5 deletions features/step_definitions/projects_steps.rb
@@ -1,5 +1,5 @@
Given /^there is a project$/ do
@project = Project.first
@project = Project.make
end

Given /^there are projects$/ do
Expand All @@ -25,7 +25,7 @@

#TODO refactor so that the steps action is clearer
Given /^the project has features$/ do
@project = Project.find 2
@project.features << Feature.make
end

Given /^the project does have a project location to an invalid feature$/ do
Expand All @@ -51,11 +51,13 @@
Given /^the "([^\"]*)" has "([^\"]*)"$/ do |model, assoc|
case model
when /project/
@project = Project.find 2
@project.features << Feature.make
when /feature/
@feature = Feature.first
@feature.stories << Story.make
when /story/
@story = Story.first
@story.steps << Step.make
when //
# do nothing
else
raise "Can't instantiate \"#{model}\".\n" +
"Now, go and add a mapping in #{__FILE__}"
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/steps_steps.rb
Expand Up @@ -3,7 +3,7 @@
end

Given /^there is a step$/ do
@step = Step.first
@step = Step.make
end

Given /^there are steps$/ do
Expand Down
6 changes: 5 additions & 1 deletion features/step_definitions/stories_steps.rb
Expand Up @@ -7,7 +7,7 @@
end

Given /^there is a story$/ do
@story = Story.first
@story = Story.make
end

Given /^we have a stories with examples$/ do
Expand All @@ -17,6 +17,10 @@
@story.examples.size.should eql 1
end

Given /^it has an associated feature$/ do
@story.features << Feature.make
end

When /^I select first feature new story link$/ do
click_link 'New Story'
end
Expand Down

0 comments on commit d854dfc

Please sign in to comment.