suspenders 1.47.0 → 1.48.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e585c8f3e53dfd7aa542261c004856ddd5e6372373d5a09fb23ad4adcafbfde1
4
- data.tar.gz: ec2ff003f5d6ba7870fef1d617f3c60580a0b0dad6837bcdc5fcaf1600e62539
3
+ metadata.gz: 026c79f5c34397199d36e6bd17fa69c195f5c726ac8b1fdb8af6b83b733b361a
4
+ data.tar.gz: f66658fa08e388e6c57b90afbb3d434f0965c342e4e12dba101548a2a1b36e6b
5
5
  SHA512:
6
- metadata.gz: 5ec04e0b9b8e16290547280ad3e76ebaf74f7cc427840eb13f4bef533eff595dc4d3b6829470b715b46104246b8465dd356ecb71b86da025a20356e1b1cf2efb
7
- data.tar.gz: c95149425b13ea6b3ebedbe86207cafc3bf616293c2afab63eaffeb156b7e11ca459fb6bc89a30e882640b72dceea0e65de0ab7c86713e5d152d737234ace46c
6
+ metadata.gz: d0177c69ba8b3ea0f36a464896c8ce39b5740f4b31d5ff50733225ca351c7d08f2f17d9dd2e3b932c412a73972d338e7dbd741a728cfccfb683f13406b348bcb
7
+ data.tar.gz: 13f9f01d699a0805b5f66068754a3575e734b45246abd03af22810066c7166031108c0a41cb229d8a61300efa3d1b0f325f834c223796a2a9394ebbd022f868a
data/CONTRIBUTING.md CHANGED
@@ -13,9 +13,6 @@ Set up your machine:
13
13
 
14
14
  ./bin/setup
15
15
 
16
- If you're having trouble installing `capybara-webkit` check their [installation
17
- instructions](https://github.com/thoughtbot/capybara-webkit#qt-dependency-and-installation-issues).
18
-
19
16
  Make sure the tests pass:
20
17
 
21
18
  rake
data/NEWS.md CHANGED
@@ -1,3 +1,10 @@
1
+ 1.48.0 (August 10, 2018)
2
+
3
+ * Bug fix: change production timeouts generator to use working configuration
4
+ method with latest version of Rack::Timeout
5
+ * Bug fix: Only add email environment requirements if configuring for email
6
+ * Breaking: Replace capybara-webkit with chromedriver
7
+
1
8
  1.47.0 (May 25, 2018)
2
9
 
3
10
  * Bug fix: normalize.css Sass import is concatenated with other styles now
data/README.md CHANGED
@@ -76,7 +76,7 @@ And development gems like:
76
76
  And testing gems like:
77
77
 
78
78
  * [Capybara](https://github.com/jnicklas/capybara) and
79
- [Capybara WebKit](https://github.com/thoughtbot/capybara-webkit) for
79
+ [Google Chromedriver]
80
80
  integration testing
81
81
  * [Factory Bot](https://github.com/thoughtbot/factory_bot) for test data
82
82
  * [Formulaic](https://github.com/thoughtbot/formulaic) for integration testing
@@ -182,10 +182,10 @@ Snow Leopard (OS X 10.6).
182
182
  Use [Command Line Tools for Xcode](https://developer.apple.com/downloads/index.action)
183
183
  for Lion (OS X 10.7) or Mountain Lion (OS X 10.8).
184
184
 
185
- We use [Capybara WebKit](https://github.com/thoughtbot/capybara-webkit) for
186
- full-stack JavaScript integration testing. It requires QT. Instructions for
187
- installing QT are
188
- [here](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit).
185
+ We use [Google Chromedriver] for full-stack JavaScript integration testing. It
186
+ requires Google Chrome or Chromium.
187
+
188
+ [Google Chromedriver]: https://sites.google.com/a/chromium.org/chromedriver/home
189
189
 
190
190
  PostgreSQL needs to be installed and running for the `db:create` rake task.
191
191
 
@@ -26,5 +26,60 @@ module Suspenders
26
26
  before: "\nend"
27
27
  )
28
28
  end
29
+
30
+ def expand_json(file, data)
31
+ action ExpandJson.new(destination_root, file, data)
32
+ end
33
+
34
+ class ExpandJson
35
+ def initialize(destination_root, file, data)
36
+ @destination_root = destination_root
37
+ @file = file
38
+ @data = data
39
+ end
40
+
41
+ def invoke!
42
+ write_out { |existing_json| existing_json.merge(data) }
43
+ end
44
+
45
+ def revoke!
46
+ write_out { |existing_json| hash_unmerge(existing_json, data) }
47
+ end
48
+
49
+ private
50
+
51
+ attr_reader :destination_root, :file, :data
52
+
53
+ def write_out
54
+ new_json = yield(existing_json)
55
+ IO.write(destination_file, JSON.pretty_generate(new_json))
56
+ end
57
+
58
+ def destination_file
59
+ File.join(destination_root, file)
60
+ end
61
+
62
+ def existing_json
63
+ JSON.parse(IO.read(destination_file))
64
+ rescue Errno::ENOENT
65
+ {}
66
+ end
67
+
68
+ def hash_unmerge(hash, subhash)
69
+ subhash.reduce(hash) do |acc, (k, v)|
70
+ if hash.has_key?(k)
71
+ if v == hash[k]
72
+ acc.except(k)
73
+ elsif v.is_a?(Hash)
74
+ acc.merge(k => hash_unmerge(hash[k], v))
75
+ else
76
+ acc
77
+ end
78
+ else
79
+ acc
80
+ end
81
+ end
82
+ end
83
+ end
29
84
  end
30
85
  end
@@ -59,6 +59,7 @@ module Suspenders
59
59
  invoke :setup_default_directories
60
60
  invoke :create_local_heroku_setup
61
61
  invoke :create_heroku_apps
62
+ invoke :generate_production_default
62
63
  invoke :outro
63
64
  end
64
65
 
@@ -192,6 +193,9 @@ module Suspenders
192
193
  generate("suspenders:jobs")
193
194
  generate("suspenders:analytics")
194
195
  generate("suspenders:views")
196
+ end
197
+
198
+ def generate_production_default
195
199
  generate("suspenders:production:force_tls")
196
200
  generate("suspenders:production:email")
197
201
  generate("suspenders:production:timeout")
@@ -8,12 +8,13 @@ module Suspenders
8
8
  )
9
9
 
10
10
  def add_gems
11
- gem "capybara-webkit", group: :test
11
+ gem "capybara-selenium", group: :test
12
+ gem "chromedriver-helper", group: :test
12
13
  Bundler.with_clean_env { run "bundle install" }
13
14
  end
14
15
 
15
- def configure_capybara_webkit
16
- copy_file "capybara_webkit.rb", "spec/support/capybara_webkit.rb"
16
+ def configure_chromedriver
17
+ copy_file "chromedriver.rb", "spec/support/chromedriver.rb"
17
18
  end
18
19
  end
19
20
  end
@@ -1,8 +1,11 @@
1
1
  require "rails/generators"
2
+ require_relative "../../actions"
2
3
 
3
4
  module Suspenders
4
5
  module Production
5
6
  class EmailGenerator < Rails::Generators::Base
7
+ include Suspenders::Actions
8
+
6
9
  source_root File.expand_path(
7
10
  File.join("..", "..", "..", "..", "templates"),
8
11
  File.dirname(__FILE__),
@@ -25,6 +28,18 @@ module Suspenders
25
28
  inject_into_file "config/environments/production.rb", config,
26
29
  after: "config.action_mailer.raise_delivery_errors = false"
27
30
  end
31
+
32
+ def env_vars
33
+ expand_json(
34
+ "app.json",
35
+ env: {
36
+ SMTP_ADDRESS: { required: true },
37
+ SMTP_DOMAIN: { required: true },
38
+ SMTP_PASSWORD: { required: true },
39
+ SMTP_USERNAME: { required: true },
40
+ },
41
+ )
42
+ end
28
43
  end
29
44
  end
30
45
  end
@@ -8,13 +8,13 @@ module Suspenders
8
8
  end
9
9
 
10
10
  def configure_rack_timeout
11
- append_file "config/environments/production.rb", rack_timeout_config
11
+ append_file ".env", rack_timeout_config
12
12
  end
13
13
 
14
14
  private
15
15
 
16
16
  def rack_timeout_config
17
- %{Rack::Timeout.timeout = ENV.fetch("RACK_TIMEOUT", 10).to_i}
17
+ %{RACK_TIMEOUT_SERVICE_TIMEOUT=10}
18
18
  end
19
19
  end
20
20
  end
@@ -4,5 +4,5 @@ module Suspenders
4
4
  read("#{File.dirname(__FILE__)}/../../.ruby-version").
5
5
  strip.
6
6
  freeze
7
- VERSION = "1.47.0".freeze
7
+ VERSION = "1.48.0".freeze
8
8
  end
@@ -74,8 +74,8 @@ RSpec.describe "Suspend a new project with default configuration" do
74
74
  expect(File).to exist("#{project_path}/spec/support/action_mailer.rb")
75
75
  end
76
76
 
77
- it "configures capybara-webkit" do
78
- expect(File).to exist("#{project_path}/spec/support/capybara_webkit.rb")
77
+ it "configures capybara-chromedriver" do
78
+ expect(File).to exist("#{project_path}/spec/support/chromedriver.rb")
79
79
  end
80
80
 
81
81
  it "adds support file for i18n" do
@@ -276,7 +276,7 @@ RSpec.describe "Suspend a new project with default configuration" do
276
276
  it "creates heroku application manifest file with application name in it" do
277
277
  app_json_file = IO.read("#{project_path}/app.json")
278
278
 
279
- expect(app_json_file).to match(/"name":"#{app_name.dasherize}"/)
279
+ expect(app_json_file).to match(/"name":\s*"#{app_name.dasherize}"/)
280
280
  end
281
281
 
282
282
  def app_name
@@ -5,11 +5,43 @@ RSpec.describe "suspenders:production:email" do
5
5
  with_app { generate("suspenders:production:email") }
6
6
 
7
7
  expect("config/smtp.rb").to match_contents(%r{SMTP_SETTINGS\s*=})
8
+
8
9
  expect("config/environments/production.rb").to \
9
10
  match_contents(%r{require.+config/smtp})
10
11
  expect("config/environments/production.rb").to \
11
12
  match_contents(%r{action_mailer.delivery_method\s*=\s*:smtp})
12
13
  expect("config/environments/production.rb").to \
13
14
  match_contents(%r{action_mailer.smtp_settings\s*=\s*SMTP_SETTINGS})
15
+
16
+ expect("app.json").to contain_json(
17
+ env: {
18
+ SMTP_ADDRESS: { required: true },
19
+ SMTP_DOMAIN: { required: true },
20
+ SMTP_PASSWORD: { required: true },
21
+ SMTP_USERNAME: { required: true },
22
+ },
23
+ )
24
+ end
25
+
26
+ it "destroys the configuration for a production email deployment" do
27
+ with_app { destroy("suspenders:production:email") }
28
+
29
+ expect("config/smtp.rb").not_to exist_as_a_file
30
+
31
+ expect("config/environments/production.rb").not_to \
32
+ match_contents(%r{require.+config/smtp})
33
+ expect("config/environments/production.rb").not_to \
34
+ match_contents(%r{action_mailer.delivery_method\s*=\s*:smtp})
35
+ expect("config/environments/production.rb").not_to \
36
+ match_contents(%r{action_mailer.smtp_settings\s*=\s*SMTP_SETTINGS})
37
+
38
+ expect("app.json").not_to contain_json(
39
+ env: {
40
+ SMTP_ADDRESS: { required: true },
41
+ SMTP_DOMAIN: { required: true },
42
+ SMTP_PASSWORD: { required: true },
43
+ SMTP_USERNAME: { required: true },
44
+ },
45
+ )
14
46
  end
15
47
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ RSpec::Matchers.define :contain_json do
6
+ match do
7
+ sub_json = expected
8
+ filename = actual
9
+
10
+ filepath = File.join(project_path, filename)
11
+ json = JSON.parse(IO.read(filepath), symbolize_names: true)
12
+ sub_json <= json
13
+ end
14
+
15
+ failure_message do
16
+ sub_json = expected
17
+ filename = actual
18
+
19
+ filepath = File.join(project_path, filename)
20
+ json = JSON.parse(IO.read(filepath), symbolize_names: true)
21
+
22
+ "in #{filename}, expected to find\n#{sub_json.inspect}\nin\n#{json.inspect}"
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec::Matchers.define :exist_as_a_file do
4
+ match do |filename|
5
+ File.exist?(File.join(project_path, filename))
6
+ end
7
+ end
@@ -66,6 +66,15 @@ module SuspendersTestHelpers
66
66
  end
67
67
  end
68
68
 
69
+ def destroy(generator)
70
+ run_in_project do
71
+ with_revision_for_honeybadger do
72
+ `bin/spring stop`
73
+ `#{project_rails_bin} destroy #{generator}`
74
+ end
75
+ end
76
+ end
77
+
69
78
  def suspenders_help_command
70
79
  run_in_tmp do
71
80
  debug `#{suspenders_bin} -h`
@@ -19,18 +19,6 @@
19
19
  },
20
20
  "SECRET_KEY_BASE":{
21
21
  "generator":"secret"
22
- },
23
- "SMTP_ADDRESS":{
24
- "required":true
25
- },
26
- "SMTP_DOMAIN":{
27
- "required":true
28
- },
29
- "SMTP_PASSWORD":{
30
- "required":true
31
- },
32
- "SMTP_USERNAME":{
33
- "required":true
34
22
  }
35
23
  },
36
24
  "addons":[
@@ -0,0 +1,17 @@
1
+ require "selenium/webdriver"
2
+
3
+ Capybara.register_driver :chrome do |app|
4
+ Capybara::Selenium::Driver.new(app, browser: :chrome)
5
+ end
6
+
7
+ Capybara.register_driver :headless_chrome do |app|
8
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
9
+ chromeOptions: { args: %w(headless disable-gpu) },
10
+ )
11
+
12
+ Capybara::Selenium::Driver.new app,
13
+ browser: :chrome,
14
+ desired_capabilities: capabilities
15
+ end
16
+
17
+ Capybara.javascript_driver = :headless_chrome
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suspenders
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.47.0
4
+ version: 1.48.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoughtbot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-25 00:00:00.000000000 Z
11
+ date: 2018-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bitters
@@ -110,6 +110,8 @@ files:
110
110
  - spec/features/new_project_spec.rb
111
111
  - spec/features/production/email_spec.rb
112
112
  - spec/spec_helper.rb
113
+ - spec/support/contain_json_matcher.rb
114
+ - spec/support/exist_as_a_file_matcher.rb
113
115
  - spec/support/fake_github.rb
114
116
  - spec/support/fake_heroku.rb
115
117
  - spec/support/match_contents_matcher.rb
@@ -131,7 +133,7 @@ files:
131
133
  - templates/bin_setup_review_app.erb
132
134
  - templates/browserslist
133
135
  - templates/bundler_audit.rake
134
- - templates/capybara_webkit.rb
136
+ - templates/chromedriver.rb
135
137
  - templates/circle.yml.erb
136
138
  - templates/config_locales_en.yml.erb
137
139
  - templates/dev.rake
@@ -176,8 +178,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
178
  version: 2.7.4
177
179
  requirements: []
178
180
  rubyforge_project:
179
- rubygems_version: 2.7.6
181
+ rubygems_version: 2.7.7
180
182
  signing_key:
181
183
  specification_version: 4
182
184
  summary: Generate a Rails app using thoughtbot's best practices.
183
- test_files: []
185
+ test_files:
186
+ - spec/adapters/heroku_spec.rb
187
+ - spec/fakes/bin/heroku
188
+ - spec/fakes/bin/hub
189
+ - spec/features/api_spec.rb
190
+ - spec/features/cli_help_spec.rb
191
+ - spec/features/github_spec.rb
192
+ - spec/features/heroku_spec.rb
193
+ - spec/features/new_project_spec.rb
194
+ - spec/features/production/email_spec.rb
195
+ - spec/spec_helper.rb
196
+ - spec/support/contain_json_matcher.rb
197
+ - spec/support/exist_as_a_file_matcher.rb
198
+ - spec/support/fake_github.rb
199
+ - spec/support/fake_heroku.rb
200
+ - spec/support/match_contents_matcher.rb
201
+ - spec/support/suspenders.rb
@@ -1,5 +0,0 @@
1
- Capybara.javascript_driver = :webkit
2
-
3
- Capybara::Webkit.configure do |config|
4
- config.block_unknown_urls
5
- end