require "spec_helper" RSpec.describe "Suspend a new project with default configuration" do it "ensures project specs pass" do run_suspenders Dir.chdir(project_path) do Bundler.with_clean_env do expect(`rake`).to include('0 failures') end end end it "inherits staging config from production" do run_suspenders staging_file = IO.read("#{project_path}/config/environments/staging.rb") config_stub = "Rails.application.configure do" expect(staging_file).to match(/^require_relative "production"/) expect(staging_file).to match(/#{config_stub}/), staging_file end it "creates .ruby-version from Suspenders .ruby-version" do run_suspenders ruby_version_file = IO.read("#{project_path}/.ruby-version") expect(ruby_version_file).to eq "#{RUBY_VERSION}\n" end it "loads secret_key_base from env" do run_suspenders secrets_file = IO.read("#{project_path}/config/secrets.yml") expect(secrets_file).to match(/secret_key_base: <%= ENV\["SECRET_KEY_BASE"\] %>/) end it "adds support file for action mailer" do run_suspenders expect(File).to exist("#{project_path}/spec/support/action_mailer.rb") end it "adds support file for i18n" do run_suspenders expect(File).to exist("#{project_path}/spec/support/i18n.rb") end it "ensures newrelic.yml reads NewRelic license from env" do run_suspenders newrelic_file = IO.read("#{project_path}/config/newrelic.yml") expect(newrelic_file).to match( /license_key: "<%= ENV\["NEW_RELIC_LICENSE_KEY"\] %>"/ ) end it "records pageviews through Segment if ENV variable set" do run_suspenders expect(analytics_partial). to include(%{<% if ENV["SEGMENT_KEY"] %>}) expect(analytics_partial). to include(%{window.analytics.load("<%= ENV["SEGMENT_KEY"] %>");}) end it "raises on unpermitted parameters in all environments" do run_suspenders result = IO.read("#{project_path}/config/application.rb") expect(result).to match( /^ +config.action_controller.action_on_unpermitted_parameters = :raise$/ ) end it "raises on missing translations in development and test" do run_suspenders %w[development test].each do |environment| environment_file = IO.read("#{project_path}/config/environments/#{environment}.rb") expect(environment_file).to match( /^ +config.action_view.raise_on_missing_translations = true$/ ) end end it "adds specs for missing or unused translations" do run_suspenders expect(File).to exist("#{project_path}/spec/i18n_spec.rb") end it "configs i18n-tasks" do run_suspenders expect(File).to exist("#{project_path}/config/i18n-tasks.yml") end it "evaluates en.yml.erb" do run_suspenders locales_en_file = IO.read("#{project_path}/config/locales/en.yml") app_name = SuspendersTestHelpers::APP_NAME expect(locales_en_file).to match(/application: #{app_name.humanize}/) end it "configs simple_form" do run_suspenders expect(File).to exist("#{project_path}/config/initializers/simple_form.rb") end it "configs :test email delivery method for development" do run_suspenders dev_env_file = IO.read("#{project_path}/config/environments/development.rb") expect(dev_env_file). to match(/^ +config.action_mailer.delivery_method = :test$/) end it "configs active job queue adapter" do run_suspenders application_config = IO.read("#{project_path}/config/application.rb") test_config = IO.read("#{project_path}/config/environments/test.rb") expect(application_config).to match( /^ +config.active_job.queue_adapter = :sidekiq$/ ) expect(test_config).to match( /^ +config.active_job.queue_adapter = :inline$/ ) end it "adds spring to binstubs" do run_suspenders expect(File).to exist("#{project_path}/bin/spring") spring_line = /^ +load File.expand_path\("\.\.\/spring", __FILE__\)$/ bin_stubs = %w(rake rails rspec) bin_stubs.each do |bin_stub| expect(IO.read("#{project_path}/bin/#{bin_stub}")).to match(spring_line) end end def analytics_partial IO.read("#{project_path}/app/views/application/_analytics.html.erb") end end