welaika-suspenders 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.md +38 -0
  3. data/Gemfile +3 -0
  4. data/Gemfile.lock +123 -0
  5. data/LICENSE +21 -0
  6. data/NEWS.md +90 -0
  7. data/README.md +125 -0
  8. data/Rakefile +8 -0
  9. data/bin/welaika-suspenders +16 -0
  10. data/features/github_repo.feature +8 -0
  11. data/features/heroku_true.feature +9 -0
  12. data/features/rake_clean.feature +15 -0
  13. data/features/step_definitions/suspenders_steps.rb +68 -0
  14. data/features/support/bin/heroku +5 -0
  15. data/features/support/bin/hub +5 -0
  16. data/features/support/env.rb +10 -0
  17. data/features/support/fake_github.rb +21 -0
  18. data/features/support/fake_heroku.rb +21 -0
  19. data/lib/suspenders/actions.rb +35 -0
  20. data/lib/suspenders/app_builder.rb +295 -0
  21. data/lib/suspenders/generators/app_generator.rb +197 -0
  22. data/lib/suspenders/version.rb +3 -0
  23. data/templates/Gemfile_clean +46 -0
  24. data/templates/Procfile +1 -0
  25. data/templates/README.md.erb +9 -0
  26. data/templates/_flashes.html.slim +3 -0
  27. data/templates/_javascript.html.slim +5 -0
  28. data/templates/bin_setup +11 -0
  29. data/templates/config_locales_en.yml +11 -0
  30. data/templates/database_cleaner_rspec.rb +21 -0
  31. data/templates/disable_xml_params.rb +3 -0
  32. data/templates/email_validator.rb +7 -0
  33. data/templates/errors.rb +28 -0
  34. data/templates/factories_spec.rb +14 -0
  35. data/templates/factories_spec_rake_task.rb +9 -0
  36. data/templates/factory_girl_syntax_rspec.rb +3 -0
  37. data/templates/import_common_javascripts +4 -0
  38. data/templates/import_sass_styles +1 -0
  39. data/templates/model_spec_helper.rb +16 -0
  40. data/templates/postgresql_database.yml.erb +11 -0
  41. data/templates/presenters.rb +3 -0
  42. data/templates/rack_timeout.rb +1 -0
  43. data/templates/rspec +2 -0
  44. data/templates/rspec_config.rb +12 -0
  45. data/templates/sample.env +3 -0
  46. data/templates/simplecov_init.rb +3 -0
  47. data/templates/smtp.rb +10 -0
  48. data/templates/strong_parameters.rb +1 -0
  49. data/templates/suspenders_gitignore +12 -0
  50. data/templates/suspenders_layout.html.slim.erb +12 -0
  51. data/templates/unit_spec_helper.rb +14 -0
  52. data/welaika-suspenders.gemspec +37 -0
  53. metadata +180 -0
@@ -0,0 +1,295 @@
1
+ module Suspenders
2
+ class AppBuilder < Rails::AppBuilder
3
+ include Suspenders::Actions
4
+
5
+ def readme
6
+ template 'README.md.erb', 'README.md'
7
+ end
8
+
9
+ def remove_public_index
10
+ remove_file 'public/index.html'
11
+ end
12
+
13
+ def remove_rails_logo_image
14
+ remove_file 'app/assets/images/rails.png'
15
+ end
16
+
17
+ def raise_delivery_errors
18
+ replace_in_file 'config/environments/development.rb',
19
+ 'raise_delivery_errors = false', 'raise_delivery_errors = true'
20
+ end
21
+
22
+ def provide_setup_script
23
+ copy_file 'bin_setup', 'bin/setup'
24
+ run 'chmod a+x bin/setup'
25
+ end
26
+
27
+ def enable_factory_girl_syntax
28
+ copy_file 'factory_girl_syntax_rspec.rb', 'spec/support/factory_girl.rb'
29
+ end
30
+
31
+ def test_factories_first
32
+ copy_file 'factories_spec.rb', 'spec/models/factories_spec.rb'
33
+ append_file 'Rakefile', factories_spec_rake_task
34
+ end
35
+
36
+ def configure_smtp
37
+ copy_file 'smtp.rb', 'config/initializers/smtp.rb'
38
+
39
+ prepend_file 'config/environments/production.rb',
40
+ "require Rails.root.join('config/initializers/smtp')\n"
41
+
42
+ config = <<-RUBY
43
+ config.action_mailer.delivery_method = :smtp
44
+ config.action_mailer.smtp_settings = SMTP_SETTINGS
45
+ RUBY
46
+
47
+ inject_into_file 'config/environments/production.rb', config,
48
+ :after => 'config.action_mailer.raise_delivery_errors = false'
49
+ end
50
+
51
+ def setup_staging_environment
52
+ run 'cp config/environments/production.rb config/environments/staging.rb'
53
+
54
+ prepend_file 'config/environments/staging.rb',
55
+ "Mail.register_interceptor RecipientInterceptor.new(ENV['EMAIL_RECIPIENTS'])\n"
56
+ end
57
+
58
+ def initialize_on_precompile
59
+ inject_into_file 'config/application.rb',
60
+ "\n config.assets.initialize_on_precompile = false",
61
+ :after => 'config.assets.enabled = true'
62
+ end
63
+
64
+ def create_partials_directory
65
+ empty_directory 'app/views/application'
66
+ end
67
+
68
+ def create_shared_flashes
69
+ copy_file '_flashes.html.slim', 'app/views/application/_flashes.html.slim'
70
+ end
71
+
72
+ def create_shared_javascripts
73
+ copy_file '_javascript.html.slim', 'app/views/application/_javascript.html.slim'
74
+ end
75
+
76
+ def create_application_layout
77
+ remove_file 'app/views/layouts/application.html.erb'
78
+ template 'suspenders_layout.html.slim.erb',
79
+ 'app/views/layouts/application.html.slim',
80
+ :force => true
81
+ end
82
+
83
+ def setup_javascripts
84
+ remove_file 'app/assets/javascripts/application.js'
85
+ copy_file 'import_common_javascripts', 'app/assets/javascripts/application.js.coffee'
86
+ end
87
+
88
+ def setup_presenters
89
+ copy_file 'presenters.rb', 'config/initializers/basic_presenter.rb'
90
+ end
91
+
92
+ def use_postgres_config_template
93
+ template 'postgresql_database.yml.erb', 'config/database.yml',
94
+ :force => true
95
+ end
96
+
97
+ def create_database
98
+ bundle_command 'exec rake db:create'
99
+ end
100
+
101
+ def replace_gemfile
102
+ remove_file 'Gemfile'
103
+ copy_file 'Gemfile_clean', 'Gemfile'
104
+ end
105
+
106
+ def set_ruby_to_version_being_used
107
+ inject_into_file 'Gemfile', "\n\nruby '#{RUBY_VERSION}'",
108
+ after: /source 'https:\/\/rubygems.org'/
109
+ end
110
+
111
+ def enable_database_cleaner
112
+ copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
113
+ end
114
+
115
+ def configure_rspec
116
+ remove_file '.rspec'
117
+ copy_file 'rspec', '.rspec'
118
+ prepend_file 'spec/spec_helper.rb', simplecov_init
119
+
120
+ config = <<-RUBY
121
+ config.generators do |generate|
122
+ generate.test_framework :rspec
123
+ generate.helper false
124
+ generate.stylesheets false
125
+ generate.javascript_engine false
126
+ generate.view_specs false
127
+ end
128
+
129
+ RUBY
130
+
131
+ inject_into_class 'config/application.rb', 'Application', config
132
+ replace_in_file 'spec/spec_helper.rb', /RSpec.configure do.*end\n/m, ""
133
+
134
+ copy_file 'rspec_config.rb', 'spec/support/rspec_config.rb'
135
+ copy_file 'unit_spec_helper.rb', 'spec/unit_spec_helper.rb'
136
+ copy_file 'model_spec_helper.rb', 'spec/model_spec_helper.rb'
137
+ end
138
+
139
+ def blacklist_active_record_attributes
140
+ replace_in_file 'config/application.rb',
141
+ 'config.active_record.whitelist_attributes = true',
142
+ 'config.active_record.whitelist_attributes = false'
143
+ end
144
+
145
+ def configure_strong_parameters
146
+ copy_file 'strong_parameters.rb', 'config/initializers/strong_parameters.rb'
147
+ end
148
+
149
+ def configure_time_zone
150
+ config = <<-RUBY
151
+ config.active_record.default_timezone = :utc
152
+
153
+ RUBY
154
+ inject_into_class 'config/application.rb', 'Application', config
155
+ end
156
+
157
+ def configure_time_formats
158
+ remove_file 'config/locales/en.yml'
159
+ copy_file 'config_locales_en.yml', 'config/locales/en.yml'
160
+ end
161
+
162
+ def configure_rack_timeout
163
+ copy_file 'rack_timeout.rb', 'config/initializers/rack_timeout.rb'
164
+ end
165
+
166
+ def configure_action_mailer
167
+ action_mailer_host 'development', "#{app_name}.local"
168
+ action_mailer_host 'test', 'www.example.com'
169
+ action_mailer_host 'staging', "staging.#{app_name}.com"
170
+ action_mailer_host 'production', "#{app_name}.com"
171
+ end
172
+
173
+ def generate_rspec
174
+ generate 'rspec:install'
175
+ end
176
+
177
+ def configure_capybara_webkit
178
+ append_file 'spec/spec_helper.rb' do
179
+ "\nCapybara.javascript_driver = :webkit"
180
+ end
181
+ end
182
+
183
+ def generate_clearance
184
+ generate 'clearance:install'
185
+ end
186
+
187
+ def setup_foreman
188
+ copy_file 'sample.env', '.sample.env'
189
+ copy_file 'sample.env', '.env'
190
+ copy_file 'Procfile', 'Procfile'
191
+ end
192
+
193
+ def setup_stylesheets
194
+ remove_file 'app/assets/stylesheets/application.css'
195
+ copy_file 'import_sass_styles', 'app/assets/stylesheets/application.css.sass'
196
+ end
197
+
198
+ def gitignore_files
199
+ concat_file 'suspenders_gitignore', '.gitignore'
200
+ [
201
+ 'app/models',
202
+ 'app/presenters',
203
+ 'app/assets/images',
204
+ 'db/migrate',
205
+ 'log',
206
+ 'spec/support',
207
+ 'spec/lib',
208
+ 'spec/models',
209
+ 'spec/views',
210
+ 'spec/controllers',
211
+ 'spec/features',
212
+ 'spec/helpers',
213
+ 'spec/presenters',
214
+ 'spec/support/matchers',
215
+ 'spec/support/mixins',
216
+ 'spec/support/shared_examples'
217
+ ].each do |dir|
218
+ empty_directory_with_gitkeep dir
219
+ end
220
+ end
221
+
222
+ def init_git
223
+ run 'git init'
224
+ end
225
+
226
+ def create_heroku_apps
227
+ path_addition = override_path_for_tests
228
+ run "#{path_addition} heroku create #{app_name}-production --remote=production"
229
+ run "#{path_addition} heroku create #{app_name}-staging --remote=staging"
230
+ run "#{path_addition} heroku config:add RACK_ENV=staging RAILS_ENV=staging --remote=staging"
231
+ end
232
+
233
+ def create_github_repo(repo_name)
234
+ path_addition = override_path_for_tests
235
+ run "#{path_addition} hub create #{repo_name}"
236
+ end
237
+
238
+ def copy_miscellaneous_files
239
+ copy_file 'errors.rb', 'config/initializers/errors.rb'
240
+ end
241
+
242
+ def customize_error_pages
243
+ meta_tags =<<-EOS
244
+ <meta charset='utf-8' />
245
+ <meta name='ROBOTS' content='NOODP' />
246
+ EOS
247
+ style_tags =<<-EOS
248
+ <link href='/assets/application.css' media='all' rel='stylesheet' type='text/css' />
249
+ EOS
250
+
251
+ %w(500 404 422).each do |page|
252
+ inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
253
+ replace_in_file "public/#{page}.html", /<style.+>.+<\/style>/mi, style_tags.strip
254
+ replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
255
+ end
256
+ end
257
+
258
+ def remove_routes_comment_lines
259
+ replace_in_file 'config/routes.rb',
260
+ /Application\.routes\.draw do.*end/m,
261
+ "Application.routes.draw do\nend"
262
+ end
263
+
264
+ def add_email_validator
265
+ copy_file 'email_validator.rb', 'app/validators/email_validator.rb'
266
+ end
267
+
268
+ def disable_xml_params
269
+ copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb'
270
+ end
271
+
272
+ def setup_default_rake_task
273
+ append_file 'Rakefile' do
274
+ "task(:default).clear\ntask :default => [:spec]"
275
+ end
276
+ end
277
+
278
+ private
279
+
280
+ def override_path_for_tests
281
+ if ENV['TESTING']
282
+ support_bin = File.expand_path(File.join('..', '..', '..', 'features', 'support', 'bin'))
283
+ "PATH=#{support_bin}:$PATH"
284
+ end
285
+ end
286
+
287
+ def factories_spec_rake_task
288
+ IO.read find_in_source_paths('factories_spec_rake_task.rb')
289
+ end
290
+
291
+ def simplecov_init
292
+ IO.read find_in_source_paths('simplecov_init.rb')
293
+ end
294
+ end
295
+ end
@@ -0,0 +1,197 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+
4
+ module Suspenders
5
+ class AppGenerator < Rails::Generators::AppGenerator
6
+ class_option :database, :type => :string, :aliases => '-d', :default => 'postgresql',
7
+ :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
8
+
9
+ class_option :heroku, :type => :boolean, :aliases => '-H', :default => false,
10
+ :desc => 'Create staging and production Heroku apps'
11
+
12
+ class_option :github, :type => :string, :aliases => '-G', :default => nil,
13
+ :desc => 'Create Github repository and add remote origin pointed to repo'
14
+
15
+ class_option :skip_test_unit, :type => :boolean, :aliases => '-T', :default => true,
16
+ :desc => 'Skip Test::Unit files'
17
+
18
+ def finish_template
19
+ invoke :suspenders_customization
20
+ super
21
+ end
22
+
23
+ def suspenders_customization
24
+ invoke :remove_files_we_dont_need
25
+ invoke :customize_gemfile
26
+ invoke :setup_database
27
+ invoke :setup_development_environment
28
+ invoke :setup_test_environment
29
+ invoke :setup_production_environment
30
+ invoke :setup_staging_environment
31
+ invoke :create_suspenders_views
32
+ invoke :setup_javascripts
33
+ invoke :setup_presenters
34
+ invoke :configure_app
35
+ invoke :setup_stylesheets
36
+ invoke :copy_miscellaneous_files
37
+ invoke :customize_error_pages
38
+ invoke :remove_routes_comment_lines
39
+ invoke :setup_git
40
+ invoke :create_heroku_apps
41
+ invoke :create_github_repo
42
+ invoke :outro
43
+ end
44
+
45
+ def remove_files_we_dont_need
46
+ build :remove_public_index
47
+ build :remove_rails_logo_image
48
+ end
49
+
50
+ def setup_development_environment
51
+ say 'Setting up the development environment'
52
+ build :raise_delivery_errors
53
+ build :provide_setup_script
54
+ end
55
+
56
+ def setup_test_environment
57
+ say 'Setting up the test environment'
58
+ build :enable_factory_girl_syntax
59
+ build :test_factories_first
60
+ build :generate_rspec
61
+ build :configure_rspec
62
+ build :enable_database_cleaner
63
+ build :configure_capybara_webkit
64
+ build :setup_guard_spork
65
+ end
66
+
67
+ def setup_production_environment
68
+ say 'Setting up the production environment'
69
+ build :configure_smtp
70
+ end
71
+
72
+ def setup_staging_environment
73
+ say 'Setting up the staging environment'
74
+ build :setup_staging_environment
75
+ build :initialize_on_precompile
76
+ end
77
+
78
+ def create_suspenders_views
79
+ say 'Creating suspenders views'
80
+ build :create_partials_directory
81
+ build :create_shared_flashes
82
+ build :create_shared_javascripts
83
+ build :create_application_layout
84
+ end
85
+
86
+ def setup_javascripts
87
+ say 'Setting up javascripts'
88
+ build :setup_javascripts
89
+ end
90
+
91
+ def setup_presenters
92
+ say 'Setting up presenters'
93
+ build :setup_presenters
94
+ end
95
+
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
+ def setup_database
103
+ say 'Setting up database'
104
+
105
+ if 'postgresql' == options[:database]
106
+ build :use_postgres_config_template
107
+ end
108
+
109
+ build :create_database
110
+ end
111
+
112
+ def configure_app
113
+ say 'Configuring app'
114
+ build :configure_action_mailer
115
+ build :blacklist_active_record_attributes
116
+ build :configure_strong_parameters
117
+ build :configure_time_zone
118
+ build :configure_time_formats
119
+ build :configure_rack_timeout
120
+ build :disable_xml_params
121
+ build :add_email_validator
122
+ build :setup_default_rake_task
123
+ build :setup_foreman
124
+ end
125
+
126
+ def setup_stylesheets
127
+ say 'Set up stylesheets'
128
+ build :setup_stylesheets
129
+ end
130
+
131
+ def setup_git
132
+ say 'Initializing git'
133
+ invoke :setup_gitignore
134
+ invoke :init_git
135
+ end
136
+
137
+ def create_heroku_apps
138
+ if options[:heroku]
139
+ say 'Creating Heroku apps'
140
+ build :create_heroku_apps
141
+ end
142
+ end
143
+
144
+ def create_github_repo
145
+ if options[:github]
146
+ say 'Creating Github repo'
147
+ build :create_github_repo, options[:github]
148
+ end
149
+ end
150
+
151
+ def setup_gitignore
152
+ build :gitignore_files
153
+ end
154
+
155
+ def init_git
156
+ build :init_git
157
+ end
158
+
159
+ def copy_libraries
160
+ say 'Copying libraries'
161
+ build :copy_libraries
162
+ end
163
+
164
+ def copy_miscellaneous_files
165
+ say 'Copying miscellaneous support files'
166
+ build :copy_miscellaneous_files
167
+ end
168
+
169
+ def customize_error_pages
170
+ say 'Customizing the 500/404/422 pages'
171
+ build :customize_error_pages
172
+ end
173
+
174
+ def remove_routes_comment_lines
175
+ build :remove_routes_comment_lines
176
+ end
177
+
178
+ def outro
179
+ say 'Congratulations! You just pulled our suspenders.'
180
+ say "Remember to run 'rails generate airbrake' with your API key."
181
+ end
182
+
183
+ def run_bundle
184
+ # Let's not: We'll bundle manually at the right spot
185
+ end
186
+
187
+ protected
188
+
189
+ def get_builder_class
190
+ Suspenders::AppBuilder
191
+ end
192
+
193
+ def using_active_record?
194
+ !options[:skip_active_record]
195
+ end
196
+ end
197
+ end
@@ -0,0 +1,3 @@
1
+ module Suspenders
2
+ VERSION = '1.2.3'
3
+ end
@@ -0,0 +1,46 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'airbrake'
4
+ gem 'basic_presenter'
5
+ gem 'bourbon'
6
+ gem 'flutie'
7
+ gem 'jquery-rails'
8
+ gem 'pg'
9
+ gem 'rack-timeout'
10
+ gem 'rails', '>= 3.2.11'
11
+ gem 'recipient_interceptor'
12
+ gem 'simple_form'
13
+ gem 'slim-rails'
14
+ gem 'strong_parameters'
15
+ gem 'thin'
16
+
17
+ group :assets do
18
+ gem 'coffee-rails'
19
+ gem 'sass-rails'
20
+ gem 'uglifier'
21
+ end
22
+
23
+ group :development do
24
+ gem 'foreman'
25
+ gem 'better_errors'
26
+ gem 'binding_of_caller'
27
+ end
28
+
29
+ group :development, :test do
30
+ gem 'factory_girl_rails'
31
+ gem 'rspec-rails'
32
+ end
33
+
34
+ group :test do
35
+ gem 'bourne', require: false
36
+ gem 'capybara-webkit', '>= 0.14.1'
37
+ gem 'database_cleaner'
38
+ gem 'launchy'
39
+ gem 'shoulda-matchers'
40
+ gem 'simplecov', require: false
41
+ gem 'timecop'
42
+ end
43
+
44
+ group :staging, :production do
45
+ gem 'newrelic_rpm'
46
+ end
@@ -0,0 +1 @@
1
+ web: bundle exec rails server thin -p $PORT -e $RACK_ENV
@@ -0,0 +1,9 @@
1
+ You look great in Suspenders
2
+ ============================
3
+
4
+ Use the following guides for getting things done, programming well, and
5
+ programming in style.
6
+
7
+ * [Protocol](http://github.com/thoughtbot/guides/blob/master/protocol)
8
+ * [Best Practices](http://github.com/thoughtbot/guides/blob/master/best-practices)
9
+ * [Style](http://github.com/thoughtbot/guides/blob/master/style)
@@ -0,0 +1,3 @@
1
+ #flash
2
+ - flash.each do |key, value|
3
+ div id="flash_#{key}"= value
@@ -0,0 +1,5 @@
1
+ = javascript_include_tag :application
2
+ = yield :javascript
3
+ - if Rails.env.test?
4
+ javascript:
5
+ $.ajaxSetup({ async: false });
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env sh
2
+
3
+ # Set up Rails app. Run this script immediately after cloning the codebase.
4
+ # https://github.com/thoughtbot/guides/tree/master/protocol
5
+
6
+ bundle install --binstubs=bin/stubs
7
+ bundle exec rake db:setup
8
+
9
+ if [ ! -f .env ]; then
10
+ cp .sample.env .env
11
+ fi
@@ -0,0 +1,11 @@
1
+ en:
2
+ date:
3
+ formats:
4
+ default: '%m/%d/%Y'
5
+ with_weekday: '%a %m/%d/%y'
6
+
7
+ time:
8
+ formats:
9
+ default: '%a, %b %-d, %Y at %r'
10
+ date: '%b %-d, %Y'
11
+ short: '%B %d'
@@ -0,0 +1,21 @@
1
+ RSpec.configure do |config|
2
+ config.before(:suite) do
3
+ DatabaseCleaner.clean_with(:deletion)
4
+ end
5
+
6
+ config.before(:each) do
7
+ DatabaseCleaner.strategy = :transaction
8
+ end
9
+
10
+ config.before(:each, :js => true) do
11
+ DatabaseCleaner.strategy = :deletion
12
+ end
13
+
14
+ config.before(:each) do
15
+ DatabaseCleaner.start
16
+ end
17
+
18
+ config.after(:each) do
19
+ DatabaseCleaner.clean
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ # Protect against injection attacks
2
+ # http://www.kb.cert.org/vuls/id/380039
3
+ ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML)
@@ -0,0 +1,7 @@
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
@@ -0,0 +1,28 @@
1
+ require 'net/http'
2
+ require 'net/smtp'
3
+
4
+ # Example:
5
+ # begin
6
+ # some http call
7
+ # rescue *HTTP_ERRORS => error
8
+ # notify_hoptoad error
9
+ # end
10
+
11
+ HTTP_ERRORS = [Timeout::Error,
12
+ Errno::EINVAL,
13
+ Errno::ECONNRESET,
14
+ EOFError,
15
+ Net::HTTPBadResponse,
16
+ Net::HTTPHeaderSyntaxError,
17
+ Net::ProtocolError]
18
+
19
+ SMTP_SERVER_ERRORS = [TimeoutError,
20
+ IOError,
21
+ Net::SMTPUnknownError,
22
+ Net::SMTPServerBusy,
23
+ Net::SMTPAuthenticationError]
24
+
25
+ SMTP_CLIENT_ERRORS = [Net::SMTPFatalError,
26
+ Net::SMTPSyntaxError]
27
+
28
+ SMTP_ERRORS = SMTP_SERVER_ERRORS + SMTP_CLIENT_ERRORS
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
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) }
7
+
8
+ it 'is valid' do
9
+ is_valid = subject.valid?
10
+ expect(is_valid).to be_true, subject.errors.full_messages.join(',')
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+
2
+ if defined?(RSpec)
3
+ desc 'Run factory specs.'
4
+ RSpec::Core::RakeTask.new(:factory_specs) do |t|
5
+ t.pattern = './spec/models/factories_spec.rb'
6
+ end
7
+
8
+ task spec: :factory_specs
9
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryGirl::Syntax::Methods
3
+ end
@@ -0,0 +1,4 @@
1
+ #= require jquery
2
+ #= require jquery_ujs
3
+
4
+ $ ->