suspenders 1.6.0 → 1.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9143fdabbeb2429e35b159d7d05ebd723ca630f9
4
- data.tar.gz: 3dda26b01f294506f39591fc5e9399fed50c3c4f
3
+ metadata.gz: 0f7d09cee5a10cf3cbe9b1aa85666f7d11085889
4
+ data.tar.gz: 1dfe58a3f0553599f33821571a5551883feebafc
5
5
  SHA512:
6
- metadata.gz: 3728b65694bec8e195af833a2eaf0be99939c5e8d918e0d5f7eace2fa06ab5a435369542d5402d3d831e9b611f49888a8a5654476b6aa4f661a2865e91788338
7
- data.tar.gz: 57fa6bab849dd3df3ee5af8c6173faeb0de308e12d65fc57dfdf15abab8b7031e41e49c6d05f7a087ca6da0cf4530c5d5b38e2808a7510a8f1b8d77201679a2a
6
+ metadata.gz: e9152f3b09f3c6b3613113faa1a78857b8dddd956af2e735fe3d953471bcca215fef056482cec2daacb8f0420047d25a18113ab6f8387aadeb447dbe84b1fb85
7
+ data.tar.gz: cd4d52db35d9e70931108c9a21f75f1dc66f2b38bab38ddb9891f03916dca84329997824af7315b6f2b3bd5c051dd39654273e1e5c62bb5693bccb681672bc55
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- suspenders (1.6.0)
4
+ suspenders (1.7.0)
5
5
  bundler (~> 1.3)
6
6
  rails (= 4.0.0)
7
7
 
@@ -56,7 +56,7 @@ GEM
56
56
  gherkin (2.12.0-x86-mingw32)
57
57
  multi_json (~> 1.3)
58
58
  hike (1.2.3)
59
- i18n (0.6.5)
59
+ i18n (0.6.9)
60
60
  mail (2.5.4)
61
61
  mime-types (~> 1.16)
62
62
  treetop (~> 1.4.8)
data/NEWS.md CHANGED
@@ -1,3 +1,12 @@
1
+ 1.7.0 (December 6, 2013)
2
+
3
+ * Keep `db/schema.rb` under version control.
4
+ * Fast-fail if any part of `bin/setup` fails.
5
+ * Move secret key out of version control.
6
+ * Create `.ruby-version` in generated applications.
7
+ * Add placeholder modules and directories for feature specs.
8
+ * Improve README to include setup instructions.
9
+
1
10
  1.6.0 (November 28, 2013)
2
11
 
3
12
  * Do not create `.rspec` file as the settings are not project-specific.
@@ -6,7 +15,7 @@
6
15
  * Add `--skip-git` option.
7
16
  * Disable jQuery animations in Rails integration tests that execute JavaScript.
8
17
  * Fix git remote bug.
9
- * Add `Rack::Timeout` to compress responses with Gzip.
18
+ * Add `Rack::Deflater` to compress responses with Gzip.
10
19
 
11
20
  1.5.1 (September 10, 2013)
12
21
 
data/README.md CHANGED
@@ -82,6 +82,16 @@ Suspenders also comes with:
82
82
  [compress]: http://robots.thoughtbot.com/content-compression-with-rack-deflater/
83
83
  [fast]: http://robots.thoughtbot.com/testing-your-factories-first
84
84
 
85
+ Suspenders fixes several of Rails' [insecure defaults]:
86
+
87
+ * Suspenders uses Unicorn instead of WEBrick, allowing less verbose Server
88
+ headers.
89
+ * Suspenders is configured to pull your application secret key base from an
90
+ environment variable, which means you won't need to risk placing it in version
91
+ control.
92
+
93
+ [insecure defaults]: http://blog.codeclimate.com/blog/2013/03/27/rails-insecure-defaults/
94
+
85
95
  Heroku
86
96
  ------
87
97
 
@@ -7,3 +7,5 @@ Feature: Creating a Heroku app
7
7
  | --heroku | true |
8
8
  Then the "test_project-staging" Heroku app should exist
9
9
  And the "test_project-production" Heroku app should exist
10
+ And the "staging" Heroku remote should have "SECRET_KEY_BASE" configured
11
+ And the "production" Heroku remote should have "SECRET_KEY_BASE" configured
@@ -6,10 +6,39 @@ Feature: Rake works in the suspended project
6
6
  Scenario: Running rake in the suspended project
7
7
  When I suspend a project called "test_project"
8
8
  And I cd to the "test_project" root
9
+ And I obtain a fresh checkout
10
+ And I setup the project
9
11
  Then I can cleanly rake the project
10
12
 
11
- Scenario: Making a spec then running rake
13
+ Scenario: Making a model spec then running rake
12
14
  When I suspend a project called "test_project"
13
15
  And I cd to the "test_project" root
16
+ And I obtain a fresh checkout
17
+ And I setup the project
14
18
  And I generate "model post title:string"
19
+ And I run migrations
15
20
  Then I can cleanly rake the project
21
+
22
+ Scenario: Making a feature spec then running rake
23
+ When I suspend a project called "test_project"
24
+ And I cd to the "test_project" root
25
+ And I obtain a fresh checkout
26
+ And I setup the project
27
+ And I write to "spec/features/example_spec.rb" with:
28
+ """
29
+ require 'spec_helper'
30
+
31
+ feature 'Example feature spec' do
32
+ scenario 'using a method from the Features module' do
33
+ expect(example_method).to eq('Expected Value')
34
+ end
35
+ end
36
+ """
37
+ And I write to "spec/support/features/example.rb" with:
38
+ """
39
+ module Features
40
+ def example_method
41
+ 'Expected Value'
42
+ end
43
+ end
44
+ """
@@ -6,6 +6,18 @@ When 'I run rake' do
6
6
  end
7
7
  end
8
8
 
9
+ When 'I run migrations' do
10
+ in_current_dir do
11
+ run_simple 'bundle exec rake db:migrate'
12
+ end
13
+ end
14
+
15
+ When 'I obtain a fresh checkout' do
16
+ in_current_dir do
17
+ run_simple 'git clean --force -x -d'
18
+ end
19
+ end
20
+
9
21
  When 'I run the rake task "$task_name"' do |task_name|
10
22
  in_current_dir do
11
23
  run_simple "bundle exec rake #{task_name}"
@@ -26,6 +38,10 @@ end
26
38
  When 'I suspend a project called "$project_name"' do |project_name|
27
39
  suspenders_bin = File.expand_path(File.join('..', '..', 'bin', 'suspenders'), File.dirname(__FILE__))
28
40
  run_simple "#{suspenders_bin} #{project_name}"
41
+ cd project_name
42
+ run_simple 'git add -A'
43
+ run_simple 'git commit -m "Initial commit"'
44
+ cd '..'
29
45
  end
30
46
 
31
47
  When %r{I suspend a project called "([^"]*)" with:} do |project_name, arguments_table|
@@ -40,12 +56,13 @@ When 'I cd to the "$test_project" root' do |dirname|
40
56
  cd dirname
41
57
  end
42
58
 
59
+ When 'I setup the project' do
60
+ run_simple 'bin/setup'
61
+ end
62
+
43
63
  Then 'I can cleanly rake the project' do
44
64
  steps %{
45
- And I run the rake task "db:create"
46
- And I run the rake task "db:migrate"
47
- And I run the rake task "db:test:prepare"
48
- And I run rake
65
+ When I run rake
49
66
  }
50
67
  end
51
68
 
@@ -63,6 +80,10 @@ Then %r{the "([^"]*)" Heroku app should exist} do |app_name|
63
80
  FakeHeroku.should have_created_app(app_name)
64
81
  end
65
82
 
83
+ Then %r{the "([^"]+)" Heroku remote should have "([^"]+)" configured} do |remote_name, config_name|
84
+ FakeHeroku.configured_vars_for(remote_name).should include(config_name)
85
+ end
86
+
66
87
  Then %r{the "([^"]*)" Github repo should exist} do |repo_name|
67
88
  FakeGithub.should have_created_repo(repo_name)
68
89
  end
@@ -7,7 +7,7 @@ class FakeHeroku
7
7
 
8
8
  def run!
9
9
  File.open(RECORDER, 'a') do |file|
10
- file.write @args.join(' ')
10
+ file.puts @args.join(' ')
11
11
  end
12
12
  end
13
13
 
@@ -18,4 +18,13 @@ class FakeHeroku
18
18
  def self.has_created_app?(app_name)
19
19
  File.open(RECORDER, 'r').read.include?("create #{app_name}")
20
20
  end
21
+
22
+ def self.configured_vars_for(remote_name)
23
+ File.open(RECORDER, 'r').
24
+ each_line.
25
+ grep(/^config:add .* --remote=#{remote_name}/) { |line|
26
+ line.scan(/([A-Z_]+)=[^ ]*/)
27
+ }.
28
+ flatten
29
+ end
21
30
  end
@@ -98,6 +98,12 @@ module Suspenders
98
98
  "Mail.register_interceptor RecipientInterceptor.new(ENV['EMAIL_RECIPIENTS'])\n"
99
99
  end
100
100
 
101
+ def setup_secret_token
102
+ template 'secret_token.rb',
103
+ 'config/initializers/secret_token.rb',
104
+ :force => true
105
+ end
106
+
101
107
  def create_partials_directory
102
108
  empty_directory 'app/views/application'
103
109
  end
@@ -132,7 +138,7 @@ module Suspenders
132
138
  end
133
139
 
134
140
  def create_database
135
- bundle_command 'exec rake db:create'
141
+ bundle_command 'exec rake db:create db:migrate'
136
142
  end
137
143
 
138
144
  def replace_gemfile
@@ -143,12 +149,18 @@ module Suspenders
143
149
  def set_ruby_to_version_being_used
144
150
  inject_into_file 'Gemfile', "\n\nruby '#{RUBY_VERSION}'",
145
151
  after: /source 'https:\/\/rubygems.org'/
152
+ create_file '.ruby-version', "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}\n"
146
153
  end
147
154
 
148
155
  def enable_database_cleaner
149
156
  copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
150
157
  end
151
158
 
159
+ def configure_spec_support_features
160
+ empty_directory_with_keep_file 'spec/features'
161
+ empty_directory_with_keep_file 'spec/support/features'
162
+ end
163
+
152
164
  def configure_rspec
153
165
  remove_file 'spec/spec_helper.rb'
154
166
  copy_file 'spec_helper.rb', 'spec/spec_helper.rb'
@@ -250,6 +262,12 @@ git remote add production git@heroku.com:#{app_name}-production.git
250
262
  append_file 'bin/setup', remotes
251
263
  end
252
264
 
265
+ def set_heroku_rails_secrets
266
+ path_addition = override_path_for_tests
267
+ run "#{path_addition} heroku config:add SECRET_KEY_BASE=#{generate_secret} --remote=staging"
268
+ run "#{path_addition} heroku config:add SECRET_KEY_BASE=#{generate_secret} --remote=production"
269
+ end
270
+
253
271
  def create_github_repo(repo_name)
254
272
  path_addition = override_path_for_tests
255
273
  run "#{path_addition} hub create #{repo_name}"
@@ -299,5 +317,9 @@ git remote add production git@heroku.com:#{app_name}-production.git
299
317
  def factories_spec_rake_task
300
318
  IO.read find_in_source_paths('factories_spec_rake_task.rb')
301
319
  end
320
+
321
+ def generate_secret
322
+ SecureRandom.hex(64)
323
+ end
302
324
  end
303
325
  end
@@ -23,11 +23,11 @@ module Suspenders
23
23
  def suspenders_customization
24
24
  invoke :remove_files_we_dont_need
25
25
  invoke :customize_gemfile
26
- invoke :setup_database
27
26
  invoke :setup_development_environment
28
27
  invoke :setup_test_environment
29
28
  invoke :setup_production_environment
30
29
  invoke :setup_staging_environment
30
+ invoke :setup_secret_token
31
31
  invoke :create_suspenders_views
32
32
  invoke :setup_coffeescript
33
33
  invoke :configure_app
@@ -36,6 +36,7 @@ module Suspenders
36
36
  invoke :customize_error_pages
37
37
  invoke :remove_routes_comment_lines
38
38
  invoke :setup_git
39
+ invoke :setup_database
39
40
  invoke :create_heroku_apps
40
41
  invoke :create_github_repo
41
42
  invoke :outro
@@ -79,7 +80,7 @@ module Suspenders
79
80
  build :use_rspec_binstub
80
81
  build :configure_background_jobs_for_rspec
81
82
  build :enable_database_cleaner
82
- build :configure_capybara_webkit
83
+ build :configure_spec_support_features
83
84
  end
84
85
 
85
86
  def setup_production_environment
@@ -93,6 +94,11 @@ module Suspenders
93
94
  build :setup_staging_environment
94
95
  end
95
96
 
97
+ def setup_secret_token
98
+ say 'Moving secret token out of version control'
99
+ build :setup_secret_token
100
+ end
101
+
96
102
  def create_suspenders_views
97
103
  say 'Creating suspenders views'
98
104
  build :create_partials_directory
@@ -139,6 +145,7 @@ module Suspenders
139
145
  say 'Creating Heroku apps'
140
146
  build :create_heroku_apps
141
147
  build :set_heroku_remotes
148
+ build :set_heroku_rails_secrets
142
149
  end
143
150
  end
144
151
 
@@ -1,3 +1,3 @@
1
1
  module Suspenders
2
- VERSION = '1.6.0'
2
+ VERSION = '1.7.0'
3
3
  end
@@ -1,5 +1,21 @@
1
- You look great in Suspenders
2
- ============================
1
+ <%= app_name.humanize %>
2
+ <%= '=' * app_name.humanize.length %>
3
+
4
+ Getting Started
5
+ ---------------
6
+
7
+ This repository comes equipped with a self-setup script!
8
+
9
+ % ./bin/setup
10
+
11
+ After setting up, you can run the application using [foreman]:
12
+
13
+ % foreman start
14
+
15
+ [foreman]: http://ddollar.github.io/foreman/
16
+
17
+ Guidelines
18
+ ----------
3
19
 
4
20
  Use the following guides for getting things done, programming well, and
5
21
  programming in style.
data/templates/bin_setup CHANGED
@@ -3,6 +3,9 @@
3
3
  # Set up Rails app. Run this script immediately after cloning the codebase.
4
4
  # https://github.com/thoughtbot/guides/tree/master/protocol
5
5
 
6
+ # Exit if any subcommand fails
7
+ set -e
8
+
6
9
  # Set up Ruby dependencies via Bundler
7
10
  bundle install
8
11
 
data/templates/sample.env CHANGED
@@ -1,2 +1,3 @@
1
1
  # http://ddollar.github.com/foreman/
2
2
  RACK_ENV=development
3
+ SECRET_KEY_BASE=development_secret
@@ -0,0 +1,10 @@
1
+ # Your secret key is used for verifying the integrity of signed cookies.
2
+ # If you change this key, all old signed cookies will become invalid!
3
+
4
+ # Make sure the secret is at least 30 characters and all random,
5
+ # no regular words or you'll be exposed to dictionary attacks.
6
+ # You can use `rake secret` to generate a secure secret key.
7
+
8
+ # Make sure your secret_key_base is kept private
9
+ # if you're sharing your code publicly.
10
+ <%= app_const %>.config.secret_key_base = ENV['SECRET_KEY_BASE']
@@ -10,12 +10,17 @@ require 'webmock/rspec'
10
10
 
11
11
  Dir[Rails.root.join('spec/support/**/*.rb')].each { |file| require file }
12
12
 
13
+ module Features
14
+ # Extend this module in spec/support/features/*.rb
15
+ end
16
+
13
17
  RSpec.configure do |config|
14
18
  config.expect_with :rspec do |c|
15
19
  c.syntax = :expect
16
20
  end
17
21
 
18
22
  config.fail_fast = true
23
+ config.include Features, type: :feature
19
24
  config.infer_base_class_for_anonymous_controllers = false
20
25
  config.order = 'random'
21
26
  config.use_transactional_fixtures = false
@@ -6,7 +6,6 @@
6
6
  .sass-cache/
7
7
  coverage/*
8
8
  db/*.sqlite3
9
- db/schema.rb
10
9
  log/*
11
10
  public/system
12
11
  rerun.txt
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.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoughtbot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-28 00:00:00.000000000 Z
11
+ date: 2013-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -121,6 +121,7 @@ files:
121
121
  - templates/postgresql_database.yml.erb
122
122
  - templates/rack_timeout.rb
123
123
  - templates/sample.env
124
+ - templates/secret_token.rb
124
125
  - templates/smtp.rb
125
126
  - templates/spec_helper.rb
126
127
  - templates/suspenders_gitignore
@@ -147,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
148
  version: '0'
148
149
  requirements: []
149
150
  rubyforge_project:
150
- rubygems_version: 2.0.5
151
+ rubygems_version: 2.1.10
151
152
  signing_key:
152
153
  specification_version: 4
153
154
  summary: Generate a Rails app using thoughtbot's best practices.