bretelline 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bretelline/app_generator.rb +4 -1
  3. data/lib/bretelline/builders/solidus.rb +39 -4
  4. data/lib/bretelline/templates/README.md.erb +64 -0
  5. data/lib/bretelline/templates/bin_rails +19 -0
  6. data/lib/bretelline/templates/circle.yml +10 -0
  7. data/lib/bretelline/templates/rubocop.yml +177 -0
  8. data/lib/bretelline/templates/solidus_gemfile.erb +1 -2
  9. data/lib/bretelline/templates/spec/rails_helper.rb +61 -0
  10. data/lib/bretelline/templates/spec/support/capybara.rb +6 -0
  11. data/lib/bretelline/templates/spec/support/database_cleaner.rb +44 -0
  12. data/lib/bretelline/templates/spec/support/paperclip.rb +8 -0
  13. data/lib/bretelline/templates/spec/support/simplecov.rb +16 -0
  14. data/lib/bretelline/templates/spec/support/solidus.rb +22 -0
  15. data/lib/bretelline/templates/spec/support/tools.rb +33 -0
  16. data/lib/bretelline/version.rb +1 -1
  17. metadata +12 -78
  18. data/blog/.gitignore +0 -23
  19. data/blog/Gemfile +0 -54
  20. data/blog/Gemfile.lock +0 -191
  21. data/blog/README.md +0 -1
  22. data/blog/Rakefile +0 -6
  23. data/blog/app/assets/config/manifest.js +0 -3
  24. data/blog/app/assets/images/.keep +0 -0
  25. data/blog/app/assets/javascripts/application.js +0 -15
  26. data/blog/app/assets/javascripts/cable.js +0 -13
  27. data/blog/app/assets/javascripts/channels/.keep +0 -0
  28. data/blog/app/assets/stylesheets/application.css +0 -15
  29. data/blog/app/channels/application_cable/channel.rb +0 -4
  30. data/blog/app/channels/application_cable/connection.rb +0 -4
  31. data/blog/app/controllers/application_controller.rb +0 -3
  32. data/blog/app/controllers/concerns/.keep +0 -0
  33. data/blog/app/helpers/application_helper.rb +0 -2
  34. data/blog/app/jobs/application_job.rb +0 -2
  35. data/blog/app/mailers/application_mailer.rb +0 -4
  36. data/blog/app/models/application_record.rb +0 -3
  37. data/blog/app/models/concerns/.keep +0 -0
  38. data/blog/app/views/layouts/application.html.erb +0 -14
  39. data/blog/app/views/layouts/mailer.html.erb +0 -13
  40. data/blog/app/views/layouts/mailer.text.erb +0 -1
  41. data/blog/bin/bundle +0 -3
  42. data/blog/bin/rails +0 -9
  43. data/blog/bin/rake +0 -9
  44. data/blog/bin/setup +0 -38
  45. data/blog/bin/spring +0 -17
  46. data/blog/bin/update +0 -29
  47. data/blog/bin/yarn +0 -11
  48. data/blog/config.ru +0 -5
  49. data/blog/config/application.rb +0 -18
  50. data/blog/config/boot.rb +0 -3
  51. data/blog/config/cable.yml +0 -10
  52. data/blog/config/database.yml +0 -25
  53. data/blog/config/environment.rb +0 -5
  54. data/blog/config/environments/development.rb +0 -54
  55. data/blog/config/environments/production.rb +0 -91
  56. data/blog/config/environments/test.rb +0 -42
  57. data/blog/config/initializers/application_controller_renderer.rb +0 -6
  58. data/blog/config/initializers/assets.rb +0 -14
  59. data/blog/config/initializers/backtrace_silencers.rb +0 -7
  60. data/blog/config/initializers/cookies_serializer.rb +0 -5
  61. data/blog/config/initializers/filter_parameter_logging.rb +0 -4
  62. data/blog/config/initializers/inflections.rb +0 -16
  63. data/blog/config/initializers/mime_types.rb +0 -4
  64. data/blog/config/initializers/wrap_parameters.rb +0 -14
  65. data/blog/config/locales/en.yml +0 -33
  66. data/blog/config/puma.rb +0 -56
  67. data/blog/config/routes.rb +0 -3
  68. data/blog/config/secrets.yml +0 -32
  69. data/blog/config/spring.rb +0 -6
  70. data/blog/db/seeds.rb +0 -7
  71. data/blog/lib/assets/.keep +0 -0
  72. data/blog/lib/tasks/.keep +0 -0
  73. data/blog/log/.keep +0 -0
  74. data/blog/package.json +0 -5
  75. data/blog/public/404.html +0 -67
  76. data/blog/public/422.html +0 -67
  77. data/blog/public/500.html +0 -66
  78. data/blog/public/apple-touch-icon-precomposed.png +0 -0
  79. data/blog/public/apple-touch-icon.png +0 -0
  80. data/blog/public/favicon.ico +0 -0
  81. data/blog/public/robots.txt +0 -1
  82. data/blog/test/application_system_test_case.rb +0 -5
  83. data/blog/test/controllers/.keep +0 -0
  84. data/blog/test/fixtures/.keep +0 -0
  85. data/blog/test/fixtures/files/.keep +0 -0
  86. data/blog/test/helpers/.keep +0 -0
  87. data/blog/test/integration/.keep +0 -0
  88. data/blog/test/mailers/.keep +0 -0
  89. data/blog/test/models/.keep +0 -0
  90. data/blog/test/system/.keep +0 -0
  91. data/blog/test/test_helper.rb +0 -9
  92. data/blog/tmp/.keep +0 -0
  93. data/blog/vendor/.keep +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e04097487a7d9751b99b24fdb8e2e1fbd018c62
4
- data.tar.gz: c4d186d68e9d226964d663989293e41d608e2b89
3
+ metadata.gz: b5c3567e21e47b2619058bf15be7a0157d92af22
4
+ data.tar.gz: 9888a831fd2c9840d1fbf177f405ddcd6f4f4547
5
5
  SHA512:
6
- metadata.gz: e7b8aba7217f0a0ff5148d61d7b5f02d0b61ac74e3c1afa4d650b1a40e1e7300603fad5c37c659e7af0a077ca74aabbc83bcf881abcdce8f019e048f6b75449a
7
- data.tar.gz: 0a3a6ce506e1fa18735ea76066334f40e154fc4a8a506619c2977339f058dfef1da395dd4d75742f1654191ad0b48d74f30c5b273a725ee3f8d7a1ef54fbc6bb
6
+ metadata.gz: b4ad960a20850e43e670f1959dca6df9ee674eda8d204c1c76a80a8c5de0087ba7897de07fa01cd1d3a5c37040856aafab0ebb2fd2f2ba9c0c19f0737c659428
7
+ data.tar.gz: dc29010e2a2e19109de9def1f2e03807daaddb57151e1f111d6e685ab6eda559fceb913ad2cace6c3227f48658f210bd324e0c6376fb9a3ddda7431ac7c4cd19
@@ -3,6 +3,9 @@ module Bretelline
3
3
  class_option :database, type: :string, aliases: "-d", default: "postgresql",
4
4
  desc: "Configure for selected database (options: #{DATABASES.join('/')})"
5
5
 
6
+ class_option :skip_spring, type: :boolean, default: true,
7
+ desc: "Don't install Spring application preloader"
8
+
6
9
  class_option :skip_test, type: :boolean, default: true,
7
10
  desc: "Skip Test Unit"
8
11
 
@@ -34,7 +37,7 @@ module Bretelline
34
37
  def bretelline
35
38
  bundle_command 'install'
36
39
  invoke :create_database
37
- build :install_engine
40
+ build :setup
38
41
  invoke :migrate_database
39
42
  end
40
43
 
@@ -5,15 +5,50 @@ module Bretelline
5
5
  template "solidus_gemfile.erb", "Gemfile"
6
6
  end
7
7
 
8
- def install_engine
9
- bundle_command "exec rails g spree:install"
10
- bundle_command "exec rails g solidus:auth:install"
11
- bundle_command "exec rake railties:install:migrations"
8
+ def setup
9
+ solidus
10
+ rspec
11
+ ci
12
+ rubocop
12
13
  end
13
14
 
14
15
  def readme
15
16
  template 'README.md.erb', 'README.md'
16
17
  end
18
+
19
+ private
20
+
21
+ def solidus
22
+ bundle_command "exec rails g spree:install --sample=false"
23
+ bundle_command "exec rails g solidus:auth:install"
24
+ bundle_command "exec rake railties:install:migrations"
25
+ empty_directory_with_keep_file 'app/overrides'
26
+ end
27
+
28
+ def rspec
29
+ bundle_command "exec rails generate rspec:install"
30
+ directory 'spec/support'
31
+ remove_file 'spec/rails_helper.rb'
32
+ copy_file 'spec/rails_helper.rb', 'spec/rails_helper.rb'
33
+ prepend_to_file 'spec/spec_helper.rb', "require 'support/simplecov'\n"
34
+ empty_directory_with_keep_file 'spec/features'
35
+ empty_directory_with_keep_file 'spec/models'
36
+ empty_directory_with_keep_file 'spec/controllers'
37
+ empty_directory_with_keep_file 'spec/jobs'
38
+ empty_directory_with_keep_file 'spec/pages/sections'
39
+ empty_directory_with_keep_file 'spec/factories'
40
+ remove_file 'bin/rails'
41
+ copy_file 'bin_rails', 'bin/rails'
42
+ end
43
+
44
+ def ci
45
+ copy_file 'circle.yml', 'circle.yml'
46
+ end
47
+
48
+ def rubocop
49
+ copy_file 'rubocop.yml', '.rubocop.yml'
50
+ bundle_command 'exec rubocop -a'
51
+ end
17
52
  end
18
53
  end
19
54
  end
@@ -1 +1,65 @@
1
1
  # <%= app_name.humanize %>
2
+
3
+ This is [Solidus](https://solidus.io/) eCommerce application.
4
+
5
+ ## Development Setup
6
+
7
+ 1. Clone the repo:
8
+
9
+ ```
10
+ $ cd ~/Code
11
+ $ git clone git@github.com:nebulab/<%= app_name.humanize %>.git
12
+ $ cd <%= app_name.humanize %>
13
+ ```
14
+
15
+ 2. Install dependencies and prepare database:
16
+
17
+ ```
18
+ $ ./bin/setup
19
+ ```
20
+
21
+ 3. You're up and running. Just start foreman:
22
+
23
+ ```
24
+ $ bundle exec invoker start invoker.ini
25
+ ```
26
+
27
+ Notes:
28
+
29
+ * Make sure you have PostgreSQL and Redis up and running
30
+ * Seeds include a user that developer can use locally to login:
31
+
32
+ ```
33
+ Email: admin@example.com
34
+ Psw: test123
35
+ ```
36
+
37
+ ## <%= app_name.humanize %> basic development style guide
38
+
39
+ 1. *Always* create separate branches and pull requests for adding/removing/changing code;
40
+ 2. Write feature and unit specs as needed and respect project guidelines (code coverange, quality metrics, ...);
41
+ 3. Use imperative commit messages with capitalized first letter (eg. "Add this feature" instead
42
+ of "adds this feature"). Use descriptive commits (with both title and description) and respect title length;
43
+ 4. If we are working on a new feature, it's better to create seed data for the models we are working on to
44
+ let other devs reproduce behavior or eventual issues with these;
45
+ 5. When porting some code from Solidus please use a separate commit referring to the original code you're porting
46
+ with a link to the Solidus GH project;
47
+ 6. Please refer to [GitHub Ruby Styleguide](https://github.com/styleguide/ruby) when writing Ruby code.
48
+
49
+ ## Running tests
50
+
51
+ <%= app_name.humanize %> is covered with basic fuctional tests using Rspec, FactoryGirl and Capybara (the same tools used by Solidus).
52
+ Javascript tests are run via Selenium ChromeDriver so you'll need to install _Chrome_ first (which is required).
53
+
54
+ To run the test suite run:
55
+
56
+ ```
57
+ $ rake db:test:prepare
58
+ $ rspec spec
59
+ ```
60
+
61
+ Please aim to full test coverage.
62
+
63
+ ## Deploying <%= app_name.humanize %>
64
+
65
+ Deploys depend on the app's configuration and can change from app to app. When in doubt ask [mtylty](https://github.com/mtylty).
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if ENV['RAILS_ENV'] == 'test'
4
+ require 'simplecov'
5
+
6
+ # Save to CircleCI's artifacts directory if we're on CircleCI
7
+ if ENV['CIRCLE_ARTIFACTS']
8
+ dir = File.join(ENV['CIRCLE_ARTIFACTS'], "coverage")
9
+ SimpleCov.coverage_dir(dir)
10
+ end
11
+
12
+ SimpleCov.start 'rails' do
13
+ add_filter 'config/application'
14
+ end
15
+ end
16
+
17
+ APP_PATH = File.expand_path('../config/application', __dir__)
18
+ require_relative '../config/boot'
19
+ require 'rails/commands'
@@ -0,0 +1,10 @@
1
+ machine:
2
+ services:
3
+ - redis
4
+ test:
5
+ pre:
6
+ - mkdir $CIRCLE_ARTIFACTS/coverage $CIRCLE_ARTIFACTS/quality $CIRCLE_ARTIFACTS/security
7
+ - curl -s https://raw.githubusercontent.com/chronogolf/circleci-google-chrome/master/use_chrome_stable_version.sh | bash
8
+ post:
9
+ - bundle exec rubocop --format html -o $CIRCLE_ARTIFACTS/quality/rubocop.html
10
+ - bundle exec brakeman --exit-on-warn --confidence-level 2 -o $CIRCLE_ARTIFACTS/security/brakeman.html
@@ -0,0 +1,177 @@
1
+ # Custom rules
2
+ AllCops:
3
+ Include:
4
+ - Rakefile
5
+ - config.ru
6
+ Exclude:
7
+ - db/schema.rb
8
+ - db/migrate/*
9
+ - tmp/**/*
10
+ - vendor/**/*
11
+ - bin/**/*
12
+ - log/**/*
13
+
14
+ Rails:
15
+ Enabled: true
16
+
17
+ # Relaxed.Ruby.Style
18
+ ## Version 2.1
19
+
20
+ Style/Alias:
21
+ Enabled: false
22
+ StyleGuide: http://relaxed.ruby.style/#stylealias
23
+
24
+ Style/AsciiComments:
25
+ Enabled: false
26
+ StyleGuide: http://relaxed.ruby.style/#styleasciicomments
27
+
28
+ Style/BeginBlock:
29
+ Enabled: false
30
+ StyleGuide: http://relaxed.ruby.style/#stylebeginblock
31
+
32
+ Style/BlockDelimiters:
33
+ Enabled: false
34
+ StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters
35
+
36
+ Style/CommentAnnotation:
37
+ Enabled: false
38
+ StyleGuide: http://relaxed.ruby.style/#stylecommentannotation
39
+
40
+ Style/Documentation:
41
+ Enabled: false
42
+ StyleGuide: http://relaxed.ruby.style/#styledocumentation
43
+
44
+ Style/DotPosition:
45
+ Enabled: false
46
+ StyleGuide: http://relaxed.ruby.style/#layoutdotposition
47
+
48
+ Style/DoubleNegation:
49
+ Enabled: false
50
+ StyleGuide: http://relaxed.ruby.style/#styledoublenegation
51
+
52
+ Style/EndBlock:
53
+ Enabled: false
54
+ StyleGuide: http://relaxed.ruby.style/#styleendblock
55
+
56
+ Style/FormatString:
57
+ Enabled: false
58
+ StyleGuide: http://relaxed.ruby.style/#styleformatstring
59
+
60
+ Style/IfUnlessModifier:
61
+ Enabled: false
62
+ StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier
63
+
64
+ Style/Lambda:
65
+ Enabled: false
66
+ StyleGuide: http://relaxed.ruby.style/#stylelambda
67
+
68
+ Style/ModuleFunction:
69
+ Enabled: false
70
+ StyleGuide: http://relaxed.ruby.style/#stylemodulefunction
71
+
72
+ Style/MultilineBlockChain:
73
+ Enabled: false
74
+ StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain
75
+
76
+ Style/NegatedIf:
77
+ Enabled: false
78
+ StyleGuide: http://relaxed.ruby.style/#stylenegatedif
79
+
80
+ Style/NegatedWhile:
81
+ Enabled: false
82
+ StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile
83
+
84
+ Style/ParallelAssignment:
85
+ Enabled: false
86
+ StyleGuide: http://relaxed.ruby.style/#styleparallelassignment
87
+
88
+ Style/PercentLiteralDelimiters:
89
+ Enabled: false
90
+ StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters
91
+
92
+ Style/PerlBackrefs:
93
+ Enabled: false
94
+ StyleGuide: http://relaxed.ruby.style/#styleperlbackrefs
95
+
96
+ Style/Semicolon:
97
+ Enabled: false
98
+ StyleGuide: http://relaxed.ruby.style/#stylesemicolon
99
+
100
+ Style/SignalException:
101
+ Enabled: false
102
+ StyleGuide: http://relaxed.ruby.style/#stylesignalexception
103
+
104
+ Style/SingleLineBlockParams:
105
+ Enabled: false
106
+ StyleGuide: http://relaxed.ruby.style/#stylesinglelineblockparams
107
+
108
+ Style/SingleLineMethods:
109
+ Enabled: false
110
+ StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods
111
+
112
+ Style/SpaceBeforeBlockBraces:
113
+ Enabled: false
114
+ StyleGuide: http://relaxed.ruby.style/#layoutspacebeforeblockbraces
115
+
116
+ Style/SpaceInsideParens:
117
+ Enabled: false
118
+ StyleGuide: http://relaxed.ruby.style/#layoutspaceinsideparens
119
+
120
+ Style/SpecialGlobalVars:
121
+ Enabled: false
122
+ StyleGuide: http://relaxed.ruby.style/#stylespecialglobalvars
123
+
124
+ Style/StringLiterals:
125
+ Enabled: false
126
+ StyleGuide: http://relaxed.ruby.style/#stylestringliterals
127
+
128
+ Style/TrailingCommaInArguments:
129
+ Enabled: false
130
+ StyleGuide: http://relaxed.ruby.style/#styletrailingcommainarguments
131
+
132
+ Style/TrailingCommaInLiteral:
133
+ Enabled: false
134
+ StyleGuide: http://relaxed.ruby.style/#styletrailingcommainliteral
135
+
136
+ Style/WhileUntilModifier:
137
+ Enabled: false
138
+ StyleGuide: http://relaxed.ruby.style/#stylewhileuntilmodifier
139
+
140
+ Style/WordArray:
141
+ Enabled: false
142
+ StyleGuide: http://relaxed.ruby.style/#stylewordarray
143
+
144
+ Lint/AmbiguousRegexpLiteral:
145
+ Enabled: false
146
+ StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral
147
+
148
+ Lint/AssignmentInCondition:
149
+ Enabled: false
150
+ StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition
151
+
152
+ Metrics/AbcSize:
153
+ Enabled: false
154
+
155
+ Metrics/BlockNesting:
156
+ Enabled: false
157
+
158
+ Metrics/ClassLength:
159
+ Enabled: false
160
+
161
+ Metrics/ModuleLength:
162
+ Enabled: false
163
+
164
+ Metrics/CyclomaticComplexity:
165
+ Enabled: false
166
+
167
+ Metrics/LineLength:
168
+ Enabled: false
169
+
170
+ Metrics/MethodLength:
171
+ Enabled: false
172
+
173
+ Metrics/ParameterLists:
174
+ Enabled: false
175
+
176
+ Metrics/PerceivedComplexity:
177
+ Enabled: false
@@ -37,9 +37,8 @@ gem 'seedbank', '~> 0.4'
37
37
 
38
38
  group :development, :test do
39
39
  gem 'dev_tools', github: 'nebulab/dev_tools'
40
+ gem 'listen', '~> 3.0.5'
40
41
  gem 'rspec-rails', '~> 3.6.0'
41
- gem 'spring'
42
- gem 'spring-watcher-listen', '~> 2.0.0'
43
42
  gem 'web-console', '>= 3.3.0'
44
43
  end
45
44
 
@@ -0,0 +1,61 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV['RAILS_ENV'] ||= 'test'
3
+ require File.expand_path('../../config/environment', __FILE__)
4
+ # Prevent database truncation if the environment is production
5
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
6
+ require 'spec_helper'
7
+ require 'rspec/rails'
8
+ require 'ffaker'
9
+
10
+ # Add additional requires below this line. Rails is not loaded until this point!
11
+
12
+ # We manually require each file to make sure the files are required in the
13
+ # correct order and no exceptions come up because of wrong require order
14
+ %w(
15
+ spec/support/capybara
16
+ spec/support/database_cleaner
17
+ spec/support/solidus
18
+ spec/support/tools
19
+ spec/support/paperclip
20
+ ).each { |path| require Rails.root.join(path) }
21
+
22
+ # Requires supporting ruby files with custom matchers and macros, etc, in
23
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
24
+ # run as spec files by default. This means that files in spec/support that end
25
+ # in _spec.rb will both be required and run as specs, causing the specs to be
26
+ # run twice. It is recommended that you do not name files matching this glob to
27
+ # end with _spec.rb. You can configure this pattern with the --pattern
28
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
29
+ #
30
+ # The following line is provided for convenience purposes. It has the downside
31
+ # of increasing the boot-up time by auto-requiring all files in the support
32
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
33
+ # require only the support files necessary.
34
+ #
35
+ # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
36
+
37
+ # Checks for pending migration and applies them before tests are run.
38
+ # If you are not using ActiveRecord, you can remove this line.
39
+ ActiveRecord::Migration.maintain_test_schema!
40
+
41
+ RSpec.configure do |config|
42
+ # RSpec Rails can automatically mix in different behaviours to your tests
43
+ # based on their file location, for example enabling you to call `get` and
44
+ # `post` in specs under `spec/controllers`.
45
+ #
46
+ # You can disable this behaviour by removing the line below, and instead
47
+ # explicitly tag your specs with their type, e.g.:
48
+ #
49
+ # RSpec.describe UsersController, :type => :controller do
50
+ # # ...
51
+ # end
52
+ #
53
+ # The different available types are documented in the features, such as in
54
+ # https://relishapp.com/rspec/rspec-rails/docs
55
+ config.infer_spec_type_from_file_location!
56
+
57
+ # Filter lines from Rails gems in backtraces.
58
+ config.filter_rails_from_backtrace!
59
+ # arbitrary gems may also be filtered via:
60
+ # config.filter_gems_from_backtrace("gem name")
61
+ end
@@ -0,0 +1,6 @@
1
+ Capybara.register_driver :selenium do |app|
2
+ Capybara::Selenium::Driver.new(app, browser: :chrome)
3
+ end
4
+
5
+ # Wait some seconds after clicks
6
+ Capybara.default_max_wait_time = 5
@@ -0,0 +1,44 @@
1
+ RSpec.configure do |config|
2
+ config.use_transactional_fixtures = false
3
+
4
+ config.before(:suite) do
5
+ if config.use_transactional_fixtures?
6
+ raise(<<-MSG)
7
+ Delete line `config.use_transactional_fixtures = true` from rails_helper.rb
8
+ (or set it to false) to prevent uncommitted transactions being used in
9
+ JavaScript-dependent specs.
10
+
11
+ During testing, the app-under-test that the browser driver connects to
12
+ uses a different database connection to the database connection used by
13
+ the spec. The app's database connection would not be able to access
14
+ uncommitted transaction data setup over the spec's database connection.
15
+ MSG
16
+ end
17
+ DatabaseCleaner.clean_with(:truncation)
18
+ end
19
+
20
+ config.before(:each) do
21
+ DatabaseCleaner.strategy = :transaction
22
+ end
23
+
24
+ config.before(:each, type: :feature) do
25
+ # :rack_test driver's Rack app under test shares database connection
26
+ # with the specs, so continue to use transaction strategy for speed.
27
+ driver_shares_db_connection_with_specs = Capybara.current_driver == :rack_test
28
+
29
+ if !driver_shares_db_connection_with_specs
30
+ # Driver is probably for an external browser with an app
31
+ # under test that does *not* share a database connection with the
32
+ # specs, so use truncation strategy.
33
+ DatabaseCleaner.strategy = :truncation
34
+ end
35
+ end
36
+
37
+ config.before(:each) do
38
+ DatabaseCleaner.start
39
+ end
40
+
41
+ config.append_after(:each) do
42
+ DatabaseCleaner.clean
43
+ end
44
+ end