voyage 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +11 -0
  5. data/CONTRIBUTING.md +54 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +21 -0
  8. data/NEWS.md +510 -0
  9. data/README.md +233 -0
  10. data/RELEASING.md +19 -0
  11. data/Rakefile +8 -0
  12. data/USAGE +13 -0
  13. data/bin/rake +16 -0
  14. data/bin/rspec +16 -0
  15. data/bin/setup +13 -0
  16. data/bin/suspenders +23 -0
  17. data/bin/voyage +20 -0
  18. data/lib/suspenders.rb +6 -0
  19. data/lib/suspenders/actions.rb +33 -0
  20. data/lib/suspenders/adapters/heroku.rb +127 -0
  21. data/lib/suspenders/app_builder.rb +486 -0
  22. data/lib/suspenders/generators/app_generator.rb +287 -0
  23. data/lib/suspenders/generators/static_generator.rb +9 -0
  24. data/lib/suspenders/version.rb +8 -0
  25. data/lib/voyage.rb +9 -0
  26. data/lib/voyage/app_builder.rb +469 -0
  27. data/lib/voyage/generators/app_generator.rb +118 -0
  28. data/lib/voyage/templates/Gemfile.erb +118 -0
  29. data/lib/voyage/templates/README.md.erb +28 -0
  30. data/lib/voyage/templates/about.html.erb +1 -0
  31. data/lib/voyage/templates/application.js +19 -0
  32. data/lib/voyage/templates/config_locales_en.yml.erb +25 -0
  33. data/lib/voyage/templates/controller_helpers.rb +14 -0
  34. data/lib/voyage/templates/custom_cancan_matchers.rb +54 -0
  35. data/lib/voyage/templates/rails_helper.rb.erb +99 -0
  36. data/lib/voyage/templates/seeder.rb.erb +46 -0
  37. data/lib/voyage/templates/seeds.rb.erb +50 -0
  38. data/lib/voyage/templates/simplecov.rb +31 -0
  39. data/lib/voyage/templates/users_index.html.slim.erb +25 -0
  40. data/lib/voyage/templates/welcome.html.erb +11 -0
  41. data/lib/voyage/version.rb +8 -0
  42. data/spec/adapters/heroku_spec.rb +57 -0
  43. data/spec/fakes/bin/heroku +5 -0
  44. data/spec/fakes/bin/hub +5 -0
  45. data/spec/features/cli_help_spec.rb +36 -0
  46. data/spec/features/github_spec.rb +16 -0
  47. data/spec/features/heroku_spec.rb +75 -0
  48. data/spec/features/new_project_spec.rb +270 -0
  49. data/spec/spec_helper.rb +20 -0
  50. data/spec/support/fake_github.rb +21 -0
  51. data/spec/support/fake_heroku.rb +53 -0
  52. data/spec/support/suspenders.rb +83 -0
  53. data/suspenders.gemspec +34 -0
  54. data/templates/Gemfile.erb +64 -0
  55. data/templates/Procfile +2 -0
  56. data/templates/README.md.erb +28 -0
  57. data/templates/_analytics.html.erb +7 -0
  58. data/templates/_css_overrides.html.erb +7 -0
  59. data/templates/_flashes.html.erb +7 -0
  60. data/templates/_javascript.html.erb +12 -0
  61. data/templates/action_mailer.rb +5 -0
  62. data/templates/app.json.erb +42 -0
  63. data/templates/application.scss +9 -0
  64. data/templates/bin_deploy +12 -0
  65. data/templates/bin_setup +21 -0
  66. data/templates/bin_setup_review_app.erb +19 -0
  67. data/templates/browserslist +3 -0
  68. data/templates/bundler_audit.rake +12 -0
  69. data/templates/capybara_webkit.rb +5 -0
  70. data/templates/circle.yml.erb +6 -0
  71. data/templates/config_locales_en.yml.erb +19 -0
  72. data/templates/database_cleaner_rspec.rb +21 -0
  73. data/templates/dev.rake +12 -0
  74. data/templates/dotfiles/.ctags +2 -0
  75. data/templates/dotfiles/.env +13 -0
  76. data/templates/errors.rb +34 -0
  77. data/templates/factories.rb +2 -0
  78. data/templates/factory_girl_rspec.rb +3 -0
  79. data/templates/flashes_helper.rb +5 -0
  80. data/templates/hound.yml +14 -0
  81. data/templates/i18n.rb +3 -0
  82. data/templates/json_encoding.rb +1 -0
  83. data/templates/postgresql_database.yml.erb +21 -0
  84. data/templates/puma.rb +28 -0
  85. data/templates/rack_mini_profiler.rb +5 -0
  86. data/templates/rails_helper.rb +22 -0
  87. data/templates/secrets.yml +14 -0
  88. data/templates/shoulda_matchers_config_rspec.rb +6 -0
  89. data/templates/smtp.rb +13 -0
  90. data/templates/spec_helper.rb +29 -0
  91. data/templates/suspenders_gitignore +13 -0
  92. data/templates/suspenders_layout.html.erb.erb +22 -0
  93. metadata +207 -0
@@ -0,0 +1,46 @@
1
+ module Seeder
2
+ extend self
3
+ <% if config[:using_devise] %>
4
+ def admin_user
5
+ puts '-----> Creating Admin User'
6
+
7
+ # Remove all admins
8
+ User.admins.destroy_all
9
+
10
+ create(:user, :admin)
11
+ end
12
+
13
+ def all_users
14
+ puts '-----> Resetting to a clean user list with all Users'
15
+
16
+ # Remove all users
17
+ User.destroy_all
18
+
19
+ # list user traits from factory_girl here
20
+ %w(admin another_role).each do |name|
21
+ create(:user, name.to_sym)
22
+ end
23
+ end
24
+ <% else %>
25
+ # Change 'resource' to something real
26
+ def seed_resource
27
+ puts '-----> Creating Resource'
28
+
29
+ # Remove all resources
30
+ Resource.destroy_all
31
+
32
+ create(:resource)
33
+ end
34
+ <% end %>
35
+ end
36
+
37
+ if Rails.env == 'production'
38
+ unless ENV['FORCE_SEED']
39
+ puts
40
+ puts '================================================================================='
41
+ puts 'WARNING: You are trying to run db:seed on production. This is a DESTRUCTIVE task.'
42
+ puts 'If you know what you are doing, you can override by setting environment variable '
43
+ puts 'FORCE_SEED=1'
44
+ exit 1
45
+ end
46
+ end
@@ -0,0 +1,50 @@
1
+ require 'faker'
2
+ require 'factory_girl_rails'
3
+ include FactoryGirl::Syntax::Methods
4
+
5
+ # This file should contain all the record creation needed to seed the database
6
+ # with its default values. The data can then be loaded with the rake db:seed
7
+ # (or created alongside the db with db:setup).
8
+ #
9
+ # For the seeded attribute values, see factories.rb
10
+
11
+ puts
12
+ puts 'Seeding the database...'
13
+ puts
14
+
15
+ dev_tables_to_seed =
16
+ %w(
17
+ <%= config[:using_devise] ? 'admin_user' : 'factory_name' %>
18
+ )
19
+
20
+ production_tables_to_seed =
21
+ %w(
22
+ <%= config[:using_devise] ? 'admin_user' : 'factory_name' %>
23
+ )
24
+
25
+ test_tables_to_seed = %w()
26
+
27
+ if ENV['TABLES'].present?
28
+ # Allow overriding which tables we seed if the TABLES env var is present
29
+ tables = ENV['TABLES'].to_s.split(',')
30
+ else
31
+ # Load the tables specified based on the environment
32
+ tables =
33
+ case Rails.env
34
+ when 'production'
35
+ production_tables_to_seed
36
+ when 'staging', 'development'
37
+ dev_tables_to_seed
38
+ when 'test'
39
+ test_tables_to_seed
40
+ else
41
+ message = 'Error: Rails environment not found. Please check seeds.rb.'
42
+ fail StandardError.new, message: message
43
+ end
44
+ end
45
+
46
+ # raise StandardError.new, message: 'No Tables Specified' if tables.blank?
47
+
48
+ tables.each do |table_name|
49
+ eval("Seeder.#{table_name}")
50
+ end
@@ -0,0 +1,31 @@
1
+ if ENV['COVERAGE'] =~ /\Atrue\z/i
2
+ require 'cadre/simplecov'
3
+
4
+ SimpleCov.start do
5
+ add_filter '/.bundle/'
6
+ add_filter '/spec/'
7
+ add_filter '/config/'
8
+ add_group 'Controllers', 'app/controllers'
9
+ add_group 'Helpers', 'app/helpers'
10
+ add_group 'Mailers', 'app/mailers'
11
+ add_group 'Models', 'app/models'
12
+ add_group 'Serializers', 'app/serializers'
13
+ add_group 'Services', 'app/services'
14
+ add_group 'Workers', 'app/workers'
15
+ add_group 'Libraries', 'lib'
16
+ add_group 'Long Files' do |src_file|
17
+ src_file.lines.count > 300
18
+ end
19
+ add_group 'Ignored Code' do |src_file|
20
+ File.readlines(src_file.filename).grep(/:nocov:/).any?
21
+ end
22
+ end
23
+
24
+ SimpleCov.formatters = [
25
+ SimpleCov::Formatter::HTMLFormatter,
26
+ Cadre::SimpleCov::VimFormatter
27
+ ]
28
+
29
+ SimpleCov.minimum_coverage 95
30
+ SimpleCov.command_name 'Rspec'
31
+ end
@@ -0,0 +1,25 @@
1
+ h1 Listing Users
2
+
3
+ table
4
+ thead
5
+ tr<% if config[:adding_first_and_last_name] %>
6
+ th First Name
7
+ th Last Name<% end %>
8
+ th Email
9
+ th
10
+ th
11
+ th
12
+
13
+ tbody
14
+ - @users.each do |user|
15
+ tr<% if config[:adding_first_and_last_name] %>
16
+ td= user.first_name
17
+ td= user.last_name<% end %>
18
+ td= user.email
19
+ td= link_to 'Show', user
20
+ td= link_to 'Edit', edit_user_path(user)
21
+ td= link_to 'Destroy', user, data: { confirm: 'Are you sure?' }, method: :delete
22
+
23
+ br
24
+
25
+ = link_to 'New User', signup_path
@@ -0,0 +1,11 @@
1
+ <h1>Welcome to Voyage!</h1>
2
+
3
+ <pre>
4
+ __
5
+ \ \___ .__
6
+ .--""___\..--"/
7
+ .__.|-"""..... ' /
8
+ ________\_______________/_________
9
+ </pre>
10
+
11
+ <%%= Redcarpet::Markdown.new(Redcarpet::Render::HTML.new).render(File.read('README.md')).html_safe %>
@@ -0,0 +1,8 @@
1
+ module Voyage
2
+ RAILS_VERSION = "~> 4.2".freeze
3
+ RUBY_VERSION = IO.
4
+ read("#{File.dirname(__FILE__)}/../../.ruby-version").
5
+ strip.
6
+ freeze
7
+ VERSION = '1.0'.freeze
8
+ end
@@ -0,0 +1,57 @@
1
+ require "spec_helper"
2
+
3
+ module Suspenders
4
+ module Adapters
5
+ RSpec.describe Heroku do
6
+ it "sets the heroku remotes" do
7
+ setup_file = "bin/setup"
8
+ app_builder = double(app_name: app_name)
9
+ allow(app_builder).to receive(:append_file)
10
+
11
+ Heroku.new(app_builder).set_heroku_remotes
12
+
13
+ expect(app_builder).to have_received(:append_file).
14
+ with(setup_file, /heroku join --app #{app_name.dasherize}-production/)
15
+ expect(app_builder).to have_received(:append_file).
16
+ with(setup_file, /heroku join --app #{app_name.dasherize}-staging/)
17
+ end
18
+
19
+ it "sets the heroku rails secrets" do
20
+ app_builder = double(app_name: app_name)
21
+ allow(app_builder).to receive(:run)
22
+
23
+ Heroku.new(app_builder).set_heroku_rails_secrets
24
+
25
+ expect(app_builder).to(
26
+ have_configured_var("staging", "SECRET_KEY_BASE"),
27
+ )
28
+ expect(app_builder).to(
29
+ have_configured_var("production", "SECRET_KEY_BASE"),
30
+ )
31
+ end
32
+
33
+ it "sets the application host" do
34
+ app_builder = double(app_name: app_name)
35
+ allow(app_builder).to receive(:run)
36
+
37
+ Heroku.new(app_builder).set_heroku_application_host
38
+
39
+ expect(app_builder).to(
40
+ have_configured_var("staging", "APPLICATION_HOST"),
41
+ )
42
+
43
+ expect(app_builder).to(
44
+ have_configured_var("production", "APPLICATION_HOST"),
45
+ )
46
+ end
47
+
48
+ def app_name
49
+ SuspendersTestHelpers::APP_NAME
50
+ end
51
+
52
+ def have_configured_var(remote_name, var)
53
+ have_received(:run).with(/config:add #{var}=.+ --remote #{remote_name}/)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', '..', 'support', 'fake_heroku'), File.dirname(__FILE__))
4
+
5
+ FakeHeroku.new(ARGV).run!
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', '..', 'support', 'fake_github'), File.dirname(__FILE__))
4
+
5
+ FakeGithub.new(ARGV).run!
@@ -0,0 +1,36 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Command line help output" do
4
+ let(:help_text) { suspenders_help_command }
5
+
6
+ it "does not contain the default rails usage statement" do
7
+ expect(help_text).not_to include("rails new APP_PATH [options]")
8
+ end
9
+
10
+ it "provides the correct usage statement for suspenders" do
11
+ expect(help_text).to include <<~EOH
12
+ Usage:
13
+ suspenders APP_PATH [options]
14
+ EOH
15
+ end
16
+
17
+ it "does not contain the default rails group" do
18
+ expect(help_text).not_to include("Rails options:")
19
+ end
20
+
21
+ it "provides help and version usage within the suspenders group" do
22
+ expect(help_text).to include <<~EOH
23
+ Suspenders options:
24
+ -h, [--help], [--no-help] # Show this help message and quit
25
+ -v, [--version], [--no-version] # Show Suspenders version number and quit
26
+ EOH
27
+ end
28
+
29
+ it "does not show the default extended rails help section" do
30
+ expect(help_text).not_to include("Create suspenders files for app generator.")
31
+ end
32
+
33
+ it "contains the usage statement from the suspenders gem" do
34
+ expect(help_text).to include IO.read(usage_file)
35
+ end
36
+ end
@@ -0,0 +1,16 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "GitHub" do
4
+ before do
5
+ drop_dummy_database
6
+ remove_project_directory
7
+ end
8
+
9
+ it "suspends a project with --github option" do
10
+ repo_name = 'test'
11
+ run_suspenders("--github=#{repo_name}")
12
+ setup_app_dependencies
13
+
14
+ expect(FakeGithub).to have_created_repo(repo_name)
15
+ end
16
+ end
@@ -0,0 +1,75 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Heroku" do
4
+ context "--heroku" do
5
+ before(:all) do
6
+ clean_up
7
+ run_suspenders("--heroku=true")
8
+ setup_app_dependencies
9
+ end
10
+
11
+ it "suspends a project for Heroku" do
12
+ app_name = SuspendersTestHelpers::APP_NAME.dasherize
13
+
14
+ expect(FakeHeroku).to have_created_app_for("staging")
15
+ expect(FakeHeroku).to have_created_app_for("production")
16
+ expect(FakeHeroku).to have_configured_vars("staging", "SECRET_KEY_BASE")
17
+ expect(FakeHeroku).to have_configured_vars(
18
+ "production",
19
+ "SECRET_KEY_BASE",
20
+ )
21
+ expect(FakeHeroku).to have_configured_vars(
22
+ "staging",
23
+ "APPLICATION_HOST",
24
+ )
25
+ expect(FakeHeroku).to have_configured_vars(
26
+ "production",
27
+ "APPLICATION_HOST",
28
+ )
29
+ expect(FakeHeroku).to have_setup_pipeline_for(app_name)
30
+
31
+ bin_setup_path = "#{project_path}/bin/setup"
32
+ bin_setup = IO.read(bin_setup_path)
33
+
34
+ expect(bin_setup).to include("heroku join --app #{app_name}-production")
35
+ expect(bin_setup).to include("heroku join --app #{app_name}-staging")
36
+ expect(bin_setup).to include("git config heroku.remote staging")
37
+ expect(File.stat(bin_setup_path)).to be_executable
38
+
39
+ readme = IO.read("#{project_path}/README.md")
40
+
41
+ expect(readme).to include("./bin/deploy staging")
42
+ expect(readme).to include("./bin/deploy production")
43
+
44
+ circle_yml_path = "#{project_path}/circle.yml"
45
+ circle_yml = IO.read(circle_yml_path)
46
+
47
+ expect(circle_yml).to include <<-YML.strip_heredoc
48
+ deployment:
49
+ staging:
50
+ branch: master
51
+ commands:
52
+ - bin/deploy staging
53
+ YML
54
+ end
55
+ end
56
+
57
+ context "--heroku with region flag" do
58
+ before(:all) do
59
+ clean_up
60
+ run_suspenders(%{--heroku=true --heroku-flags="--region eu"})
61
+ setup_app_dependencies
62
+ end
63
+
64
+ it "suspends a project with extra Heroku flags" do
65
+ expect(FakeHeroku).to have_created_app_for("staging", "--region eu")
66
+ expect(FakeHeroku).to have_created_app_for("production", "--region eu")
67
+ end
68
+ end
69
+
70
+ def clean_up
71
+ drop_dummy_database
72
+ remove_project_directory
73
+ FakeHeroku.clear!
74
+ end
75
+ end
@@ -0,0 +1,270 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Suspend a new project with default configuration" do
4
+ before(:all) do
5
+ drop_dummy_database
6
+ remove_project_directory
7
+ run_suspenders
8
+ setup_app_dependencies
9
+ end
10
+
11
+ it "uses custom Gemfile" do
12
+ gemfile_file = IO.read("#{project_path}/Gemfile")
13
+ expect(gemfile_file).to match(
14
+ /^ruby "#{Suspenders::RUBY_VERSION}"$/,
15
+ )
16
+ expect(gemfile_file).to match(
17
+ /^gem "autoprefixer-rails"$/,
18
+ )
19
+ expect(gemfile_file).to match(
20
+ /^gem "rails", "#{Suspenders::RAILS_VERSION}"$/,
21
+ )
22
+ end
23
+
24
+ it "ensures project specs pass" do
25
+ Dir.chdir(project_path) do
26
+ Bundler.with_clean_env do
27
+ expect(`rake`).to include('0 failures')
28
+ end
29
+ end
30
+ end
31
+
32
+ it "creates .ruby-version from Suspenders .ruby-version" do
33
+ ruby_version_file = IO.read("#{project_path}/.ruby-version")
34
+
35
+ expect(ruby_version_file).to eq "#{RUBY_VERSION}\n"
36
+ end
37
+
38
+ it "copies dotfiles" do
39
+ %w[.ctags .env].each do |dotfile|
40
+ expect(File).to exist("#{project_path}/#{dotfile}")
41
+ end
42
+ end
43
+
44
+ it "loads secret_key_base from env" do
45
+ secrets_file = IO.read("#{project_path}/config/secrets.yml")
46
+
47
+ expect(secrets_file).to match(/secret_key_base: <%= ENV\["SECRET_KEY_BASE"\] %>/)
48
+ end
49
+
50
+ it "adds bin/setup file" do
51
+ expect(File).to exist("#{project_path}/bin/setup")
52
+ end
53
+
54
+ it "makes bin/setup executable" do
55
+ bin_setup_path = "#{project_path}/bin/setup"
56
+
57
+ expect(File.stat(bin_setup_path)).to be_executable
58
+ end
59
+
60
+ it "adds support file for action mailer" do
61
+ expect(File).to exist("#{project_path}/spec/support/action_mailer.rb")
62
+ end
63
+
64
+ it "configures capybara-webkit" do
65
+ expect(File).to exist("#{project_path}/spec/support/capybara_webkit.rb")
66
+ end
67
+
68
+ it "adds support file for i18n" do
69
+ expect(File).to exist("#{project_path}/spec/support/i18n.rb")
70
+ end
71
+
72
+ it "creates good default .hound.yml" do
73
+ hound_config_file = IO.read("#{project_path}/.hound.yml")
74
+
75
+ expect(hound_config_file).to include "enabled: true"
76
+ end
77
+
78
+ it "ensures Gemfile contains `rack-mini-profiler`" do
79
+ gemfile = IO.read("#{project_path}/Gemfile")
80
+
81
+ expect(gemfile).to include %{gem "rack-mini-profiler", require: false}
82
+ end
83
+
84
+ it "ensures .sample.env defaults to RACK_MINI_PROFILER=0" do
85
+ env = IO.read("#{project_path}/.env")
86
+
87
+ expect(env).to include "RACK_MINI_PROFILER=0"
88
+ end
89
+
90
+ it "creates a rack-mini-profiler initializer" do
91
+ expect(File).
92
+ to exist("#{project_path}/config/initializers/rack_mini_profiler.rb")
93
+ end
94
+
95
+ it "records pageviews through Segment if ENV variable set" do
96
+ expect(analytics_partial).
97
+ to include(%{<% if ENV["SEGMENT_KEY"] %>})
98
+ expect(analytics_partial).
99
+ to include(%{window.analytics.load("<%= ENV["SEGMENT_KEY"] %>");})
100
+ end
101
+
102
+ it "raises on unpermitted parameters in all environments" do
103
+ result = IO.read("#{project_path}/config/application.rb")
104
+
105
+ expect(result).to match(
106
+ /^ +config.action_controller.action_on_unpermitted_parameters = :raise$/
107
+ )
108
+ end
109
+
110
+ it "adds explicit quiet_assets configuration" do
111
+ result = IO.read("#{project_path}/config/application.rb")
112
+
113
+ expect(result).to match(
114
+ /^ +config.quiet_assets = true$/
115
+ )
116
+ end
117
+
118
+ it "configures static_cache_control in production" do
119
+ prod_env_file = IO.read("#{project_path}/config/environments/production.rb")
120
+ expect(prod_env_file).to match(
121
+ /config.static_cache_control = "public, max-age=.+"/,
122
+ )
123
+ end
124
+
125
+ it "raises on missing translations in development and test" do
126
+ %w[development test].each do |environment|
127
+ environment_file =
128
+ IO.read("#{project_path}/config/environments/#{environment}.rb")
129
+ expect(environment_file).to match(
130
+ /^ +config.action_view.raise_on_missing_translations = true$/
131
+ )
132
+ end
133
+ end
134
+
135
+ it "evaluates en.yml.erb" do
136
+ locales_en_file = IO.read("#{project_path}/config/locales/en.yml")
137
+
138
+ expect(locales_en_file).to match(/application: #{app_name.humanize}/)
139
+ end
140
+
141
+ it "configs simple_form" do
142
+ expect(File).to exist("#{project_path}/config/initializers/simple_form.rb")
143
+ end
144
+
145
+ it "configs :test email delivery method for development" do
146
+ dev_env_file = IO.read("#{project_path}/config/environments/development.rb")
147
+ expect(dev_env_file).
148
+ to match(/^ +config.action_mailer.delivery_method = :file$/)
149
+ end
150
+
151
+ it "uses APPLICATION_HOST, not HOST in the production config" do
152
+ prod_env_file = IO.read("#{project_path}/config/environments/production.rb")
153
+ expect(prod_env_file).to match(/"APPLICATION_HOST"/)
154
+ expect(prod_env_file).not_to match(/"HOST"/)
155
+ end
156
+
157
+ it "configures email interceptor in smtp config" do
158
+ smtp_file = IO.read("#{project_path}/config/smtp.rb")
159
+ expect(smtp_file).
160
+ to match(/RecipientInterceptor.new\(ENV\["EMAIL_RECIPIENTS"\]\)/)
161
+ end
162
+
163
+ it "configures language in html element" do
164
+ layout_path = "/app/views/layouts/application.html.erb"
165
+ layout_file = IO.read("#{project_path}#{layout_path}")
166
+ expect(layout_file).to match(/<html lang="en">/)
167
+ end
168
+
169
+ it "configs active job queue adapter" do
170
+ application_config = IO.read("#{project_path}/config/application.rb")
171
+ test_config = IO.read("#{project_path}/config/environments/test.rb")
172
+
173
+ expect(application_config).to match(
174
+ /^ +config.active_job.queue_adapter = :delayed_job$/
175
+ )
176
+ expect(test_config).to match(
177
+ /^ +config.active_job.queue_adapter = :inline$/
178
+ )
179
+ end
180
+
181
+ it "configs bullet gem in development" do
182
+ test_config = IO.read("#{project_path}/config/environments/development.rb")
183
+
184
+ expect(test_config).to match /^ +Bullet.enable = true$/
185
+ expect(test_config).to match /^ +Bullet.bullet_logger = true$/
186
+ expect(test_config).to match /^ +Bullet.rails_logger = true$/
187
+ end
188
+
189
+ it "configs missing assets to raise in test" do
190
+ test_config = IO.read("#{project_path}/config/environments/test.rb")
191
+
192
+ expect(test_config).to match(
193
+ /^ +config.assets.raise_runtime_errors = true$/,
194
+ )
195
+ end
196
+
197
+ it "adds spring to binstubs" do
198
+ expect(File).to exist("#{project_path}/bin/spring")
199
+
200
+ bin_stubs = %w(rake rails rspec)
201
+ bin_stubs.each do |bin_stub|
202
+ expect(IO.read("#{project_path}/bin/#{bin_stub}")).to match(/spring/)
203
+ end
204
+ end
205
+
206
+ it "removes comments and extra newlines from config files" do
207
+ config_files = [
208
+ IO.read("#{project_path}/config/application.rb"),
209
+ IO.read("#{project_path}/config/environment.rb"),
210
+ IO.read("#{project_path}/config/environments/development.rb"),
211
+ IO.read("#{project_path}/config/environments/production.rb"),
212
+ IO.read("#{project_path}/config/environments/test.rb"),
213
+ ]
214
+
215
+ config_files.each do |file|
216
+ expect(file).not_to match(/.*#.*/)
217
+ expect(file).not_to match(/^$\n/)
218
+ end
219
+ end
220
+
221
+ it "copies factories.rb" do
222
+ expect(File).to exist("#{project_path}/spec/factories.rb")
223
+ end
224
+
225
+ it "creates review apps setup script" do
226
+ bin_setup_path = "#{project_path}/bin/setup_review_app"
227
+ bin_setup = IO.read(bin_setup_path)
228
+
229
+ expect(bin_setup).to include("heroku run rake db:migrate --exit-code "\
230
+ "--app #{app_name.dasherize}-staging-pr-$1")
231
+ expect(bin_setup).to include("heroku ps:scale worker=1 "\
232
+ "--app #{app_name.dasherize}-staging-pr-$1")
233
+ expect(bin_setup).to include("heroku restart "\
234
+ "--app #{app_name.dasherize}-staging-pr-$1")
235
+ expect(File.stat(bin_setup_path)).to be_executable
236
+ end
237
+
238
+ it "creates deploy script" do
239
+ bin_deploy_path = "#{project_path}/bin/deploy"
240
+ bin_deploy = IO.read(bin_deploy_path)
241
+
242
+ expect(bin_deploy).to include("heroku run rake db:migrate --exit-code")
243
+ expect(File.stat(bin_deploy_path)).to be_executable
244
+ end
245
+
246
+ it "creates heroku application manifest file with application name in it" do
247
+ app_json_file = IO.read("#{project_path}/app.json")
248
+
249
+ expect(app_json_file).to match(/"name":"#{app_name.dasherize}"/)
250
+ end
251
+
252
+ it "sets up heroku specific gems" do
253
+ gemfile_file = IO.read("#{project_path}/Gemfile")
254
+
255
+ expect(gemfile_file).to include %{gem "rails_stdout_logging"}
256
+ end
257
+
258
+ def app_name
259
+ SuspendersTestHelpers::APP_NAME
260
+ end
261
+
262
+ it "adds high_voltage" do
263
+ gemfile = IO.read("#{project_path}/Gemfile")
264
+ expect(gemfile).to match(/high_voltage/)
265
+ end
266
+
267
+ def analytics_partial
268
+ IO.read("#{project_path}/app/views/application/_analytics.html.erb")
269
+ end
270
+ end