Skip to content

Commit

Permalink
More refactoring and renamed helper, step modified to reflect change
Browse files Browse the repository at this point in the history
  • Loading branch information
baphled committed Jul 22, 2010
1 parent 8c847f9 commit 84ea41e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion features/step_definitions/general_steps.rb
@@ -1,5 +1,5 @@
Given /^the "([^\"]*)" has ([^\"]*) "([^\"]*)"$/ do |model, amount, assoc|
build_associations model, assoc, amount
build_associations_by_amount amount, model, assoc
end

Then /^a flash message '(.*)' should be displayed$/ do |message|
Expand Down
4 changes: 1 addition & 3 deletions features/step_definitions/pagination_steps.rb
@@ -1,7 +1,5 @@
Given /^there are "([^\"]*)"$/ do |model|
models = []
3.times { models << model.capitalize.singularize.constantize.make }
model.capitalize.singularize.constantize.stub!(:all).and_return models
build_model_by_amount 3, model
model.capitalize.singularize.constantize.all.should_not be_empty
end

Expand Down
9 changes: 8 additions & 1 deletion features/support/env.rb
Expand Up @@ -94,7 +94,7 @@ def fill_in_form_with_duplicate_data form_name

module AssociationsHelper

def build_associations model, assoc, amount
def build_associations_by_amount amount, model, assoc
associated = []
amount = amount.to_i
associate = assoc.capitalize.singularize.constantize
Expand All @@ -112,7 +112,14 @@ def build_associations model, assoc, amount
"Now, go and add a mapping in #{__FILE__}"
end
end

def build_model_by_amount amount, model
models = []
amount.times { models << model.capitalize.singularize.constantize.make }
model.capitalize.singularize.constantize.stub!(:all).and_return models
end
end

World(Spec::Mocks::ExampleMethods, FormHelpers, AssociationsHelper)

Before do
Expand Down

0 comments on commit 84ea41e

Please sign in to comment.