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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +10 -17
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -1
- data/.github_changelog_generator +4 -0
- data/.mergify.yml +39 -0
- data/.rubocop.yml +42 -0
- data/CHANGELOG.md +85 -7
- data/Gemfile +1 -1
- data/OLD_CHANGELOG.md +200 -0
- data/README.md +13 -6
- data/Rakefile +11 -1
- data/lib/solidus_dev_support/extension.rb +1 -1
- data/lib/solidus_dev_support/rake_tasks.rb +12 -0
- data/lib/solidus_dev_support/rspec/capybara.rb +18 -0
- data/lib/solidus_dev_support/rspec/feature_helper.rb +17 -18
- data/lib/solidus_dev_support/rspec/rails_helper.rb +28 -0
- data/lib/solidus_dev_support/rubocop/config.yml +82 -202
- data/lib/solidus_dev_support/solidus_command.rb +0 -1
- data/lib/solidus_dev_support/templates/extension/.circleci/config.yml +6 -0
- data/lib/solidus_dev_support/templates/extension/.github/stale.yml +4 -4
- data/lib/solidus_dev_support/templates/extension/README.md +47 -22
- data/lib/solidus_dev_support/templates/extension/bin/rails +7 -0
- data/lib/solidus_dev_support/templates/extension/bin/{r.tt → rails-engine.tt} +0 -0
- data/lib/solidus_dev_support/templates/extension/bin/{sandbox_rails → rails-sandbox} +1 -3
- data/lib/solidus_dev_support/templates/extension/bin/sandbox.tt +2 -0
- data/lib/solidus_dev_support/templates/extension/extension.gemspec.tt +3 -3
- data/lib/solidus_dev_support/templates/extension/gitignore +3 -0
- data/lib/solidus_dev_support/templates/extension/lib/generators/%file_name%/install/install_generator.rb.tt +5 -5
- data/lib/solidus_dev_support/templates/extension/rubocop.yml +0 -5
- data/lib/solidus_dev_support/templates/extension/spec/spec_helper.rb.tt +9 -2
- data/lib/solidus_dev_support/version.rb +5 -1
- data/solidus_dev_support.gemspec +16 -14
- data/spec/features/create_extension_spec.rb +171 -0
- data/spec/lib/extension_spec.rb +33 -0
- data/spec/spec_helper.rb +16 -0
- metadata +52 -41
- data/.github/stale.yml +0 -17
@@ -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:
|
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:
|
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
|
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
|
-
|
3
|
+
<!-- Replace REPO_ORG and uncomment the following to show badges for CI and coverage. -->
|
5
4
|
|
6
|
-
|
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
|
-
|
19
|
-
bundle exec rails g <%= file_name %>:install
|
23
|
+
bin/rails generate <%= file_name %>:install
|
20
24
|
```
|
21
25
|
|
22
|
-
|
23
|
-
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
[Explain how to use your extension once it's been installed.]
|
29
|
+
|
30
|
+
## Development
|
24
31
|
|
25
|
-
|
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
|
-
|
46
|
-
-----------
|
55
|
+
### Running the sandbox
|
47
56
|
|
48
|
-
To run this extension in a sandboxed Solidus application you can run `bin/sandbox
|
49
|
-
|
50
|
-
|
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
|
-
|
61
|
+
Here's an example:
|
53
62
|
|
54
|
-
```
|
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
|
-
|
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
|
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
|
-
|
94
|
+
## License
|
95
|
+
|
96
|
+
Copyright (c) <%= Time.now.year %> [name of extension author], released under the New BSD License.
|
File without changes
|
@@ -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
|
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.
|
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.
|
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
|
@@ -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"
|
10
|
-
append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/<%= file_name %>\n"
|
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
|
15
|
-
inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/<%= file_name %>\n", before: %r{\*/}, verbose: true # rubocop:disable
|
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
|
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
|
@@ -6,14 +6,17 @@ ENV['RAILS_ENV'] = 'test'
|
|
6
6
|
# Run Coverage report
|
7
7
|
require 'solidus_dev_support/rspec/coverage'
|
8
8
|
|
9
|
-
|
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[
|
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
|
data/solidus_dev_support.gemspec
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
spec.
|
26
|
-
spec.
|
27
|
-
spec.
|
28
|
-
|
29
|
-
|
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.
|
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 '
|
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
|