solidus_dev_support 1.4.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +10 -17
  3. data/.github/PULL_REQUEST_TEMPLATE.md +0 -1
  4. data/.github_changelog_generator +4 -0
  5. data/.mergify.yml +33 -1
  6. data/.rubocop.yml +42 -0
  7. data/CHANGELOG.md +48 -5
  8. data/Gemfile +1 -1
  9. data/OLD_CHANGELOG.md +200 -0
  10. data/README.md +3 -1
  11. data/Rakefile +11 -1
  12. data/lib/solidus_dev_support/extension.rb +4 -1
  13. data/lib/solidus_dev_support/rake_tasks.rb +12 -0
  14. data/lib/solidus_dev_support/rspec/capybara.rb +18 -0
  15. data/lib/solidus_dev_support/rspec/feature_helper.rb +17 -18
  16. data/lib/solidus_dev_support/rspec/rails_helper.rb +8 -5
  17. data/lib/solidus_dev_support/rubocop/config.yml +82 -203
  18. data/lib/solidus_dev_support/solidus_command.rb +0 -1
  19. data/lib/solidus_dev_support/templates/extension/.circleci/config.yml +6 -0
  20. data/lib/solidus_dev_support/templates/extension/.github/stale.yml +4 -4
  21. data/lib/solidus_dev_support/templates/extension/README.md +28 -8
  22. data/lib/solidus_dev_support/templates/extension/bin/rails-sandbox +1 -1
  23. data/lib/solidus_dev_support/templates/extension/bin/sandbox.tt +2 -0
  24. data/lib/solidus_dev_support/templates/extension/extension.gemspec.tt +1 -1
  25. data/lib/solidus_dev_support/templates/extension/github_changelog_generator +2 -0
  26. data/lib/solidus_dev_support/templates/extension/lib/%file_name%.rb.tt +13 -0
  27. data/lib/solidus_dev_support/templates/extension/lib/%file_name%/configuration.rb.tt +8 -0
  28. data/lib/solidus_dev_support/templates/extension/lib/%file_name%/{factories.rb.tt → testing_support/factories.rb.tt} +0 -0
  29. data/lib/solidus_dev_support/templates/extension/lib/generators/%file_name%/install/install_generator.rb.tt +10 -5
  30. data/lib/solidus_dev_support/templates/extension/lib/generators/%file_name%/install/templates/initializer.rb.tt +6 -0
  31. data/lib/solidus_dev_support/templates/extension/rubocop.yml +3 -0
  32. data/lib/solidus_dev_support/templates/extension/spec/spec_helper.rb.tt +11 -7
  33. data/lib/solidus_dev_support/version.rb +5 -1
  34. data/solidus_dev_support.gemspec +16 -14
  35. data/spec/features/create_extension_spec.rb +171 -0
  36. data/spec/lib/extension_spec.rb +33 -0
  37. data/spec/spec_helper.rb +16 -0
  38. metadata +48 -37
  39. data/lib/solidus_dev_support/templates/extension/bin/r +0 -8
  40. data/lib/solidus_dev_support/templates/extension/bin/sandbox_rails +0 -8
@@ -18,4 +18,3 @@ module SolidusDevSupport
18
18
  end
19
19
  end
20
20
  end
21
-
@@ -16,12 +16,18 @@ jobs:
16
16
  executor: solidusio_extensions/mysql
17
17
  steps:
18
18
  - solidusio_extensions/run-tests
19
+ lint-code:
20
+ executor: solidusio_extensions/sqlite-memory
21
+ steps:
22
+ - solidusio_extensions/lint-code
19
23
 
20
24
  workflows:
21
25
  "Run specs on supported Solidus versions":
22
26
  jobs:
23
27
  - run-specs-with-postgres
24
28
  - run-specs-with-mysql
29
+ - lint-code
30
+
25
31
  "Weekly run specs against master":
26
32
  triggers:
27
33
  - schedule:
@@ -1,17 +1,17 @@
1
1
  # Number of days of inactivity before an issue becomes stale
2
2
  daysUntilStale: 60
3
3
  # Number of days of inactivity before a stale issue is closed
4
- daysUntilClose: 7
4
+ daysUntilClose: false
5
5
  # Issues with these labels will never be considered stale
6
6
  exemptLabels:
7
7
  - pinned
8
8
  - security
9
9
  # Label to use when marking an issue as stale
10
- staleLabel: wontfix
10
+ staleLabel: stale
11
11
  # Comment to post when marking an issue as stale. Set to `false` to disable
12
12
  markComment: >
13
13
  This issue has been automatically marked as stale because it has not had
14
- recent activity. It will be closed if no further activity occurs. Thank you
14
+ recent activity. It might be closed if no further activity occurs. Thank you
15
15
  for your contributions.
16
16
  # Comment to post when closing a stale issue. Set to `false` to disable
17
- closeComment: false
17
+ closeComment: false
@@ -1,6 +1,13 @@
1
- # <%= class_name %>
1
+ # <%= class_name.gsub(/(?<=[^A-Z])([A-Z])/, ' \1') %>
2
2
 
3
- [Explain what your extension does.]
3
+ <!-- Replace REPO_ORG and uncomment the following to show badges for CI and coverage. -->
4
+
5
+ <!--
6
+ [![CircleCI](https://circleci.com/gh/REPO_ORG/<%= file_name %>.svg?style=shield)](https://circleci.com/gh/REPO_ORG/<%= file_name %>)
7
+ [![codecov](https://codecov.io/gh/REPO_ORG/<%= file_name %>/branch/master/graph/badge.svg)](https://codecov.io/gh/REPO_ORG/<%= file_name %>)
8
+ -->
9
+
10
+ [Explain what your extension does.]
4
11
 
5
12
  ## Installation
6
13
 
@@ -13,8 +20,7 @@ gem '<%= file_name %>'
13
20
  Bundle your dependencies and run the installation generator:
14
21
 
15
22
  ```shell
16
- bundle
17
- bundle exec rails g <%= file_name %>:install
23
+ bin/rails generate <%= file_name %>:install
18
24
  ```
19
25
 
20
26
  ## Usage
@@ -30,7 +36,6 @@ app if it does not exist, then it will run specs. The dummy app can be regenerat
30
36
  `bin/rake extension:test_app`.
31
37
 
32
38
  ```shell
33
- bundle
34
39
  bin/rake
35
40
  ```
36
41
 
@@ -47,7 +52,7 @@ Simply add this require statement to your spec_helper:
47
52
  require '<%= file_name %>/factories'
48
53
  ```
49
54
 
50
- ## Running the sandbox
55
+ ### Running the sandbox
51
56
 
52
57
  To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
53
58
  the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
@@ -55,7 +60,7 @@ the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands t
55
60
 
56
61
  Here's an example:
57
62
 
58
- ```shell
63
+ ```
59
64
  $ bin/rails server
60
65
  => Booting Puma
61
66
  => Rails 6.0.2.1 application starting in development
@@ -63,12 +68,27 @@ $ bin/rails server
63
68
  Use Ctrl-C to stop
64
69
  ```
65
70
 
71
+ ### Updating the changelog
72
+
73
+ Before and after releases the changelog should be updated to reflect the up-to-date status of
74
+ the project:
75
+
76
+ ```shell
77
+ bin/rake changelog
78
+ git add CHANGELOG.md
79
+ git commit -m "Update the changelog"
80
+ ```
81
+
66
82
  ### Releasing new versions
67
83
 
68
84
  Your new extension version can be released using `gem-release` like this:
69
85
 
70
86
  ```shell
71
- bundle exec gem bump -v VERSION --tag --push --remote upstream && gem release
87
+ bundle exec gem bump -v 1.6.0
88
+ bin/rake changelog
89
+ git commit -a --amend
90
+ git push
91
+ bundle exec gem release
72
92
  ```
73
93
 
74
94
  ## License
@@ -5,7 +5,7 @@ app_root = 'sandbox'
5
5
  unless File.exist? "#{app_root}/bin/rails"
6
6
  warn 'Creating the sandbox app...'
7
7
  Dir.chdir "#{__dir__}/.." do
8
- system "#{__dir__}/sandbox" or begin # rubocop:disable Style/AndOr
8
+ system "#{__dir__}/sandbox" or begin
9
9
  warn 'Automatic creation of the sandbox app failed'
10
10
  exit 1
11
11
  end
@@ -72,9 +72,11 @@ unbundled bundle exec rails generate spree:install \
72
72
  --user_class=Spree::User \
73
73
  --enforce_available_locales=true \
74
74
  --with-authentication=false \
75
+ --payment-method=none \
75
76
  $@
76
77
 
77
78
  unbundled bundle exec rails generate solidus:auth:install
79
+ unbundled bundle exec rails generate ${extension_name}:install
78
80
 
79
81
  echo
80
82
  echo "🚀 Sandbox app successfully created for $extension_name!"
@@ -32,5 +32,5 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 3']
33
33
  spec.add_dependency 'solidus_support', '~> 0.5'
34
34
 
35
- spec.add_development_dependency 'solidus_dev_support'
35
+ spec.add_development_dependency 'solidus_dev_support', '<%= SolidusDevSupport.gem_version.approximate_recommendation %>'
36
36
  end
@@ -0,0 +1,2 @@
1
+ issues=false
2
+ exclude-labels=infrastructure
@@ -3,5 +3,18 @@
3
3
  require 'solidus_core'
4
4
  require 'solidus_support'
5
5
 
6
+ require '<%=file_name%>/configuration'
6
7
  require '<%=file_name%>/version'
7
8
  require '<%=file_name%>/engine'
9
+
10
+ module <%= class_name %>
11
+ class << self
12
+ def configuration
13
+ @configuration ||= Configuration.new
14
+ end
15
+
16
+ def configure
17
+ yield configuration
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module <%= class_name %>
4
+ class Configuration
5
+ # TODO: Remember to change this with your extension's actual preferences!
6
+ # attr_accessor :sample_preference
7
+ end
8
+ end
@@ -4,15 +4,20 @@ module <%= class_name %>
4
4
  module Generators
5
5
  class InstallGenerator < Rails::Generators::Base
6
6
  class_option :auto_run_migrations, type: :boolean, default: false
7
+ source_root File.expand_path('templates', __dir__)
8
+
9
+ def copy_initializer
10
+ template 'initializer.rb', 'config/initializers/<%= file_name %>.rb'
11
+ end
7
12
 
8
13
  def add_javascripts
9
- append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/<%= file_name %>\n" # rubocop:disable Metrics/LineLength
10
- append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/<%= file_name %>\n" # rubocop:disable Metrics/LineLength
14
+ append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/<%= file_name %>\n"
15
+ append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/<%= file_name %>\n"
11
16
  end
12
17
 
13
18
  def add_stylesheets
14
- inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/<%= file_name %>\n", before: %r{\*/}, verbose: true # rubocop:disable Metrics/LineLength
15
- inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/<%= file_name %>\n", before: %r{\*/}, verbose: true # rubocop:disable Metrics/LineLength
19
+ inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/<%= file_name %>\n", before: %r{\*/}, verbose: true # rubocop:disable Layout/LineLength
20
+ inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/<%= file_name %>\n", before: %r{\*/}, verbose: true # rubocop:disable Layout/LineLength
16
21
  end
17
22
 
18
23
  def add_migrations
@@ -20,7 +25,7 @@ module <%= class_name %>
20
25
  end
21
26
 
22
27
  def run_migrations
23
- run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Metrics/LineLength
28
+ run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Layout/LineLength
24
29
  if run_migrations
25
30
  run 'bin/rails db:migrate'
26
31
  else
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ <%= class_name %>.configure do |config|
4
+ # TODO: Remember to change this with the actual preferences you have implemented!
5
+ # config.sample_preference = 'sample_value'
6
+ end
@@ -1,2 +1,5 @@
1
1
  require:
2
2
  - solidus_dev_support/rubocop
3
+
4
+ AllCops:
5
+ NewCops: Enable
@@ -6,22 +6,26 @@ ENV['RAILS_ENV'] = 'test'
6
6
  # Run Coverage report
7
7
  require 'solidus_dev_support/rspec/coverage'
8
8
 
9
- require File.expand_path('dummy/config/environment.rb', __dir__).tap { |file|
10
- # Create the dummy app if it's still missing.
11
- system 'bin/rake extension:test_app' unless File.exist? file
12
- }
9
+ # Create the dummy app if it's still missing.
10
+ dummy_env = "#{__dir__}/dummy/config/environment.rb"
11
+ system 'bin/rake extension:test_app' unless File.exist? dummy_env
12
+ require dummy_env
13
13
 
14
14
  # Requires factories and other useful helpers defined in spree_core.
15
15
  require 'solidus_dev_support/rspec/feature_helper'
16
16
 
17
17
  # Requires supporting ruby files with custom matchers and macros, etc,
18
18
  # in spec/support/ and its subdirectories.
19
- Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
19
+ Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
20
20
 
21
- # Requires factories defined in lib/<%= file_name %>/factories.rb
22
- require '<%= file_name %>/factories'
21
+ # Requires factories defined in lib/<%= file_name %>/testing_support/factories.rb
22
+ require '<%= file_name %>/testing_support/factories'
23
23
 
24
24
  RSpec.configure do |config|
25
25
  config.infer_spec_type_from_file_location!
26
26
  config.use_transactional_fixtures = false
27
+
28
+ if Spree.solidus_gem_version < Gem::Version.new('2.11')
29
+ config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
30
+ end
27
31
  end
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusDevSupport
4
- VERSION = "1.4.0"
4
+ VERSION = "2.1.0"
5
+
6
+ def self.gem_version
7
+ Gem::Version.new(VERSION)
8
+ end
5
9
  end
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'solidus_dev_support/version'
3
+ require_relative 'lib/solidus_dev_support/version'
6
4
 
7
5
  Gem::Specification.new do |spec|
8
6
  spec.name = 'solidus_dev_support'
@@ -16,33 +14,37 @@ Gem::Specification.new do |spec|
16
14
 
17
15
  spec.metadata['homepage_uri'] = spec.homepage
18
16
  spec.metadata['source_code_uri'] = 'https://github.com/solidusio/solidus_dev_support'
17
+ spec.metadata['changelog_uri'] = 'https://github.com/solidusio/solidus_dev_support/blob/master/CHANGELOG.md'
18
+
19
+ spec.required_ruby_version = Gem::Requirement.new('~> 2.5')
19
20
 
20
21
  # Specify which files should be added to the gem when it is released.
21
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
- end
25
- spec.bindir = 'exe'
26
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.require_paths = ['lib']
28
-
29
- spec.add_dependency 'apparition', '~> 0.4'
23
+ files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
24
+
25
+ spec.files = files.grep_v(%r{^(test|spec|features)/})
26
+ spec.test_files = files.grep(%r{^(test|spec|features)/})
27
+ spec.bindir = "exe"
28
+ spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
30
31
  spec.add_dependency 'capybara', '~> 3.29'
31
32
  spec.add_dependency 'capybara-screenshot', '~> 1.0'
32
- spec.add_dependency 'codecov', '~> 0.1.16'
33
+ spec.add_dependency 'codecov', '~> 0.2'
33
34
  spec.add_dependency 'database_cleaner', '~> 1.7'
34
35
  spec.add_dependency 'factory_bot_rails', '~> 5.1'
35
36
  spec.add_dependency 'ffaker', '~> 2.13'
36
37
  spec.add_dependency 'gem-release', '~> 2.1'
37
38
  spec.add_dependency 'github_changelog_generator', '~> 1.15'
38
39
  spec.add_dependency 'puma', '~> 4.3'
39
- spec.add_dependency 'rspec-rails', '~> 4.0.0.beta3'
40
40
  spec.add_dependency 'rspec_junit_formatter'
41
- spec.add_dependency 'rubocop', '~> 0.76.0'
41
+ spec.add_dependency 'rspec-rails', '~> 4.0.0.beta3'
42
+ spec.add_dependency 'rubocop', '~> 0.90'
42
43
  spec.add_dependency 'rubocop-performance', '~> 1.5'
43
44
  spec.add_dependency 'rubocop-rails', '~> 2.3'
44
45
  spec.add_dependency 'rubocop-rspec', '~> 1.36'
45
46
  spec.add_dependency 'solidus_core', ['>= 2.0', '< 3']
47
+ spec.add_dependency 'webdrivers', '~> 4.4'
46
48
 
47
49
  spec.add_development_dependency 'bundler'
48
50
  spec.add_development_dependency 'rake'
@@ -0,0 +1,171 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+ require 'open3'
5
+ require 'spec_helper'
6
+
7
+ RSpec.describe 'Create extension' do
8
+ include FileUtils
9
+
10
+ let(:gem_root) { File.expand_path('../..', __dir__) }
11
+ let(:solidus_cmd) { "#{gem_root}/exe/solidus" }
12
+ let(:extension_name) { 'test_extension' }
13
+ let(:gemspec_name) { "solidus_#{extension_name}.gemspec" }
14
+ let(:tmp_path) { Pathname.new(gem_root).join('tmp') }
15
+ let(:install_path) { tmp_path.join("solidus_#{extension_name}") }
16
+
17
+ class CommandFailed < StandardError; end
18
+
19
+ before do
20
+ rm_rf(install_path)
21
+ mkdir_p(tmp_path)
22
+ end
23
+
24
+ def step(method_name)
25
+ puts "Step #{method_name}"
26
+ send method_name
27
+ end
28
+
29
+ it 'checks the create extension process' do
30
+ step :check_solidus_cmd
31
+ step :check_create_extension
32
+ step :check_bundle_install
33
+ step :check_default_task
34
+ step :check_run_specs
35
+ step :check_sandbox
36
+ end
37
+
38
+ private
39
+
40
+ def check_solidus_cmd
41
+ cd(tmp_path) do
42
+ output = `#{solidus_cmd} -h`
43
+ expect($?).to be_success
44
+ expect(output).to include('Commands:')
45
+ end
46
+ end
47
+
48
+ def check_create_extension
49
+ cd(tmp_path) do
50
+ output = `#{solidus_cmd} extension #{extension_name}`
51
+ expect($?).to be_success
52
+ expect(output).to include(gemspec_name)
53
+ expect(output).to include('.circleci')
54
+ end
55
+
56
+ cd(install_path) do
57
+ aggregate_failures do
58
+ %w[
59
+ bin/console
60
+ bin/rails
61
+ bin/rails-engine
62
+ bin/rails-sandbox
63
+ bin/sandbox
64
+ bin/setup
65
+ ].each do |bin|
66
+ bin = Pathname(bin)
67
+ expect(
68
+ name: bin,
69
+ exist: bin.exist?,
70
+ executable: bin.stat.executable?
71
+ ).to eq(
72
+ name: bin,
73
+ exist: true,
74
+ executable: true
75
+ )
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ def check_bundle_install
82
+ cd(install_path) do
83
+ open('Gemfile', 'a') { |f| f.puts "gem 'solidus_dev_support', path: '../../..'" }
84
+ end
85
+
86
+ expect { bundle_install }.to raise_error(CommandFailed, /invalid gemspec/)
87
+
88
+ # Update gemspec with the required fields
89
+ gemspec_path = install_path.join(gemspec_name)
90
+ gemspec = gemspec_path.read.lines
91
+ gemspec.grep(/spec\.author/).first.replace(" spec.author = 'John Doe'\n")
92
+ gemspec.grep(/spec\.email/).first.replace(" spec.email = 'john@example.com'\n")
93
+ gemspec.grep(/spec\.summary/).first.replace(" spec.summary = 'A nice extension'\n")
94
+ gemspec.grep(/spec\.description/).first.replace(" spec.description = 'A super nice extension'\n")
95
+ gemspec_path.write(gemspec.join)
96
+
97
+ expect(bundle_install).to match(/Bundle complete/)
98
+ end
99
+
100
+ def check_default_task
101
+ cd(install_path) do
102
+ output = sh('bin/rake')
103
+ expect(output).to include('Generating dummy Rails application')
104
+ expect(output).to include('0 examples, 0 failures')
105
+ end
106
+ end
107
+
108
+ def check_run_specs
109
+ install_path.join('spec', 'some_spec.rb').write(
110
+ "require 'spec_helper'\nRSpec.describe 'Some test' do it { expect(true).to be_truthy } end\n"
111
+ )
112
+ cd(install_path) do
113
+ output = sh('bundle exec rspec')
114
+ expect(output).to include('1 example, 0 failures')
115
+ expect(output).to include(ENV['CODECOV_TOKEN'] ? 'Coverage reports upload successfully' : 'Provide a CODECOV_TOKEN environment variable to enable Codecov uploads')
116
+ end
117
+ end
118
+
119
+ def check_sandbox
120
+ cd(install_path) do
121
+ # rubocop:disable Lint/InterpolationCheck
122
+ command = 'bin/rails-sandbox runner "puts %{The version of SolidusTestExtension is #{SolidusTestExtension::VERSION}}"'
123
+ # rubocop:enable Lint/InterpolationCheck
124
+
125
+ first_run_output = sh(command)
126
+ expect(first_run_output).to include("Creating the sandbox app...")
127
+ expect(first_run_output).to include('The version of SolidusTestExtension is 0.0.1')
128
+
129
+ second_run_output = sh(command)
130
+ expect(second_run_output).not_to include("Creating the sandbox app...")
131
+ expect(second_run_output).to include('The version of SolidusTestExtension is 0.0.1')
132
+ end
133
+ end
134
+
135
+ def sh(*args)
136
+ command = args.size == 1 ? args.first : args.shelljoin
137
+ output, status = with_unbundled_env { Open3.capture2e(command) }
138
+
139
+ if status.success?
140
+ output.to_s
141
+ else
142
+ if $DEBUG
143
+ warn '~' * 80
144
+ warn "$ #{command}"
145
+ warn output.to_s
146
+ end
147
+ raise(CommandFailed, "command failed: #{command}\n#{output}")
148
+ end
149
+ end
150
+
151
+ def with_unbundled_env(&block)
152
+ if Bundler.respond_to?(:with_unbundled_env)
153
+ Bundler.with_unbundled_env(&block)
154
+ else
155
+ Bundler.with_clean_env(&block)
156
+ end
157
+ end
158
+
159
+ def bundle_install
160
+ # Optimize the bundle path within the CI, in this context using bundler env
161
+ # variables doesn't help because commands are run with a clean env.
162
+ bundle_path = "#{gem_root}/vendor/bundle"
163
+
164
+ command = 'bundle install'
165
+ command += " --path=#{bundle_path.shellescape}" if File.exist?(bundle_path)
166
+
167
+ output = nil
168
+ cd(install_path) { output = sh command }
169
+ output
170
+ end
171
+ end