suspenders-ocs 0.0.1

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 (75) 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 +51 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +21 -0
  8. data/NEWS.md +486 -0
  9. data/README.md +233 -0
  10. data/RELEASING.md +19 -0
  11. data/Rakefile +8 -0
  12. data/bin/rake +16 -0
  13. data/bin/rspec +16 -0
  14. data/bin/setup +13 -0
  15. data/bin/suspenders +23 -0
  16. data/lib/suspenders.rb +5 -0
  17. data/lib/suspenders/actions.rb +33 -0
  18. data/lib/suspenders/adapters/heroku.rb +125 -0
  19. data/lib/suspenders/app_builder.rb +523 -0
  20. data/lib/suspenders/generators/app_generator.rb +269 -0
  21. data/lib/suspenders/version.rb +5 -0
  22. data/spec/adapters/heroku_spec.rb +52 -0
  23. data/spec/fakes/bin/heroku +5 -0
  24. data/spec/fakes/bin/hub +5 -0
  25. data/spec/features/github_spec.rb +15 -0
  26. data/spec/features/heroku_spec.rb +93 -0
  27. data/spec/features/new_project_spec.rb +234 -0
  28. data/spec/spec_helper.rb +20 -0
  29. data/spec/support/fake_github.rb +21 -0
  30. data/spec/support/fake_heroku.rb +53 -0
  31. data/spec/support/suspenders.rb +58 -0
  32. data/suspenders.gemspec +34 -0
  33. data/templates/Gemfile.erb +63 -0
  34. data/templates/Procfile +2 -0
  35. data/templates/README.md.erb +28 -0
  36. data/templates/_analytics.html.erb +7 -0
  37. data/templates/_css_overrides.html.erb +8 -0
  38. data/templates/_flashes.html.erb +7 -0
  39. data/templates/_javascript.html.erb +12 -0
  40. data/templates/action_mailer.rb +5 -0
  41. data/templates/app.json.erb +42 -0
  42. data/templates/application.scss +9 -0
  43. data/templates/bin_deploy +12 -0
  44. data/templates/bin_setup +21 -0
  45. data/templates/bin_setup_review_app.erb +19 -0
  46. data/templates/browserslist +3 -0
  47. data/templates/bundler_audit.rake +12 -0
  48. data/templates/capybara_webkit.rb +5 -0
  49. data/templates/circle.yml.erb +6 -0
  50. data/templates/config_locales_en.yml.erb +19 -0
  51. data/templates/database_cleaner_rspec.rb +21 -0
  52. data/templates/dev.rake +12 -0
  53. data/templates/disable_xml_params.rb +1 -0
  54. data/templates/dotfiles/.ctags +2 -0
  55. data/templates/dotfiles/.env +13 -0
  56. data/templates/errors.rb +34 -0
  57. data/templates/factories.rb +2 -0
  58. data/templates/factory_girl_rspec.rb +3 -0
  59. data/templates/flashes_helper.rb +5 -0
  60. data/templates/hound.yml +14 -0
  61. data/templates/i18n.rb +3 -0
  62. data/templates/json_encoding.rb +1 -0
  63. data/templates/newrelic.yml.erb +34 -0
  64. data/templates/postgresql_database.yml.erb +21 -0
  65. data/templates/puma.rb +28 -0
  66. data/templates/rack_mini_profiler.rb +5 -0
  67. data/templates/rails_helper.rb +22 -0
  68. data/templates/secrets.yml +14 -0
  69. data/templates/shoulda_matchers_config_rspec.rb +6 -0
  70. data/templates/smtp.rb +9 -0
  71. data/templates/spec_helper.rb +29 -0
  72. data/templates/staging.rb +5 -0
  73. data/templates/suspenders_gitignore +13 -0
  74. data/templates/suspenders_layout.html.erb.erb +22 -0
  75. metadata +204 -0
@@ -0,0 +1,234 @@
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
+ end
9
+
10
+ it "uses custom Gemfile" do
11
+ gemfile_file = IO.read("#{project_path}/Gemfile")
12
+ expect(gemfile_file).to match(
13
+ /^ruby "#{Suspenders::RUBY_VERSION}"$/,
14
+ )
15
+ expect(gemfile_file).to match(
16
+ /^gem "autoprefixer-rails"$/,
17
+ )
18
+ expect(gemfile_file).to match(
19
+ /^gem "rails", "#{Suspenders::RAILS_VERSION}"$/,
20
+ )
21
+ end
22
+
23
+ it "ensures project specs pass" do
24
+ Dir.chdir(project_path) do
25
+ Bundler.with_clean_env do
26
+ expect(`rake`).to include('0 failures')
27
+ end
28
+ end
29
+ end
30
+
31
+ it "inherits staging config from production" do
32
+ staging_file = IO.read("#{project_path}/config/environments/staging.rb")
33
+ config_stub = "Rails.application.configure do"
34
+
35
+ expect(staging_file).to match(/^require_relative "production"/)
36
+ expect(staging_file).to match(/#{config_stub}/), staging_file
37
+ end
38
+
39
+ it "creates .ruby-version from Suspenders .ruby-version" do
40
+ ruby_version_file = IO.read("#{project_path}/.ruby-version")
41
+
42
+ expect(ruby_version_file).to eq "#{RUBY_VERSION}\n"
43
+ end
44
+
45
+ it "copies dotfiles" do
46
+ %w[.ctags .env].each do |dotfile|
47
+ expect(File).to exist("#{project_path}/#{dotfile}")
48
+ end
49
+ end
50
+
51
+ it "loads secret_key_base from env" do
52
+ secrets_file = IO.read("#{project_path}/config/secrets.yml")
53
+
54
+ expect(secrets_file).to match(/secret_key_base: <%= ENV\["SECRET_KEY_BASE"\] %>/)
55
+ end
56
+
57
+ it "adds bin/setup file" do
58
+ expect(File).to exist("#{project_path}/bin/setup")
59
+ end
60
+
61
+ it "makes bin/setup executable" do
62
+ bin_setup_path = "#{project_path}/bin/setup"
63
+
64
+ expect(File.stat(bin_setup_path)).to be_executable
65
+ end
66
+
67
+ it "adds support file for action mailer" do
68
+ expect(File).to exist("#{project_path}/spec/support/action_mailer.rb")
69
+ end
70
+
71
+ it "configures capybara-webkit" do
72
+ expect(File).to exist("#{project_path}/spec/support/capybara_webkit.rb")
73
+ end
74
+
75
+ it "adds support file for i18n" do
76
+ expect(File).to exist("#{project_path}/spec/support/i18n.rb")
77
+ end
78
+
79
+ it "creates good default .hound.yml" do
80
+ hound_config_file = IO.read("#{project_path}/.hound.yml")
81
+
82
+ expect(hound_config_file).to include "enabled: true"
83
+ end
84
+
85
+ it "ensures Gemfile contains `rack-mini-profiler`" do
86
+ gemfile = IO.read("#{project_path}/Gemfile")
87
+
88
+ expect(gemfile).to include %{gem "rack-mini-profiler", require: false}
89
+ end
90
+
91
+ it "ensures .sample.env defaults to RACK_MINI_PROFILER=0" do
92
+ env = IO.read("#{project_path}/.env")
93
+
94
+ expect(env).to include "RACK_MINI_PROFILER=0"
95
+ end
96
+
97
+ it "creates a rack-mini-profiler initializer" do
98
+ expect(File).
99
+ to exist("#{project_path}/config/initializers/rack_mini_profiler.rb")
100
+ end
101
+
102
+ it "ensures newrelic.yml reads NewRelic license from env" do
103
+ newrelic_file = IO.read("#{project_path}/config/newrelic.yml")
104
+
105
+ expect(newrelic_file).to match(
106
+ /license_key: "<%= ENV\["NEW_RELIC_LICENSE_KEY"\] %>"/
107
+ )
108
+ end
109
+
110
+ it "records pageviews through Segment if ENV variable set" do
111
+ expect(analytics_partial).
112
+ to include(%{<% if ENV["SEGMENT_KEY"] %>})
113
+ expect(analytics_partial).
114
+ to include(%{window.analytics.load("<%= ENV["SEGMENT_KEY"] %>");})
115
+ end
116
+
117
+ it "raises on unpermitted parameters in all environments" do
118
+ result = IO.read("#{project_path}/config/application.rb")
119
+
120
+ expect(result).to match(
121
+ /^ +config.action_controller.action_on_unpermitted_parameters = :raise$/
122
+ )
123
+ end
124
+
125
+ it "adds explicit quiet_assets configuration" do
126
+ result = IO.read("#{project_path}/config/application.rb")
127
+
128
+ expect(result).to match(
129
+ /^ +config.quiet_assets = true$/
130
+ )
131
+ end
132
+
133
+ it "raises on missing translations in development and test" do
134
+ %w[development test].each do |environment|
135
+ environment_file =
136
+ IO.read("#{project_path}/config/environments/#{environment}.rb")
137
+ expect(environment_file).to match(
138
+ /^ +config.action_view.raise_on_missing_translations = true$/
139
+ )
140
+ end
141
+ end
142
+
143
+ it "evaluates en.yml.erb" do
144
+ locales_en_file = IO.read("#{project_path}/config/locales/en.yml")
145
+
146
+ expect(locales_en_file).to match(/application: #{app_name.humanize}/)
147
+ end
148
+
149
+ it "configs simple_form" do
150
+ expect(File).to exist("#{project_path}/config/initializers/simple_form.rb")
151
+ end
152
+
153
+ it "configs :test email delivery method for development" do
154
+ dev_env_file = IO.read("#{project_path}/config/environments/development.rb")
155
+ expect(dev_env_file).
156
+ to match(/^ +config.action_mailer.delivery_method = :file$/)
157
+ end
158
+
159
+ it "uses APPLICATION_HOST, not HOST in the production config" do
160
+ prod_env_file = IO.read("#{project_path}/config/environments/production.rb")
161
+ expect(prod_env_file).to match(/"APPLICATION_HOST"/)
162
+ expect(prod_env_file).not_to match(/"HOST"/)
163
+ end
164
+
165
+ it "configures language in html element" do
166
+ layout_path = "/app/views/layouts/application.html.erb"
167
+ layout_file = IO.read("#{project_path}#{layout_path}")
168
+ expect(layout_file).to match(/<html lang="en">/)
169
+ end
170
+
171
+ it "configs active job queue adapter" do
172
+ application_config = IO.read("#{project_path}/config/application.rb")
173
+ test_config = IO.read("#{project_path}/config/environments/test.rb")
174
+
175
+ expect(application_config).to match(
176
+ /^ +config.active_job.queue_adapter = :delayed_job$/
177
+ )
178
+ expect(test_config).to match(
179
+ /^ +config.active_job.queue_adapter = :inline$/
180
+ )
181
+ end
182
+
183
+ it "configs bullet gem in development" do
184
+ test_config = IO.read("#{project_path}/config/environments/development.rb")
185
+
186
+ expect(test_config).to match /^ +Bullet.enable = true$/
187
+ expect(test_config).to match /^ +Bullet.bullet_logger = true$/
188
+ expect(test_config).to match /^ +Bullet.rails_logger = true$/
189
+ end
190
+
191
+ it "configs missing assets to raise in test" do
192
+ test_config = IO.read("#{project_path}/config/environments/test.rb")
193
+
194
+ expect(test_config).to match(
195
+ /^ +config.assets.raise_runtime_errors = true$/,
196
+ )
197
+ end
198
+
199
+ it "adds spring to binstubs" do
200
+ expect(File).to exist("#{project_path}/bin/spring")
201
+
202
+ bin_stubs = %w(rake rails rspec)
203
+ bin_stubs.each do |bin_stub|
204
+ expect(IO.read("#{project_path}/bin/#{bin_stub}")).to match(/spring/)
205
+ end
206
+ end
207
+
208
+ it "removes comments and extra newlines from config files" do
209
+ config_files = [
210
+ IO.read("#{project_path}/config/application.rb"),
211
+ IO.read("#{project_path}/config/environment.rb"),
212
+ IO.read("#{project_path}/config/environments/development.rb"),
213
+ IO.read("#{project_path}/config/environments/production.rb"),
214
+ IO.read("#{project_path}/config/environments/test.rb"),
215
+ ]
216
+
217
+ config_files.each do |file|
218
+ expect(file).not_to match(/.*#.*/)
219
+ expect(file).not_to match(/^$\n/)
220
+ end
221
+ end
222
+
223
+ it "copies factories.rb" do
224
+ expect(File).to exist("#{project_path}/spec/factories.rb")
225
+ end
226
+
227
+ def app_name
228
+ SuspendersTestHelpers::APP_NAME
229
+ end
230
+
231
+ def analytics_partial
232
+ IO.read("#{project_path}/app/views/application/_analytics.html.erb")
233
+ end
234
+ end
@@ -0,0 +1,20 @@
1
+ require 'bundler/setup'
2
+
3
+ Bundler.require(:default, :test)
4
+
5
+ require (Pathname.new(__FILE__).dirname + '../lib/suspenders').expand_path
6
+
7
+ Dir['./spec/support/**/*.rb'].each { |file| require file }
8
+
9
+ RSpec.configure do |config|
10
+ config.include SuspendersTestHelpers
11
+
12
+ config.before(:all) do
13
+ add_fakes_to_path
14
+ create_tmp_directory
15
+ end
16
+
17
+ config.before(:each) do
18
+ FakeGithub.clear!
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ class FakeGithub
2
+ RECORDER = File.expand_path(File.join('..', '..', 'tmp', 'hub_commands'), File.dirname(__FILE__))
3
+
4
+ def initialize(args)
5
+ @args = args
6
+ end
7
+
8
+ def run!
9
+ File.open(RECORDER, 'a') do |file|
10
+ file.write @args.join(' ')
11
+ end
12
+ end
13
+
14
+ def self.clear!
15
+ FileUtils.rm_rf RECORDER
16
+ end
17
+
18
+ def self.has_created_repo?(repo_name)
19
+ File.read(RECORDER) == "create #{repo_name}"
20
+ end
21
+ end
@@ -0,0 +1,53 @@
1
+ class FakeHeroku
2
+ RECORDER = File.expand_path(File.join('..', '..', 'tmp', 'heroku_commands'), File.dirname(__FILE__))
3
+
4
+ def initialize(args)
5
+ @args = args
6
+ end
7
+
8
+ def run!
9
+ if @args.first == "plugins"
10
+ puts "heroku-pipelines@0.29.0"
11
+ end
12
+ File.open(RECORDER, 'a') do |file|
13
+ file.puts @args.join(' ')
14
+ end
15
+ end
16
+
17
+ def self.clear!
18
+ FileUtils.rm_rf RECORDER
19
+ end
20
+
21
+ def self.has_gem_included?(project_path, gem_name)
22
+ gemfile = File.open(File.join(project_path, 'Gemfile'), 'a')
23
+
24
+ File.foreach(gemfile).any? do |line|
25
+ line.match(/#{Regexp.quote(gem_name)}/)
26
+ end
27
+ end
28
+
29
+ def self.has_created_app_for?(environment, flags = nil)
30
+ app_name = "#{SuspendersTestHelpers::APP_NAME.dasherize}-#{environment}"
31
+
32
+ command = if flags
33
+ "create #{app_name} #{flags} --remote #{environment}\n"
34
+ else
35
+ "create #{app_name} --remote #{environment}\n"
36
+ end
37
+
38
+ File.foreach(RECORDER).any? { |line| line == command }
39
+ end
40
+
41
+ def self.has_configured_vars?(remote_name, var)
42
+ commands_ran =~ /^config:add #{var}=.+ --remote #{remote_name}\n/
43
+ end
44
+
45
+ def self.has_setup_pipeline_for?(app_name)
46
+ commands_ran =~ /^pipelines:create #{app_name} -a #{app_name}-staging --stage staging/ &&
47
+ commands_ran =~ /^pipelines:add #{app_name} -a #{app_name}-production --stage production/
48
+ end
49
+
50
+ def self.commands_ran
51
+ @commands_ran ||= File.read(RECORDER)
52
+ end
53
+ end
@@ -0,0 +1,58 @@
1
+ module SuspendersTestHelpers
2
+ APP_NAME = "dummy_app"
3
+
4
+ def remove_project_directory
5
+ FileUtils.rm_rf(project_path)
6
+ end
7
+
8
+ def create_tmp_directory
9
+ FileUtils.mkdir_p(tmp_path)
10
+ end
11
+
12
+ def run_suspenders(arguments = nil)
13
+ Dir.chdir(tmp_path) do
14
+ Bundler.with_clean_env do
15
+ add_fakes_to_path
16
+ `
17
+ #{suspenders_bin} #{APP_NAME} #{arguments}
18
+ `
19
+ end
20
+ end
21
+ end
22
+
23
+ def drop_dummy_database
24
+ if File.exist?(project_path)
25
+ Dir.chdir(project_path) do
26
+ Bundler.with_clean_env do
27
+ `rake db:drop`
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ def add_fakes_to_path
34
+ ENV["PATH"] = "#{support_bin}:#{ENV['PATH']}"
35
+ end
36
+
37
+ def project_path
38
+ @project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
39
+ end
40
+
41
+ private
42
+
43
+ def tmp_path
44
+ @tmp_path ||= Pathname.new("#{root_path}/tmp")
45
+ end
46
+
47
+ def suspenders_bin
48
+ File.join(root_path, 'bin', 'suspenders')
49
+ end
50
+
51
+ def support_bin
52
+ File.join(root_path, "spec", "fakes", "bin")
53
+ end
54
+
55
+ def root_path
56
+ File.expand_path('../../../', __FILE__)
57
+ end
58
+ end
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'suspenders/version'
4
+ require 'date'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.required_ruby_version = ">= #{Suspenders::RUBY_VERSION}"
8
+ s.authors = ['sumeetjain']
9
+ s.date = Date.today.strftime('%Y-%m-%d')
10
+
11
+ s.description = <<-HERE
12
+ Suspenders-OCS is a fork of thoughtbot/suspenders, which is a base Rails project that used to get a jump start on a working app.
13
+ HERE
14
+
15
+ s.email = 'sumeet@sumeetjain.com'
16
+ s.executables = ['suspenders']
17
+ s.extra_rdoc_files = %w[README.md LICENSE]
18
+ s.files = `git ls-files`.split("\n")
19
+ s.homepage = 'http://github.com/omahacodeschool/suspenders'
20
+ s.license = 'MIT'
21
+ s.name = 'suspenders-ocs'
22
+ s.rdoc_options = ['--charset=UTF-8']
23
+ s.require_paths = ['lib']
24
+ s.summary = "Generate a Rails app using thoughtbot's best practices--modified for use by Omaha Code School students."
25
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
+ s.version = Suspenders::VERSION
27
+
28
+ s.add_dependency 'bundler', '~> 1.3'
29
+ s.add_dependency 'rails', Suspenders::RAILS_VERSION
30
+
31
+ s.add_development_dependency 'rspec', '~> 3.2'
32
+ s.add_development_dependency 'quiet_assets', '~> 1.1'
33
+ s.add_development_dependency 'capybara-webkit', '~> 1.8'
34
+ end
@@ -0,0 +1,63 @@
1
+ source "https://rubygems.org"
2
+
3
+ ruby "<%= Suspenders::RUBY_VERSION %>"
4
+
5
+ gem "autoprefixer-rails"
6
+ gem "bourbon", "5.0.0.beta.3"
7
+ gem "delayed_job_active_record"
8
+ gem "flutie"
9
+ gem "high_voltage"
10
+ gem "honeybadger"
11
+ gem "jquery-rails"
12
+ gem "neat", "~> 1.7.0"
13
+ gem "newrelic_rpm", ">= 3.9.8"
14
+ gem "normalize-rails", "~> 3.0.0"
15
+ gem "pg"
16
+ gem "puma"
17
+ gem "rack-canonical-host"
18
+ gem "rails", "<%= Suspenders::RAILS_VERSION %>"
19
+ gem "recipient_interceptor"
20
+ gem "sass-rails", "~> 5.0"
21
+ gem "simple_form"
22
+ gem "sprockets", ">= 3.0.0"
23
+ gem "sprockets-es6"
24
+ gem "title"
25
+ gem "uglifier"
26
+
27
+ group :development do
28
+ gem "quiet_assets"
29
+ gem "refills"
30
+ gem "spring"
31
+ gem "spring-commands-rspec"
32
+ gem "web-console"
33
+ end
34
+
35
+ group :development, :test do
36
+ gem "awesome_print"
37
+ gem "bullet"
38
+ gem "bundler-audit", ">= 0.5.0", require: false
39
+ gem "dotenv-rails"
40
+ gem "factory_girl_rails"
41
+ gem "pry-byebug"
42
+ gem "pry-rails"
43
+ gem "rspec-rails", "~> 3.4.0"
44
+ end
45
+
46
+ group :development, :staging do
47
+ gem "rack-mini-profiler", require: false
48
+ end
49
+
50
+ group :test do
51
+ gem "capybara-webkit"
52
+ gem "database_cleaner"
53
+ gem "formulaic"
54
+ gem "launchy"
55
+ gem "shoulda-matchers"
56
+ gem "simplecov", require: false
57
+ gem "timecop"
58
+ gem "webmock"
59
+ end
60
+
61
+ group :staging, :production do
62
+ gem "rack-timeout"
63
+ end