diff --git a/features/factory_girl_steps.feature b/features/factory_girl_steps.feature index 84e8eb9..edf6ea0 100644 --- a/features/factory_girl_steps.feature +++ b/features/factory_girl_steps.feature @@ -190,3 +190,11 @@ Feature: Use step definitions generated by factories Then I should find the following for the last user: | id | name | | 123 | Joe | + + Scenario: pass a factory girl table as an argument and modify it + Given these super users exist: + | id | Name | + | 123 | Joe | + Then I should find the following for the last user: + | id | name | admin | + | 123 | Joe | true | diff --git a/features/step_definitions/factory_girl_steps.rb b/features/step_definitions/factory_girl_steps.rb index 5bb03f0..f03c151 100644 --- a/features/step_definitions/factory_girl_steps.rb +++ b/features/step_definitions/factory_girl_steps.rb @@ -16,3 +16,10 @@ end When /^I create a "([^"]*)" instance from Factory Girl$/ do |factory_name| FactoryGirl.create(factory_name) end + +Given /^these super users exist:$/ do |table| + headers = table.headers + ["admin"] + rows = table.rows.map { |row| row + [true] } + new_table = Cucumber::Ast::Table.new([headers] + rows) + Given %{the following person exists:}, new_table +end diff --git a/lib/factory_girl/step_definitions.rb b/lib/factory_girl/step_definitions.rb index c3386bf..226e6c1 100644 --- a/lib/factory_girl/step_definitions.rb +++ b/lib/factory_girl/step_definitions.rb @@ -21,7 +21,7 @@ module FactoryGirlStepHelpers private def process_key_value(key, value) - [key.downcase.gsub(' ', '_').to_sym, value.strip] + [key.downcase.gsub(' ', '_').to_sym, value.to_s.strip] end class AssociationManager