2020-06-05 15:40:36 -04:00
|
|
|
When(/^I create a new rails application$/) do
|
2020-04-04 09:12:04 -04:00
|
|
|
options =
|
|
|
|
%w[
|
|
|
|
--api
|
|
|
|
--skip-bootsnap
|
|
|
|
--skip-javascript
|
|
|
|
--skip-action-mailer
|
|
|
|
--skip-active-storage
|
|
|
|
--skip-action-cable
|
|
|
|
--skip-sprockets
|
|
|
|
--skip-bundle
|
|
|
|
].join(" ")
|
|
|
|
|
2020-03-29 11:51:41 -04:00
|
|
|
template = "-m ../../features/support/rails_template"
|
|
|
|
result = run_command("bundle exec rails new test_app #{options} #{template}")
|
|
|
|
|
|
|
|
expect(result).to have_output(/README/)
|
|
|
|
expect(last_command_started).to be_successfully_executed
|
|
|
|
|
|
|
|
cd("test_app")
|
|
|
|
end
|
|
|
|
|
2020-06-05 15:40:36 -04:00
|
|
|
When(/^I add "([^"]+)" from this project as a dependency$/) do |gem_name|
|
|
|
|
append_to_file("Gemfile", %(gem "#{gem_name}", :path => "#{PROJECT_ROOT}"\n))
|
2011-09-08 12:30:26 -04:00
|
|
|
end
|
|
|
|
|
2020-06-05 15:40:36 -04:00
|
|
|
When(/^I add "([^"]+)" as a dependency$/) do |gem_name|
|
|
|
|
append_to_file("Gemfile", %(gem "#{gem_name}"\n))
|
2010-06-09 11:42:48 -04:00
|
|
|
end
|
2012-11-29 05:46:29 -05:00
|
|
|
|
2020-06-05 15:40:36 -04:00
|
|
|
When(/^I print out "([^"]*)"$/) do |path|
|
2014-05-26 23:39:51 -04:00
|
|
|
in_current_dir do
|
2018-09-28 15:23:52 -04:00
|
|
|
File.open(path, "r") do |f|
|
2014-05-26 23:39:51 -04:00
|
|
|
puts f.inspect
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-05 15:40:36 -04:00
|
|
|
When(/^I configure the factories as:$/) do |string|
|
2018-09-28 22:34:23 -04:00
|
|
|
append_to_file File.join("config", "application.rb"), <<~RUBY
|
2020-03-29 11:51:41 -04:00
|
|
|
class TestApp::Application
|
2018-09-28 22:34:23 -04:00
|
|
|
#{string}
|
|
|
|
end
|
2018-09-28 15:23:52 -04:00
|
|
|
RUBY
|
2013-02-05 09:04:10 -05:00
|
|
|
end
|
|
|
|
|
2020-06-05 15:40:36 -04:00
|
|
|
When(/^I configure the factories directory as "([^"]+)"$/) do |factory_dir|
|
2018-09-28 22:34:23 -04:00
|
|
|
append_to_file File.join("config", "application.rb"), <<~RUBY
|
2020-03-29 11:51:41 -04:00
|
|
|
class TestApp::Application
|
2018-09-28 22:34:23 -04:00
|
|
|
config.generators do |g|
|
|
|
|
g.fixture_replacement :factory_bot, :dir => "#{factory_dir}"
|
|
|
|
end
|
|
|
|
end
|
2018-09-28 15:23:52 -04:00
|
|
|
RUBY
|
2012-12-07 11:48:05 -05:00
|
|
|
end
|
2012-12-10 11:29:57 -05:00
|
|
|
|
2020-06-05 15:40:36 -04:00
|
|
|
When(/^I comment out gem "([^"]*)" from my Gemfile$/) do |gem_name|
|
2012-12-19 15:04:29 -05:00
|
|
|
in_current_dir do
|
2018-09-28 15:23:52 -04:00
|
|
|
content = File.read("Gemfile")
|
|
|
|
File.open("Gemfile", "w") do |f|
|
2012-12-19 15:04:29 -05:00
|
|
|
f.write content.sub(/gem ['"]#{gem_name}/, '#\1')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|