solidus_dev_support 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) 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 +39 -0
  6. data/.rubocop.yml +42 -0
  7. data/CHANGELOG.md +85 -7
  8. data/Gemfile +1 -1
  9. data/OLD_CHANGELOG.md +200 -0
  10. data/README.md +13 -6
  11. data/Rakefile +11 -1
  12. data/lib/solidus_dev_support/extension.rb +1 -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 +28 -0
  17. data/lib/solidus_dev_support/rubocop/config.yml +82 -202
  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 +47 -22
  22. data/lib/solidus_dev_support/templates/extension/bin/rails +7 -0
  23. data/lib/solidus_dev_support/templates/extension/bin/{r.tt → rails-engine.tt} +0 -0
  24. data/lib/solidus_dev_support/templates/extension/bin/{sandbox_rails → rails-sandbox} +1 -3
  25. data/lib/solidus_dev_support/templates/extension/bin/sandbox.tt +2 -0
  26. data/lib/solidus_dev_support/templates/extension/extension.gemspec.tt +3 -3
  27. data/lib/solidus_dev_support/templates/extension/gitignore +3 -0
  28. data/lib/solidus_dev_support/templates/extension/lib/generators/%file_name%/install/install_generator.rb.tt +5 -5
  29. data/lib/solidus_dev_support/templates/extension/rubocop.yml +0 -5
  30. data/lib/solidus_dev_support/templates/extension/spec/spec_helper.rb.tt +9 -2
  31. data/lib/solidus_dev_support/version.rb +5 -1
  32. data/solidus_dev_support.gemspec +16 -14
  33. data/spec/features/create_extension_spec.rb +171 -0
  34. data/spec/lib/extension_spec.rb +33 -0
  35. data/spec/spec_helper.rb +16 -0
  36. metadata +52 -41
  37. data/.github/stale.yml +0 -17
@@ -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,10 +1,15 @@
1
- <%= class_name %>
2
- <%= "=" * class_name.size %>
1
+ # <%= class_name.gsub(/(?<=[^A-Z])([A-Z])/, ' \1') %>
3
2
 
4
- Introduction goes here.
3
+ <!-- Replace REPO_ORG and uncomment the following to show badges for CI and coverage. -->
5
4
 
6
- Installation
7
- ------------
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.]
11
+
12
+ ## Installation
8
13
 
9
14
  Add <%= file_name %> to your Gemfile:
10
15
 
@@ -15,17 +20,22 @@ gem '<%= file_name %>'
15
20
  Bundle your dependencies and run the installation generator:
16
21
 
17
22
  ```shell
18
- bundle
19
- bundle exec rails g <%= file_name %>:install
23
+ bin/rails generate <%= file_name %>:install
20
24
  ```
21
25
 
22
- Testing
23
- -------
26
+ ## Usage
27
+
28
+ [Explain how to use your extension once it's been installed.]
29
+
30
+ ## Development
24
31
 
25
- First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using `bin/rake extension:test_app`.
32
+ ### Testing the extension
33
+
34
+ First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
35
+ app if it does not exist, then it will run specs. The dummy app can be regenerated by using
36
+ `bin/rake extension:test_app`.
26
37
 
27
38
  ```shell
28
- bundle
29
39
  bin/rake
30
40
  ```
31
41
 
@@ -42,16 +52,15 @@ Simply add this require statement to your spec_helper:
42
52
  require '<%= file_name %>/factories'
43
53
  ```
44
54
 
45
- Sandbox app
46
- -----------
55
+ ### Running the sandbox
47
56
 
48
- To run this extension in a sandboxed Solidus application you can run `bin/sandbox`
49
- The path for the sandbox app is `./sandbox` and `bin/rails` will forward any Rails command
50
- to `sandbox/bin/rails`.
57
+ To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
58
+ the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
59
+ `sandbox/bin/rails`.
51
60
 
52
- Example:
61
+ Here's an example:
53
62
 
54
- ```shell
63
+ ```
55
64
  $ bin/rails server
56
65
  => Booting Puma
57
66
  => Rails 6.0.2.1 application starting in development
@@ -59,13 +68,29 @@ $ bin/rails server
59
68
  Use Ctrl-C to stop
60
69
  ```
61
70
 
62
- Releasing
63
- ---------
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
+
82
+ ### Releasing new versions
64
83
 
65
84
  Your new extension version can be released using `gem-release` like this:
66
85
 
67
86
  ```shell
68
- 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
69
92
  ```
70
93
 
71
- Copyright (c) <%= Time.now.year %> [name of extension creator], released under the New BSD License
94
+ ## License
95
+
96
+ Copyright (c) <%= Time.now.year %> [name of extension author], released under the New BSD License.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if %w[g generate].include? ARGV.first
4
+ exec "#{__dir__}/rails-engine", *ARGV
5
+ else
6
+ exec "#{__dir__}/rails-sandbox", *ARGV
7
+ end
@@ -1,13 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # frozen_string_literal: true
4
-
5
3
  app_root = 'sandbox'
6
4
 
7
5
  unless File.exist? "#{app_root}/bin/rails"
8
6
  warn 'Creating the sandbox app...'
9
7
  Dir.chdir "#{__dir__}/.." do
10
- system "#{__dir__}/sandbox" or begin # rubocop:disable Style/AndOr
8
+ system "#{__dir__}/sandbox" or begin
11
9
  warn 'Automatic creation of the sandbox app failed'
12
10
  exit 1
13
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!"
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.metadata['source_code_uri'] = '<%= gemspec.homepage %>'
18
18
  spec.metadata['changelog_uri'] = '<%= gemspec.metadata["changelog_uri"] %>'
19
19
 
20
- spec.required_ruby_version = Gem::Requirement.new('~> 2.4')
20
+ spec.required_ruby_version = Gem::Requirement.new('~> 2.5')
21
21
 
22
22
  # Specify which files should be added to the gem when it is released.
23
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ["lib"]
31
31
 
32
32
  spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 3']
33
- spec.add_dependency 'solidus_support', '~> 0.4.0'
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
@@ -15,3 +15,6 @@ pkg
15
15
  spec/dummy
16
16
  spec/examples.txt
17
17
  /sandbox
18
+ .rvmrc
19
+ .ruby-version
20
+ .ruby-gemset
@@ -6,13 +6,13 @@ module <%= class_name %>
6
6
  class_option :auto_run_migrations, type: :boolean, default: false
7
7
 
8
8
  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
9
+ append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/<%= file_name %>\n"
10
+ append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/<%= file_name %>\n"
11
11
  end
12
12
 
13
13
  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
14
+ inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/<%= file_name %>\n", before: %r{\*/}, verbose: true # rubocop:disable Layout/LineLength
15
+ 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
16
  end
17
17
 
18
18
  def add_migrations
@@ -20,7 +20,7 @@ module <%= class_name %>
20
20
  end
21
21
 
22
22
  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
23
+ 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
24
  if run_migrations
25
25
  run 'bin/rails db:migrate'
26
26
  else
@@ -1,7 +1,2 @@
1
1
  require:
2
2
  - solidus_dev_support/rubocop
3
-
4
- AllCops:
5
- Exclude:
6
- - sandbox/**/*
7
- - spec/dummy/**/*
@@ -6,14 +6,17 @@ 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__)
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
10
13
 
11
14
  # Requires factories and other useful helpers defined in spree_core.
12
15
  require 'solidus_dev_support/rspec/feature_helper'
13
16
 
14
17
  # Requires supporting ruby files with custom matchers and macros, etc,
15
18
  # in spec/support/ and its subdirectories.
16
- Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
19
+ Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
17
20
 
18
21
  # Requires factories defined in lib/<%= file_name %>/factories.rb
19
22
  require '<%= file_name %>/factories'
@@ -21,4 +24,8 @@ require '<%= file_name %>/factories'
21
24
  RSpec.configure do |config|
22
25
  config.infer_spec_type_from_file_location!
23
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
24
31
  end
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusDevSupport
4
- VERSION = "1.2.0"
4
+ VERSION = "2.0.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