welaika-suspenders 1.2.10 → 1.4.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
  SHA1:
3
- metadata.gz: 6e911a9c4100bc8ad23b5cfd311a67feded21cee
4
- data.tar.gz: ee75709876fd6433c90e5b64063bf69f0e7b7231
3
+ metadata.gz: 6bd75804513df3c2ca1d1ec1b762a773de7a4caf
4
+ data.tar.gz: cd57eda3e4cfd279910f39c8919255ff11932c6c
5
5
  SHA512:
6
- metadata.gz: 55ff84d327b1b29fe4f84b62205e92f5af7fc4eda6a4148dae5337729c40922454c792171107e1de2af015b3f00fe425dfec49aac891a75e4b00b79b488e0f6a
7
- data.tar.gz: 973bf6aedf39db63ead37ac0bd63e1ad7b20a178f55680a1083c72376fa1613bb48cf0ecb591e920aaa540edca3e745ca9f2843052de875fc7c23ef454641f2d
6
+ metadata.gz: 607d82380093cba26fd9861a824f53016bcb3701bf691934562cd6517b611ee7f3efaf4dc762063fb22a0ee441f7d963b4c1ea8b145f2b9ab9e1689d5378d3ae
7
+ data.tar.gz: 22f642a87e09108150ede87ea5261f50f8c74fd6fbf547361ded0f94aaa269e887e2c787670d4d9426706188e5ee9225fdd4d1cabbd86c53e573e1abe1e83dc1
Binary file
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ *.swp
3
+ .bundle
4
+ .rake_tasks
5
+ /bin/*
6
+ !bin/welaika-suspenders
7
+ pkg
8
+ test_project
9
+ tmp/aruba
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ notifications:
6
+ email: false
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
@@ -1,115 +1,102 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- welaika-suspenders (1.2.10)
5
- bundler
6
- hub
7
- rails
4
+ welaika-suspenders (1.4.0)
5
+ bundler (~> 1.3)
6
+ hub (~> 1.10)
7
+ rails (= 4.0.0)
8
8
 
9
9
  GEM
10
- remote: http://rubygems.org/
10
+ remote: https://rubygems.org/
11
11
  specs:
12
- actionmailer (3.2.13)
13
- actionpack (= 3.2.13)
12
+ actionmailer (4.0.0)
13
+ actionpack (= 4.0.0)
14
14
  mail (~> 2.5.3)
15
- actionpack (3.2.13)
16
- activemodel (= 3.2.13)
17
- activesupport (= 3.2.13)
18
- builder (~> 3.0.0)
15
+ actionpack (4.0.0)
16
+ activesupport (= 4.0.0)
17
+ builder (~> 3.1.0)
19
18
  erubis (~> 2.7.0)
20
- journey (~> 1.0.4)
21
- rack (~> 1.4.5)
22
- rack-cache (~> 1.2)
23
- rack-test (~> 0.6.1)
24
- sprockets (~> 2.2.1)
25
- activemodel (3.2.13)
26
- activesupport (= 3.2.13)
27
- builder (~> 3.0.0)
28
- activerecord (3.2.13)
29
- activemodel (= 3.2.13)
30
- activesupport (= 3.2.13)
31
- arel (~> 3.0.2)
32
- tzinfo (~> 0.3.29)
33
- activeresource (3.2.13)
34
- activemodel (= 3.2.13)
35
- activesupport (= 3.2.13)
36
- activesupport (3.2.13)
37
- i18n (= 0.6.1)
38
- multi_json (~> 1.0)
39
- arel (3.0.2)
40
- aruba (0.4.11)
41
- childprocess (>= 0.2.3)
19
+ rack (~> 1.5.2)
20
+ rack-test (~> 0.6.2)
21
+ activemodel (4.0.0)
22
+ activesupport (= 4.0.0)
23
+ builder (~> 3.1.0)
24
+ activerecord (4.0.0)
25
+ activemodel (= 4.0.0)
26
+ activerecord-deprecated_finders (~> 1.0.2)
27
+ activesupport (= 4.0.0)
28
+ arel (~> 4.0.0)
29
+ activerecord-deprecated_finders (1.0.3)
30
+ activesupport (4.0.0)
31
+ i18n (~> 0.6, >= 0.6.4)
32
+ minitest (~> 4.2)
33
+ multi_json (~> 1.3)
34
+ thread_safe (~> 0.1)
35
+ tzinfo (~> 0.3.37)
36
+ arel (4.0.0)
37
+ aruba (0.5.3)
38
+ childprocess (>= 0.3.6)
42
39
  cucumber (>= 1.1.1)
43
- ffi (>= 1.0.11)
44
- rspec (>= 2.7.0)
45
- builder (3.0.4)
46
- childprocess (0.3.6)
47
- ffi (~> 1.0, >= 1.0.6)
48
- cucumber (1.1.9)
40
+ rspec-expectations (>= 2.7.0)
41
+ atomic (1.1.10)
42
+ builder (3.1.4)
43
+ childprocess (0.3.9)
44
+ ffi (~> 1.0, >= 1.0.11)
45
+ cucumber (1.3.5)
49
46
  builder (>= 2.1.2)
50
- diff-lcs (>= 1.1.2)
51
- gherkin (~> 2.9.0)
52
- json (>= 1.4.6)
53
- term-ansicolor (>= 1.0.6)
54
- diff-lcs (1.1.3)
47
+ diff-lcs (>= 1.1.3)
48
+ gherkin (~> 2.12.0)
49
+ multi_json (~> 1.7.5)
50
+ multi_test (>= 0.0.2)
51
+ diff-lcs (1.2.4)
55
52
  erubis (2.7.0)
56
- ffi (1.3.1)
57
- gherkin (2.9.3)
58
- json (>= 1.4.6)
59
- hike (1.2.2)
60
- hub (1.10.5)
61
- i18n (0.6.1)
62
- journey (1.0.4)
63
- json (1.7.6)
64
- mail (2.5.3)
65
- i18n (>= 0.4.0)
53
+ ffi (1.9.0)
54
+ gherkin (2.12.0)
55
+ multi_json (~> 1.3)
56
+ hike (1.2.3)
57
+ hub (1.10.6)
58
+ i18n (0.6.4)
59
+ mail (2.5.4)
66
60
  mime-types (~> 1.16)
67
61
  treetop (~> 1.4.8)
68
62
  mime-types (1.23)
69
- multi_json (1.7.3)
63
+ minitest (4.7.5)
64
+ multi_json (1.7.7)
65
+ multi_test (0.0.2)
70
66
  polyglot (0.3.3)
71
- rack (1.4.5)
72
- rack-cache (1.2)
73
- rack (>= 0.4)
74
- rack-ssl (1.3.3)
75
- rack
67
+ rack (1.5.2)
76
68
  rack-test (0.6.2)
77
69
  rack (>= 1.0)
78
- rails (3.2.13)
79
- actionmailer (= 3.2.13)
80
- actionpack (= 3.2.13)
81
- activerecord (= 3.2.13)
82
- activeresource (= 3.2.13)
83
- activesupport (= 3.2.13)
84
- bundler (~> 1.0)
85
- railties (= 3.2.13)
86
- railties (3.2.13)
87
- actionpack (= 3.2.13)
88
- activesupport (= 3.2.13)
89
- rack-ssl (~> 1.3.2)
70
+ rails (4.0.0)
71
+ actionmailer (= 4.0.0)
72
+ actionpack (= 4.0.0)
73
+ activerecord (= 4.0.0)
74
+ activesupport (= 4.0.0)
75
+ bundler (>= 1.3.0, < 2.0)
76
+ railties (= 4.0.0)
77
+ sprockets-rails (~> 2.0.0)
78
+ railties (4.0.0)
79
+ actionpack (= 4.0.0)
80
+ activesupport (= 4.0.0)
90
81
  rake (>= 0.8.7)
91
- rdoc (~> 3.4)
92
- thor (>= 0.14.6, < 2.0)
93
- rake (10.0.4)
94
- rdoc (3.12.2)
95
- json (~> 1.4)
96
- rspec (2.12.0)
97
- rspec-core (~> 2.12.0)
98
- rspec-expectations (~> 2.12.0)
99
- rspec-mocks (~> 2.12.0)
100
- rspec-core (2.12.2)
101
- rspec-expectations (2.12.1)
102
- diff-lcs (~> 1.1.3)
103
- rspec-mocks (2.12.1)
104
- sprockets (2.2.2)
82
+ thor (>= 0.18.1, < 2.0)
83
+ rake (10.1.0)
84
+ rspec-expectations (2.14.0)
85
+ diff-lcs (>= 1.1.3, < 2.0)
86
+ sprockets (2.10.0)
105
87
  hike (~> 1.2)
106
88
  multi_json (~> 1.0)
107
89
  rack (~> 1.0)
108
90
  tilt (~> 1.1, != 1.3.0)
109
- term-ansicolor (1.0.7)
91
+ sprockets-rails (2.0.0)
92
+ actionpack (>= 3.0)
93
+ activesupport (>= 3.0)
94
+ sprockets (~> 2.8)
110
95
  thor (0.18.1)
96
+ thread_safe (0.1.2)
97
+ atomic
111
98
  tilt (1.4.1)
112
- treetop (1.4.12)
99
+ treetop (1.4.14)
113
100
  polyglot
114
101
  polyglot (>= 0.3.1)
115
102
  tzinfo (0.3.37)
@@ -118,6 +105,6 @@ PLATFORMS
118
105
  ruby
119
106
 
120
107
  DEPENDENCIES
121
- aruba (~> 0.4.11)
122
- cucumber (~> 1.1.9)
108
+ aruba (~> 0.5.2)
109
+ cucumber (~> 1.2)
123
110
  welaika-suspenders!
data/NEWS.md CHANGED
@@ -1,3 +1,22 @@
1
+ 1.4.0 (July 21, 2013)
2
+
3
+ * Support Rails 4.
4
+ * Support Ruby 2.
5
+ * Remove jQuery UI.
6
+ * Factories spec works for non-ActiveRecord objects.
7
+ * Use New Relic RPM gem >= 3.5.7 for Heroku request queue accuracy.
8
+ * Abort RSpec runs on first failure.
9
+ * Replace custom email validator with gem.
10
+
11
+ 1.3.0 (May 13, 2013)
12
+
13
+ * Switch web server from Thin to Unicorn
14
+ * Set up database before setting up RSpec so that the rspec:install task works
15
+ * Add Delayed::Job
16
+ * Clean up cruft from ActionMailer delivery configuration
17
+ * strong_parameters now raises an error in development
18
+ * Enforce Ruby 1.9.2+ in the gemspec
19
+
1
20
  1.2.2 (March 14, 2013)
2
21
 
3
22
  * Fix Syntax error in staging/production environment config files.
data/README.md CHANGED
@@ -15,7 +15,7 @@ Then run:
15
15
 
16
16
  welaika-suspenders projectname
17
17
 
18
- This will create a Rails 3.2 app in `projectname`. This script creates a
18
+ This will create a Rails 4.0 app in `projectname`. This script creates a
19
19
  new git repository. It is not meant to be used against an existing repo.
20
20
 
21
21
  Gemfile
@@ -29,7 +29,29 @@ It includes application gems like:
29
29
 
30
30
  * [Airbrake](https://github.com/airbrake/airbrake) for exception notification
31
31
  * [Bourbon](https://github.com/thoughtbot/bourbon) for Sass mixins
32
- * [Simple Form](https://github.com/plataformatec/simple_form) for form markup and style
32
+ * [Delayed Job](https://github.com/collectiveidea/delayed_job) for background
33
+ processing
34
+ * [Email Validator](https://github.com/balexand/email_validator) for email
35
+ validation
36
+ * [Flutie](https://github.com/thoughtbot/flutie) for `page_title` and
37
+ `body_class` view helpers
38
+ * [High Voltage](https://github.com/thoughtbot/high_voltage) for static pages
39
+ * [jQuery Rails](https://github.com/rails/jquery-rails) for jQuery
40
+ * [Neat](https://github.com/thoughtbot/neat) for semantic grids
41
+ * [Postgres](https://github.com/ged/ruby-pg) for access to the Postgres database
42
+ * [Rack Timeout](https://github.com/kch/rack-timeout) to abort requests that are
43
+ taking too long
44
+ * [Recipient Interceptor](https://github.com/croaky/recipient_interceptor) to
45
+ avoid accidentally sending emails to real people from staging
46
+ * [Simple Form](https://github.com/plataformatec/simple_form) for form markup
47
+ and style
48
+ * [Unicorn](https://github.com/defunkt/unicorn) to serve HTTP requests
49
+
50
+ And gems only for staging and production like:
51
+
52
+ * [New Relic RPM](https://github.com/newrelic/rpm) for monitoring performance
53
+ * [Rails 12 Factor](https://github.com/heroku/rails_12factor) to making running
54
+ Rails 4 apps easier on Heroku
33
55
 
34
56
  And testing gems like:
35
57
 
@@ -81,6 +103,8 @@ This has the same effect as running:
81
103
  Dependencies
82
104
  ------------
83
105
 
106
+ Suspenders requires Ruby 1.9.2 or greater.
107
+
84
108
  Some gems included in Suspenders have native extensions. You should have GCC
85
109
  installed on your machine before generating an app with Suspenders.
86
110
 
@@ -49,20 +49,21 @@ Then 'I can cleanly rake the project' do
49
49
  }
50
50
  end
51
51
 
52
- Then /^"(.*)" should not be installed$/ do |gem_name|
52
+ Then %r{"(.*)" should not be installed} do |gem_name|
53
53
  in_current_dir do
54
54
  system("bundle show #{gem_name} 2>&1 > /dev/null").should be_false
55
55
  end
56
56
  end
57
57
 
58
- Then /^"(.*)" should not be included in "(.*)"$/ do |content, file_path|
58
+ Then %r{"(.*)" should not be included in "(.*)"} do |content, file_path|
59
59
  check_file_content file_path, content, false
60
60
  end
61
61
 
62
- Then /^the "([^"]*)" Heroku app should exist$/ do |app_name|
62
+ Then %r{the "([^"]*)" Heroku app should exist} do |app_name|
63
63
  FakeHeroku.should have_created_app(app_name)
64
64
  end
65
65
 
66
- Then /^the "([^"]*)" Github repo should exist$/ do |repo_name|
66
+ Then %r{the "([^"]*)" Github repo should exist} do |repo_name|
67
67
  FakeGithub.should have_created_repo(repo_name)
68
68
  end
69
+
@@ -15,10 +15,15 @@ module WelaikaSuspenders
15
15
  end
16
16
 
17
17
  def action_mailer_host(rails_env, host)
18
+ host_config = "config.action_mailer.default_url_options = { host: '#{host}' }"
19
+ configure_environment(rails_env, host_config)
20
+ end
21
+
22
+ def configure_environment(rails_env, config)
18
23
  inject_into_file(
19
24
  "config/environments/#{rails_env}.rb",
20
- "\n\n config.action_mailer.default_url_options = { :host => '#{host}' }",
21
- :before => "\nend"
25
+ "\n\n #{config}",
26
+ before: "\nend"
22
27
  )
23
28
  end
24
29
 
@@ -14,16 +14,38 @@ module WelaikaSuspenders
14
14
  remove_file 'app/assets/images/rails.png'
15
15
  end
16
16
 
17
- def raise_delivery_errors
17
+ def raise_on_delivery_errors
18
18
  replace_in_file 'config/environments/development.rb',
19
19
  'raise_delivery_errors = false', 'raise_delivery_errors = true'
20
20
  end
21
21
 
22
+ def raise_on_unpermitted_parameters
23
+ configure_environment 'development',
24
+ 'config.action_controller.action_on_unpermitted_parameters = :raise'
25
+ end
26
+
22
27
  def provide_setup_script
23
28
  copy_file 'bin_setup', 'bin/setup'
24
29
  run 'chmod a+x bin/setup'
25
30
  end
26
31
 
32
+ def configure_generators
33
+ config = <<-RUBY
34
+ config.generators do |generate|
35
+ generate.helper false
36
+ generate.javascript_engine false
37
+ generate.request_specs false
38
+ generate.routing_specs false
39
+ generate.stylesheets false
40
+ generate.test_framework :rspec
41
+ generate.view_specs false
42
+ end
43
+
44
+ RUBY
45
+
46
+ inject_into_class 'config/application.rb', 'Application', config
47
+ end
48
+
27
49
  def enable_factory_girl_syntax
28
50
  copy_file 'factory_girl_syntax_rspec.rb', 'spec/support/factory_girl.rb'
29
51
  end
@@ -39,25 +61,14 @@ module WelaikaSuspenders
39
61
  prepend_file 'config/environments/production.rb',
40
62
  "require Rails.root.join('config/initializers/smtp')\n"
41
63
 
42
- production_config = <<-RUBY
43
- config.action_mailer.delivery_method = :smtp
44
- config.action_mailer.smtp_settings = SMTP_SETTINGS
45
- RUBY
64
+ config = <<-RUBY
46
65
 
47
- development_config = <<-RUBY
66
+ config.action_mailer.delivery_method = :smtp
67
+ config.action_mailer.smtp_settings = SMTP_SETTINGS
48
68
  RUBY
49
69
 
50
- inject_into_file(
51
- 'config/environments/production.rb',
52
- production_config,
70
+ inject_into_file 'config/environments/production.rb', config,
53
71
  :after => 'config.action_mailer.raise_delivery_errors = false'
54
- )
55
-
56
- inject_into_file(
57
- 'config/environments/development.rb',
58
- "\n\n config.action_mailer.delivery_method = :letter_opener",
59
- :before => "\nend"
60
- )
61
72
  end
62
73
 
63
74
  def setup_staging_environment
@@ -124,38 +135,30 @@ module WelaikaSuspenders
124
135
  copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
125
136
  end
126
137
 
138
+ def configure_dragonfly
139
+ copy_file 'dragonfly_initializer.rb', 'config/initializers/dragonfly.rb'
140
+ copy_file 'create_dragonfly_jobs.rb', 'db/migrate/20130713151359_create_dragonfly_jobs.rb'
141
+ end
142
+
127
143
  def configure_rspec
128
144
  remove_file '.rspec'
129
145
  copy_file 'rspec', '.rspec'
146
+ prepend_file 'spec/spec_helper.rb', rails_root_definition
130
147
  prepend_file 'spec/spec_helper.rb', simplecov_init
131
148
 
132
- config = <<-RUBY
133
- config.generators do |generate|
134
- generate.test_framework :rspec
135
- generate.helper false
136
- generate.stylesheets false
137
- generate.javascript_engine false
138
- generate.view_specs false
139
- end
140
-
141
- RUBY
142
-
143
- inject_into_class 'config/application.rb', 'Application', config
144
149
  replace_in_file 'spec/spec_helper.rb', /RSpec.configure do.*end\n/m, ""
145
150
 
151
+ copy_file 'capybara_selectors.rb', 'spec/support/capybara_selectors.rb'
152
+ copy_file 'exist_in_db.rb', 'spec/support/matchers/exist_in_db.rb'
153
+ copy_file 'dragonfly.rb', 'spec/support/dragonfly.rb'
154
+
146
155
  copy_file 'rspec_config.rb', 'spec/support/rspec_config.rb'
147
156
  copy_file 'unit_spec_helper.rb', 'spec/unit_spec_helper.rb'
148
157
  copy_file 'model_spec_helper.rb', 'spec/model_spec_helper.rb'
149
158
  end
150
159
 
151
- def blacklist_active_record_attributes
152
- replace_in_file 'config/application.rb',
153
- 'config.active_record.whitelist_attributes = true',
154
- 'config.active_record.whitelist_attributes = false'
155
- end
156
-
157
- def configure_strong_parameters
158
- copy_file 'strong_parameters.rb', 'config/initializers/strong_parameters.rb'
160
+ def configure_background_jobs_for_rspec
161
+ copy_file 'background_jobs_rspec.rb', 'spec/support/background_jobs.rb'
159
162
  end
160
163
 
161
164
  def configure_time_zone
@@ -188,7 +191,7 @@ module WelaikaSuspenders
188
191
 
189
192
  def configure_capybara_webkit
190
193
  append_file 'spec/spec_helper.rb' do
191
- "\nCapybara.javascript_driver = :webkit"
194
+ "\nCapybara.javascript_driver = :webkit\n"
192
195
  end
193
196
  end
194
197
 
@@ -196,16 +199,19 @@ module WelaikaSuspenders
196
199
  generate 'clearance:install'
197
200
  end
198
201
 
202
+ def configure_unicorn
203
+ copy_file 'unicorn.rb', 'config/unicorn.rb'
204
+ end
205
+
199
206
  def setup_foreman
200
207
  copy_file 'sample.env', '.sample.env'
201
208
  copy_file 'sample.env', '.env'
202
209
  copy_file 'Procfile', 'Procfile'
203
- copy_file 'unicorn.rb', 'config/unicorn.rb'
204
210
  end
205
211
 
206
212
  def setup_stylesheets
207
213
  remove_file 'app/assets/stylesheets/application.css'
208
- copy_file 'import_sass_styles', 'app/assets/stylesheets/application.css.sass'
214
+ copy_file 'application.css.scss', 'app/assets/stylesheets/application.css.scss'
209
215
  end
210
216
 
211
217
  def gitignore_files
@@ -225,16 +231,16 @@ module WelaikaSuspenders
225
231
  'spec/presenters',
226
232
  'spec/services',
227
233
  'spec/support',
228
- 'spec/support/matchers',
229
- 'spec/support/mixins',
230
- 'spec/support/shared_contexts',
231
234
  'spec/support/shared_examples',
235
+ 'spec/support/matchers',
232
236
  'spec/views',
233
237
  ].each do |dir|
234
- empty_directory_with_gitkeep dir
238
+ run "mkdir #{dir}"
239
+ run "touch #{dir}/.gitkeep"
235
240
  end
236
241
  end
237
242
 
243
+
238
244
  def init_git
239
245
  run 'git init'
240
246
  end
@@ -277,17 +283,13 @@ module WelaikaSuspenders
277
283
  "Application.routes.draw do\nend"
278
284
  end
279
285
 
280
- def add_email_validator
281
- copy_file 'email_validator.rb', 'app/validators/email_validator.rb'
282
- end
283
-
284
286
  def disable_xml_params
285
287
  copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb'
286
288
  end
287
289
 
288
290
  def setup_default_rake_task
289
291
  append_file 'Rakefile' do
290
- "task(:default).clear\ntask :default => [:spec]"
292
+ "task(:default).clear\ntask :default => [:spec]\n"
291
293
  end
292
294
  end
293
295
 
@@ -307,6 +309,10 @@ module WelaikaSuspenders
307
309
  def simplecov_init
308
310
  IO.read find_in_source_paths('simplecov_init.rb')
309
311
  end
312
+
313
+ def rails_root_definition
314
+ IO.read find_in_source_paths('rails_root_definition.rb')
315
+ end
310
316
  end
311
317
  end
312
318
 
@@ -36,6 +36,7 @@ module WelaikaSuspenders
36
36
  invoke :copy_miscellaneous_files
37
37
  invoke :customize_error_pages
38
38
  invoke :remove_routes_comment_lines
39
+ invoke :configure_dragonfly
39
40
  invoke :setup_git
40
41
  invoke :create_heroku_apps
41
42
  invoke :create_github_repo
@@ -47,10 +48,28 @@ module WelaikaSuspenders
47
48
  build :remove_rails_logo_image
48
49
  end
49
50
 
51
+ def customize_gemfile
52
+ build :replace_gemfile
53
+ build :set_ruby_to_version_being_used
54
+ bundle_command 'install --binstubs=bin/stubs'
55
+ end
56
+
57
+ def setup_database
58
+ say 'Setting up database'
59
+
60
+ if 'postgresql' == options[:database]
61
+ build :use_postgres_config_template
62
+ end
63
+
64
+ build :create_database
65
+ end
66
+
50
67
  def setup_development_environment
51
68
  say 'Setting up the development environment'
52
- build :raise_delivery_errors
69
+ build :raise_on_delivery_errors
70
+ build :raise_on_unpermitted_parameters
53
71
  build :provide_setup_script
72
+ build :configure_generators
54
73
  end
55
74
 
56
75
  def setup_test_environment
@@ -59,6 +78,7 @@ module WelaikaSuspenders
59
78
  build :test_factories_first
60
79
  build :generate_rspec
61
80
  build :configure_rspec
81
+ build :configure_background_jobs_for_rspec
62
82
  build :enable_database_cleaner
63
83
  build :configure_capybara_webkit
64
84
  build :setup_guard_spork
@@ -93,12 +113,6 @@ module WelaikaSuspenders
93
113
  build :setup_presenters
94
114
  end
95
115
 
96
- def customize_gemfile
97
- build :replace_gemfile
98
- build :set_ruby_to_version_being_used
99
- bundle_command 'install --binstubs=bin/stubs'
100
- end
101
-
102
116
  def setup_database
103
117
  say 'Setting up database'
104
118
 
@@ -118,8 +132,8 @@ module WelaikaSuspenders
118
132
  build :configure_time_formats
119
133
  build :configure_rack_timeout
120
134
  build :disable_xml_params
121
- build :add_email_validator
122
135
  build :setup_default_rake_task
136
+ build :configure_unicorn
123
137
  build :setup_foreman
124
138
  end
125
139
 
@@ -175,9 +189,13 @@ module WelaikaSuspenders
175
189
  build :remove_routes_comment_lines
176
190
  end
177
191
 
192
+ def configure_dragonfly
193
+ say 'Configuring dragonfly'
194
+ build :configure_dragonfly
195
+ end
196
+
178
197
  def outro
179
198
  say 'Congratulations! You just pulled our suspenders.'
180
- say "Remember to run 'rails generate airbrake' with your API key."
181
199
  end
182
200
 
183
201
  def run_bundle
@@ -195,3 +213,4 @@ module WelaikaSuspenders
195
213
  end
196
214
  end
197
215
  end
216
+
@@ -1,4 +1,4 @@
1
1
  module WelaikaSuspenders
2
- VERSION = '1.2.10'
2
+ VERSION = '1.4.0'
3
3
  end
4
4
 
Binary file
@@ -2,16 +2,19 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'airbrake'
4
4
  gem 'bourbon'
5
+ gem 'dragonfly'
6
+ gem 'email_validator'
5
7
  gem 'flutie'
6
8
  gem 'jquery-rails'
9
+ gem 'neat'
7
10
  gem 'pg'
11
+ gem 'rack-cache'
8
12
  gem 'rack-timeout'
9
- gem 'rails', '>= 3.2.11'
13
+ gem 'rails', '>= 4.0.0'
10
14
  gem 'recipient_interceptor'
11
15
  gem 'showcase'
12
16
  gem 'simple_form'
13
17
  gem 'slim-rails'
14
- gem 'strong_parameters'
15
18
  gem 'unicorn'
16
19
 
17
20
  group :assets do
@@ -47,6 +50,7 @@ group :test do
47
50
  end
48
51
 
49
52
  group :staging, :production do
50
- gem 'newrelic_rpm'
53
+ gem 'newrelic_rpm', '>= 3.5.7'
54
+ gem 'rails_12factor'
51
55
  end
52
56
 
@@ -1,2 +1,3 @@
1
1
  web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
2
+ # worker: bundle exec rake jobs:work
2
3
 
@@ -0,0 +1,8 @@
1
+ @charset 'utf-8';
2
+
3
+ ///////////////////////////////////////////////////////////////////////////////
4
+
5
+ @import 'bourbon';
6
+ @import 'neat';
7
+
8
+ ///////////////////////////////////////////////////////////////////////////////
@@ -0,0 +1,19 @@
1
+ module BackgroundJobs
2
+ def run_background_jobs_immediately
3
+ delay_jobs = Delayed::Worker.delay_jobs
4
+ Delayed::Worker.delay_jobs = false
5
+ yield
6
+ ensure
7
+ Delayed::Worker.delay_jobs = delay_jobs
8
+ end
9
+ end
10
+
11
+ RSpec.configure do |config|
12
+ config.around(:each, type: :feature) do |example|
13
+ run_background_jobs_immediately do
14
+ example.run
15
+ end
16
+ end
17
+
18
+ config.include BackgroundJobs
19
+ end
@@ -0,0 +1,29 @@
1
+ Capybara.add_selector :record do
2
+ xpath do |record|
3
+ XPath.css("#" + ActionController::RecordIdentifier.dom_id(record))
4
+ end
5
+
6
+ match do |record|
7
+ record.is_a?(ActiveRecord::Base)
8
+ end
9
+ end
10
+
11
+ Capybara.add_selector :alert do
12
+ xpath do
13
+ XPath.css(".flash.alert")
14
+ end
15
+ end
16
+
17
+ Capybara.add_selector :notice do
18
+ xpath do
19
+ XPath.css(".flash.notice")
20
+ end
21
+ end
22
+
23
+ Capybara.add_selector :role do
24
+ xpath do |role|
25
+ XPath.css("[role=#{role}]")
26
+ end
27
+ end
28
+
29
+
@@ -0,0 +1,9 @@
1
+ class CreateDragonflyJobs < ActiveRecord::Migration
2
+ def change
3
+ create_table :dragonfly_jobs do |t|
4
+ t.string :uid
5
+ t.string :job
6
+ end
7
+ end
8
+ end
9
+
@@ -1,3 +1,5 @@
1
+ require 'database_cleaner'
2
+
1
3
  RSpec.configure do |config|
2
4
  config.before(:suite) do
3
5
  DatabaseCleaner.clean_with(:deletion)
@@ -1,3 +1,3 @@
1
1
  # Protect against injection attacks
2
2
  # http://www.kb.cert.org/vuls/id/380039
3
- ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML)
3
+ ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML)
@@ -0,0 +1,9 @@
1
+ require 'uri'
2
+ require 'dragonfly'
3
+ require 'rack/cache'
4
+
5
+ app = Dragonfly[:images]
6
+ app.configure_with(:imagemagick)
7
+ app.define_macro(ActiveRecord::Base, :image_accessor)
8
+ app.define_macro(ActiveRecord::Base, :file_accessor)
9
+
@@ -0,0 +1,47 @@
1
+ require 'uri'
2
+ require 'dragonfly'
3
+ require 'rack/cache'
4
+
5
+ app = Dragonfly[:images]
6
+ app.configure_with(:rails)
7
+ app.configure_with(:imagemagick)
8
+ app.define_macro(ActiveRecord::Base, :image_accessor)
9
+ app.define_macro(ActiveRecord::Base, :file_accessor)
10
+
11
+ rack_cache_already_inserted = Rails.application.config.action_controller.perform_caching && Rails.application.config.action_dispatch.rack_cache
12
+
13
+ Rails.application.middleware.insert 0, Rack::Cache, {
14
+ :verbose => false,
15
+ :metastore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces
16
+ :entitystore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/body")
17
+ } unless rack_cache_already_inserted
18
+
19
+ Rails.application.middleware.insert_after Rack::Cache, Dragonfly::Middleware, :images
20
+
21
+ if ENV['S3_BUCKET']
22
+ class DragonflyJob < ActiveRecord::Base
23
+ before_destroy do |thumb|
24
+ Dragonfly[:images].datastore.destroy(thumb.uid)
25
+ end
26
+ end
27
+
28
+ app.cache_duration = 3600*24*365*3
29
+ app.configure do |c|
30
+ c.define_url do |app, job, opts|
31
+ thumb = DragonflyJob.find_by_job(job.serialize)
32
+ if !thumb
33
+ uid = job.store
34
+ thumb = DragonflyJob.create!(uid: uid, job: job.serialize)
35
+ end
36
+ app.datastore.url_for(thumb.uid)
37
+ end
38
+ end
39
+ app.datastore = Dragonfly::DataStorage::S3DataStore.new
40
+ app.datastore.configure do |c|
41
+ c.bucket_name = ENV['S3_BUCKET']
42
+ c.access_key_id = ENV['S3_KEY']
43
+ c.secret_access_key = ENV['S3_SECRET']
44
+ c.region = ENV['S3_REGION']
45
+ end
46
+ end
47
+
@@ -0,0 +1,6 @@
1
+ RSpec::Matchers.define :exist_in_db do
2
+ match do |actual|
3
+ actual.class.exists?(actual.id)
4
+ end
5
+ end
6
+
@@ -1,14 +1,14 @@
1
- require 'spec_helper'
1
+ require 'model_spec_helper'
2
2
 
3
- describe 'validate FactoryGirl factories' do
4
- FactoryGirl.factories.each do |factory|
5
- context "with factory for :#{factory.name}" do
6
- subject { FactoryGirl.build(factory.name) }
3
+ FactoryGirl.factories.map(&:name).each do |factory_name|
4
+ describe "Factory :#{factory_name}" do
5
+ it 'is valid' do
6
+ factory = build(factory_name)
7
7
 
8
- it 'is valid' do
9
- is_valid = subject.valid?
10
- expect(is_valid).to be_true, subject.errors.full_messages.join(',')
8
+ if factory.respond_to?(:valid?)
9
+ expect(factory).to be_valid, factory.errors.full_messages.join(',')
11
10
  end
12
11
  end
13
12
  end
14
13
  end
14
+
@@ -1,6 +1,6 @@
1
-
2
1
  if defined?(RSpec)
3
2
  desc 'Run factory specs.'
3
+
4
4
  RSpec::Core::RakeTask.new(:factory_specs) do |t|
5
5
  t.pattern = './spec/models/factories_spec.rb'
6
6
  end
@@ -9,13 +9,27 @@ ActiveRecord::Base.establish_connection(db_config['test'])
9
9
  require File.join(RAILS_ROOT, "spec/support/database_cleaner.rb")
10
10
 
11
11
  # add activerecord plugins here
12
+ require 'email_validator'
12
13
  # require 'friendly_id'
13
14
 
15
+ # Needed by rspec-rails to work without the whole Rails dependency
16
+ unless defined?(Rails)
17
+ module Rails
18
+ module VERSION
19
+ STRING = '4'
20
+ end
21
+ end
22
+ end
23
+
24
+ require 'rspec/rails/extensions/active_record/base'
25
+
14
26
  autoload_paths = ActiveSupport::Dependencies.autoload_paths
15
27
  %w(app/models app/validators).each do |path|
16
28
  autoload_paths.push(path) unless autoload_paths.include?(path)
17
29
  end
18
30
 
31
+ require File.join(RAILS_ROOT, "spec/support/dragonfly.rb")
32
+
19
33
  # find definitions only if factory girls has not been already required
20
34
  if require 'factory_girl'
21
35
  require File.join(RAILS_ROOT, "spec/support/factory_girl.rb")
@@ -0,0 +1,2 @@
1
+ RAILS_ROOT = File.expand_path('../../', __FILE__) unless defined?(RAILS_ROOT)
2
+
@@ -6,6 +6,7 @@ RSpec.configure do |config|
6
6
  end
7
7
  config.mock_with :mocha
8
8
  config.order = "random"
9
+ config.fail_fast = true
9
10
  if defined?(Rails)
10
11
  config.fixture_path = "#{::Rails.root}/spec/fixtures"
11
12
  config.use_transactional_fixtures = false
@@ -1,5 +1,7 @@
1
- worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
2
- timeout 15
1
+ # https://devcenter.heroku.com/articles/rails-unicorn
2
+
3
+ worker_processes (ENV['WEB_CONCURRENCY'] || 3).to_i
4
+ timeout (ENV['WEB_TIMEOUT'] || 5).to_i
3
5
  preload_app true
4
6
 
5
7
  before_fork do |server, worker|
@@ -8,14 +10,18 @@ before_fork do |server, worker|
8
10
  Process.kill 'QUIT', Process.pid
9
11
  end
10
12
 
11
- defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
13
+ if defined? ActiveRecord::Base
14
+ ActiveRecord::Base.connection.disconnect!
15
+ end
12
16
  end
13
17
 
14
18
  after_fork do |server, worker|
15
19
  Signal.trap 'TERM' do
16
- puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
20
+ puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
17
21
  end
18
22
 
19
- defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
23
+ if defined? ActiveRecord::Base
24
+ ActiveRecord::Base.establish_connection
25
+ end
20
26
  end
21
27
 
@@ -2,7 +2,7 @@ require 'active_support/dependencies'
2
2
  require 'showcase'
3
3
 
4
4
  # add project root to load path
5
- RAILS_ROOT = File.expand_path('../../', __FILE__)
5
+ RAILS_ROOT = File.expand_path('../../', __FILE__) unless defined?(RAILS_ROOT)
6
6
  $LOAD_PATH.unshift(RAILS_ROOT) unless $LOAD_PATH.include?(RAILS_ROOT)
7
7
 
8
8
  require File.join(RAILS_ROOT, "spec/support/rspec_config.rb")
@@ -12,3 +12,4 @@ autoload_paths = ActiveSupport::Dependencies.autoload_paths
12
12
  %w(app/presenters).each do |path|
13
13
  autoload_paths.push(path) unless autoload_paths.include?(path)
14
14
  end
15
+
@@ -1,37 +1,35 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
2
+ $:.push File.expand_path('../lib', __FILE__)
3
3
  require 'welaika_suspenders/version'
4
4
  require 'date'
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = 'welaika-suspenders'
8
- s.version = WelaikaSuspenders::VERSION
9
- s.date = Date.today.strftime('%Y-%m-%d')
7
+ s.required_ruby_version = '>= 1.9.2'
8
+ s.add_dependency 'bundler', '~> 1.3'
9
+ s.add_dependency 'hub', '~> 1.10'
10
+ s.add_dependency 'rails', '4.0.0'
11
+ s.add_development_dependency 'aruba', '~> 0.5.2'
12
+ s.add_development_dependency 'cucumber', '~> 1.2'
10
13
  s.authors = ['thoughtbot', 'welaika']
11
- s.email = 'info@welaika.com'
12
- s.homepage = 'http://github.com/welaika/welaika-suspenders'
14
+ s.date = Date.today.strftime('%Y-%m-%d')
13
15
 
14
- s.summary = "Generate a Rails app using weLaika's best practices."
15
16
  s.description = <<-HERE
16
17
  Suspenders is a base Rails project that you can upgrade. It is used by
17
18
  thoughtbot to get a jump start on a working app. Use Suspenders if you're in a
18
19
  rush to build something amazing; don't use it if you like missing deadlines.
19
20
  HERE
20
21
 
21
- s.files = `git ls-files`.split("\n").
22
- reject { |file| file =~ /^\./ }.
23
- reject { |file| file =~ /^(rdoc|pkg)/ }
24
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
26
- s.require_paths = ["lib"]
27
-
28
- s.rdoc_options = ["--charset=UTF-8"]
22
+ s.email = 'info@welaika.com'
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |file| File.basename(file) }
29
24
  s.extra_rdoc_files = %w[README.md LICENSE]
30
-
31
- s.add_dependency 'rails'
32
- s.add_dependency 'bundler'
33
- s.add_dependency 'hub'
34
-
35
- s.add_development_dependency 'cucumber', '~> 1.1.9'
36
- s.add_development_dependency 'aruba', '~> 0.4.11'
25
+ s.files = `git ls-files`.split("\n")
26
+ s.homepage = 'http://github.com/welaika/welaika-suspenders'
27
+ s.license = 'MIT'
28
+ s.name = 'welaika-suspenders'
29
+ s.rdoc_options = ['--charset=UTF-8']
30
+ s.require_paths = ['lib']
31
+ s.summary = "Generate a Rails app using weLaika's best practices."
32
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
33
+ s.version = WelaikaSuspenders::VERSION
37
34
  end
35
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: welaika-suspenders
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.10
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoughtbot
@@ -9,78 +9,78 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-15 00:00:00.000000000 Z
12
+ date: 2013-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rails
15
+ name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ~>
19
19
  - !ruby/object:Gem::Version
20
- version: '0'
20
+ version: '1.3'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ~>
26
26
  - !ruby/object:Gem::Version
27
- version: '0'
27
+ version: '1.3'
28
28
  - !ruby/object:Gem::Dependency
29
- name: bundler
29
+ name: hub
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ~>
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: '1.10'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ~>
40
40
  - !ruby/object:Gem::Version
41
- version: '0'
41
+ version: '1.10'
42
42
  - !ruby/object:Gem::Dependency
43
- name: hub
43
+ name: rails
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - '='
47
47
  - !ruby/object:Gem::Version
48
- version: '0'
48
+ version: 4.0.0
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: '0'
55
+ version: 4.0.0
56
56
  - !ruby/object:Gem::Dependency
57
- name: cucumber
57
+ name: aruba
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - ~>
61
61
  - !ruby/object:Gem::Version
62
- version: 1.1.9
62
+ version: 0.5.2
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 1.1.9
69
+ version: 0.5.2
70
70
  - !ruby/object:Gem::Dependency
71
- name: aruba
71
+ name: cucumber
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ~>
75
75
  - !ruby/object:Gem::Version
76
- version: 0.4.11
76
+ version: '1.2'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - ~>
82
82
  - !ruby/object:Gem::Version
83
- version: 0.4.11
83
+ version: '1.2'
84
84
  description: |
85
85
  Suspenders is a base Rails project that you can upgrade. It is used by
86
86
  thoughtbot to get a jump start on a working app. Use Suspenders if you're in a
@@ -93,6 +93,9 @@ extra_rdoc_files:
93
93
  - README.md
94
94
  - LICENSE
95
95
  files:
96
+ - .DS_Store
97
+ - .gitignore
98
+ - .travis.yml
96
99
  - CONTRIBUTING.md
97
100
  - Gemfile
98
101
  - Gemfile.lock
@@ -115,39 +118,46 @@ files:
115
118
  - lib/welaika_suspenders/generators/app_generator.rb
116
119
  - lib/welaika_suspenders/version.rb
117
120
  - lib/welaika_suspenders/version_check.rb
121
+ - templates/.DS_Store
118
122
  - templates/Gemfile_clean
119
123
  - templates/Procfile
120
124
  - templates/README.md.erb
121
125
  - templates/_flashes.html.slim
122
126
  - templates/_javascript.html.slim
127
+ - templates/application.css.scss
128
+ - templates/background_jobs_rspec.rb
123
129
  - templates/bin_setup
130
+ - templates/capybara_selectors.rb
124
131
  - templates/config_locales_en.yml
132
+ - templates/create_dragonfly_jobs.rb
125
133
  - templates/database_cleaner_rspec.rb
126
134
  - templates/disable_xml_params.rb
127
- - templates/email_validator.rb
135
+ - templates/dragonfly.rb
136
+ - templates/dragonfly_initializer.rb
128
137
  - templates/errors.rb
138
+ - templates/exist_in_db.rb
129
139
  - templates/factories_spec.rb
130
140
  - templates/factories_spec_rake_task.rb
131
141
  - templates/factory_girl_syntax_rspec.rb
132
142
  - templates/import_common_javascripts
133
- - templates/import_sass_styles
134
143
  - templates/model_spec_helper.rb
135
144
  - templates/postgresql_database.yml.erb
136
145
  - templates/presenters.rb
137
146
  - templates/rack_timeout.rb
147
+ - templates/rails_root_definition.rb
138
148
  - templates/rspec
139
149
  - templates/rspec_config.rb
140
150
  - templates/sample.env
141
151
  - templates/simplecov_init.rb
142
152
  - templates/smtp.rb
143
- - templates/strong_parameters.rb
144
153
  - templates/suspenders_gitignore
145
154
  - templates/suspenders_layout.html.slim.erb
146
155
  - templates/unicorn.rb
147
156
  - templates/unit_spec_helper.rb
148
157
  - welaika-suspenders.gemspec
149
158
  homepage: http://github.com/welaika/welaika-suspenders
150
- licenses: []
159
+ licenses:
160
+ - MIT
151
161
  metadata: {}
152
162
  post_install_message:
153
163
  rdoc_options:
@@ -158,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
168
  requirements:
159
169
  - - '>='
160
170
  - !ruby/object:Gem::Version
161
- version: '0'
171
+ version: 1.9.2
162
172
  required_rubygems_version: !ruby/object:Gem::Requirement
163
173
  requirements:
164
174
  - - '>='
@@ -1,7 +0,0 @@
1
- class EmailValidator < ActiveModel::EachValidator
2
- def validate_each(record, attribute, value)
3
- unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
4
- record.errors[attribute] << (options[:message] || "is not an email")
5
- end
6
- end
7
- end
@@ -1 +0,0 @@
1
- @import bourbon
@@ -1 +0,0 @@
1
- ActiveRecord::Base.send :include, ActiveModel::ForbiddenAttributesProtection