mirror of
https://github.com/thoughtbot/factory_bot_rails.git
synced 2022-11-09 11:49:18 -05:00
50 lines
1.6 KiB
Ruby
50 lines
1.6 KiB
Ruby
When /^I add "([^"]+)" from this project as a dependency$/ do |gem_name|
|
|
append_to_file('Gemfile', %{gem "#{gem_name}", :path => "#{PROJECT_ROOT}"\n})
|
|
end
|
|
|
|
When /^I add "([^"]+)" as a dependency$/ do |gem_name|
|
|
append_to_file('Gemfile', %{gem "#{gem_name}"\n})
|
|
end
|
|
|
|
When /^I set the FactoryGirl :suffix option to "([^"]+)"$/ do |suffix|
|
|
append_to_file('config/application.rb', <<-RUBY)
|
|
module Testapp
|
|
class Application < Rails::Application
|
|
config.generators do |g|
|
|
g.fixture_replacement :factory_girl, :suffix => '#{suffix}'
|
|
end
|
|
end
|
|
end
|
|
RUBY
|
|
|
|
end
|
|
|
|
When /^I configure the factories directory as "([^"]+)"$/ do |factory_dir|
|
|
append_to_file File.join('config', 'application.rb'), <<-END
|
|
class Testapp::Application
|
|
config.generators do |g|
|
|
g.fixture_replacement :factory_girl, :dir => "#{factory_dir}"
|
|
end
|
|
end
|
|
END
|
|
end
|
|
|
|
When /^I configure the testing framework to use MiniTest$/ do
|
|
append_to_file('Gemfile', %{gem "minitest-rails", :group => [:development, :test]\n})
|
|
step %{I successfully run `rails generate mini_test:install`}
|
|
|
|
append_to_file File.join('config', 'application.rb'), <<-END
|
|
class Testapp::Application
|
|
config.generators do |g|
|
|
g.test_framework :mini_test, :fixture => false, :fixture_replacement => :factory_girl
|
|
end
|
|
end
|
|
END
|
|
end
|
|
|
|
When /^I configure the database connection for the application$/ do
|
|
if RUBY_PLATFORM =~ /java/
|
|
contents = File.read File.join(File.dirname(__FILE__), '..', '..', 'tmp', 'aruba', 'testapp', 'config', 'database.yml')
|
|
overwrite_file 'config/database.yml', contents.gsub('adapter: sqlite3', 'adapter: jdbcsqlite3')
|
|
end
|
|
end
|