1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/features/step_definitions/factory_girl_steps.rb
Prem Sichanugrist 40fc48d488 Fix FactoryGirl naming convention
So now, we'll always refer to this Gem as FactoryGirl, regardless of
context. This commit is to make it consistence throughout the code base.
2012-07-14 09:22:36 -04:00

43 lines
1.2 KiB
Ruby

module FactoryGirlDefinitionsHelper
def append_file_to_factory_girl_definitions_path(path_to_file)
FactoryGirl.definition_file_paths ||= []
FactoryGirl.definition_file_paths << path_to_file
end
end
World(FactoryGirlDefinitionsHelper)
When /^"([^"]*)" is added to FactoryGirl's file definitions path$/ do |file_name|
new_factory_file = File.join(current_dir, file_name.gsub(".rb", ""))
append_file_to_factory_girl_definitions_path(new_factory_file)
step %{I find definitions}
end
When /^"([^"]*)" is added to FactoryGirl's file definitions path as an absolute path$/ do |file_name|
new_factory_file = File.expand_path(File.join(current_dir, file_name.gsub(".rb", "")))
append_file_to_factory_girl_definitions_path(new_factory_file)
step %{I find definitions}
end
When /^I create a "([^"]*)" instance from FactoryGirl$/ 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)
step %{the following person exists:}, new_table
end
When /^I find definitions$/ do
FactoryGirl.find_definitions
end
When /^I reload factories$/ do
FactoryGirl.reload
end