solidus_dev_support 2.10.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.git-blame-ignore-revs +3 -0
  3. data/.github/workflows/lint.yml +25 -0
  4. data/.github/workflows/test.yml +64 -0
  5. data/.rubocop.yml +4 -55
  6. data/.standard.yml +2 -0
  7. data/Gemfile +15 -11
  8. data/README.md +26 -6
  9. data/bin/setup +5 -5
  10. data/bin/solidus +1 -1
  11. data/exe/solidus +1 -1
  12. data/lib/solidus_dev_support/extension.rb +38 -38
  13. data/lib/solidus_dev_support/rake_tasks.rb +18 -18
  14. data/lib/solidus_dev_support/rspec/capybara.rb +5 -5
  15. data/lib/solidus_dev_support/rspec/coverage.rb +13 -5
  16. data/lib/solidus_dev_support/rspec/feature_helper.rb +2 -2
  17. data/lib/solidus_dev_support/rspec/rails_helper.rb +14 -14
  18. data/lib/solidus_dev_support/rspec/spec_helper.rb +2 -2
  19. data/lib/solidus_dev_support/rubocop/config.yml +11 -80
  20. data/lib/solidus_dev_support/solidus_command.rb +10 -10
  21. data/lib/solidus_dev_support/templates/extension/.github/workflows/lint.yml +25 -0
  22. data/lib/solidus_dev_support/templates/extension/.github/workflows/test.yml +71 -0
  23. data/lib/solidus_dev_support/templates/extension/Gemfile.tt +12 -5
  24. data/lib/solidus_dev_support/templates/extension/Rakefile +2 -2
  25. data/lib/solidus_dev_support/templates/extension/bin/rails-sandbox +4 -4
  26. data/lib/solidus_dev_support/templates/extension/bin/sandbox.tt +8 -0
  27. data/lib/solidus_dev_support/templates/extension/extension.gemspec.tt +1 -1
  28. data/lib/solidus_dev_support/testing_support/factories.rb +5 -5
  29. data/lib/solidus_dev_support/version.rb +1 -1
  30. data/lib/solidus_dev_support.rb +1 -1
  31. data/solidus_dev_support.gemspec +28 -31
  32. metadata +28 -62
  33. data/.circleci/config.yml +0 -63
  34. data/.rubocop-https---relaxed-ruby-style-rubocop-yml +0 -153
  35. data/spec/features/create_extension_spec.rb +0 -193
  36. data/spec/lib/extension_spec.rb +0 -69
  37. data/spec/spec_helper.rb +0 -16
data/.circleci/config.yml DELETED
@@ -1,63 +0,0 @@
1
- version: 2.1
2
-
3
- orbs:
4
- # Always take the latest version of the orb, this allows us to
5
- # run specs against Solidus supported versions only without the need
6
- # to change this configuration every time a Solidus version is released
7
- # or goes EOL.
8
- solidusio_extensions: solidusio/extensions@volatile
9
-
10
- commands:
11
- setup:
12
- steps:
13
- - checkout
14
- - run:
15
- name: "Update bundler"
16
- command: |
17
- sudo gem update --system
18
- gem --version
19
- gem install bundler -v '>=2.3.21' --conservative
20
- bundle --version
21
-
22
- jobs:
23
- solidus-main:
24
- executor:
25
- name: solidusio_extensions/sqlite
26
- ruby_version: '3.2'
27
- steps: ['setup', 'solidusio_extensions/run-tests-solidus-main']
28
- solidus-current:
29
- executor:
30
- name: solidusio_extensions/sqlite
31
- ruby_version: '3.1'
32
- steps: ['setup', 'solidusio_extensions/run-tests-solidus-current']
33
- solidus-older:
34
- executor:
35
- name: solidusio_extensions/sqlite
36
- ruby_version: '3.0'
37
- steps: ['setup', 'solidusio_extensions/run-tests-solidus-older']
38
- lint-code:
39
- executor:
40
- name: solidusio_extensions/sqlite
41
- ruby_version: '3.1'
42
- steps: ['setup', 'solidusio_extensions/lint-code']
43
-
44
- workflows:
45
- "Run specs on supported Solidus versions":
46
- jobs:
47
- - solidus-main
48
- - solidus-current
49
- - solidus-older
50
- - lint-code
51
-
52
- "Weekly run specs against main":
53
- triggers:
54
- - schedule:
55
- cron: "0 0 * * 4" # every Thursday
56
- filters:
57
- branches:
58
- only:
59
- - main
60
- jobs:
61
- - solidus-main
62
- - solidus-current
63
- - solidus-older
@@ -1,153 +0,0 @@
1
- # Relaxed.Ruby.Style
2
- ## Version 2.5
3
-
4
- Style/Alias:
5
- Enabled: false
6
- StyleGuide: https://relaxed.ruby.style/#stylealias
7
-
8
- Style/AsciiComments:
9
- Enabled: false
10
- StyleGuide: https://relaxed.ruby.style/#styleasciicomments
11
-
12
- Style/BeginBlock:
13
- Enabled: false
14
- StyleGuide: https://relaxed.ruby.style/#stylebeginblock
15
-
16
- Style/BlockDelimiters:
17
- Enabled: false
18
- StyleGuide: https://relaxed.ruby.style/#styleblockdelimiters
19
-
20
- Style/CommentAnnotation:
21
- Enabled: false
22
- StyleGuide: https://relaxed.ruby.style/#stylecommentannotation
23
-
24
- Style/Documentation:
25
- Enabled: false
26
- StyleGuide: https://relaxed.ruby.style/#styledocumentation
27
-
28
- Layout/DotPosition:
29
- Enabled: false
30
- StyleGuide: https://relaxed.ruby.style/#layoutdotposition
31
-
32
- Style/DoubleNegation:
33
- Enabled: false
34
- StyleGuide: https://relaxed.ruby.style/#styledoublenegation
35
-
36
- Style/EndBlock:
37
- Enabled: false
38
- StyleGuide: https://relaxed.ruby.style/#styleendblock
39
-
40
- Style/FormatString:
41
- Enabled: false
42
- StyleGuide: https://relaxed.ruby.style/#styleformatstring
43
-
44
- Style/IfUnlessModifier:
45
- Enabled: false
46
- StyleGuide: https://relaxed.ruby.style/#styleifunlessmodifier
47
-
48
- Style/Lambda:
49
- Enabled: false
50
- StyleGuide: https://relaxed.ruby.style/#stylelambda
51
-
52
- Style/ModuleFunction:
53
- Enabled: false
54
- StyleGuide: https://relaxed.ruby.style/#stylemodulefunction
55
-
56
- Style/MultilineBlockChain:
57
- Enabled: false
58
- StyleGuide: https://relaxed.ruby.style/#stylemultilineblockchain
59
-
60
- Style/NegatedIf:
61
- Enabled: false
62
- StyleGuide: https://relaxed.ruby.style/#stylenegatedif
63
-
64
- Style/NegatedWhile:
65
- Enabled: false
66
- StyleGuide: https://relaxed.ruby.style/#stylenegatedwhile
67
-
68
- Style/NumericPredicate:
69
- Enabled: false
70
- StyleGuide: https://relaxed.ruby.style/#stylenumericpredicate
71
-
72
- Style/ParallelAssignment:
73
- Enabled: false
74
- StyleGuide: https://relaxed.ruby.style/#styleparallelassignment
75
-
76
- Style/PercentLiteralDelimiters:
77
- Enabled: false
78
- StyleGuide: https://relaxed.ruby.style/#stylepercentliteraldelimiters
79
-
80
- Style/PerlBackrefs:
81
- Enabled: false
82
- StyleGuide: https://relaxed.ruby.style/#styleperlbackrefs
83
-
84
- Style/Semicolon:
85
- Enabled: false
86
- StyleGuide: https://relaxed.ruby.style/#stylesemicolon
87
-
88
- Style/SignalException:
89
- Enabled: false
90
- StyleGuide: https://relaxed.ruby.style/#stylesignalexception
91
-
92
- Style/SingleLineBlockParams:
93
- Enabled: false
94
- StyleGuide: https://relaxed.ruby.style/#stylesinglelineblockparams
95
-
96
- Style/SingleLineMethods:
97
- Enabled: false
98
- StyleGuide: https://relaxed.ruby.style/#stylesinglelinemethods
99
-
100
- Layout/SpaceBeforeBlockBraces:
101
- Enabled: false
102
- StyleGuide: https://relaxed.ruby.style/#layoutspacebeforeblockbraces
103
-
104
- Layout/SpaceInsideParens:
105
- Enabled: false
106
- StyleGuide: https://relaxed.ruby.style/#layoutspaceinsideparens
107
-
108
- Style/SpecialGlobalVars:
109
- Enabled: false
110
- StyleGuide: https://relaxed.ruby.style/#stylespecialglobalvars
111
-
112
- Style/StringLiterals:
113
- Enabled: false
114
- StyleGuide: https://relaxed.ruby.style/#stylestringliterals
115
-
116
- Style/TrailingCommaInArguments:
117
- Enabled: false
118
- StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarguments
119
-
120
- Style/TrailingCommaInArrayLiteral:
121
- Enabled: false
122
- StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarrayliteral
123
-
124
- Style/TrailingCommaInHashLiteral:
125
- Enabled: false
126
- StyleGuide: https://relaxed.ruby.style/#styletrailingcommainhashliteral
127
-
128
- Style/SymbolArray:
129
- Enabled: false
130
- StyleGuide: http://relaxed.ruby.style/#stylesymbolarray
131
-
132
- Style/WhileUntilModifier:
133
- Enabled: false
134
- StyleGuide: https://relaxed.ruby.style/#stylewhileuntilmodifier
135
-
136
- Style/WordArray:
137
- Enabled: false
138
- StyleGuide: https://relaxed.ruby.style/#stylewordarray
139
-
140
- Lint/AmbiguousRegexpLiteral:
141
- Enabled: false
142
- StyleGuide: https://relaxed.ruby.style/#lintambiguousregexpliteral
143
-
144
- Lint/AssignmentInCondition:
145
- Enabled: false
146
- StyleGuide: https://relaxed.ruby.style/#lintassignmentincondition
147
-
148
- Layout/LineLength:
149
- Enabled: false
150
-
151
- Metrics:
152
- Enabled: false
153
-
@@ -1,193 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'fileutils'
4
- require 'open3'
5
- require 'spec_helper'
6
- require 'spree/core/version'
7
-
8
- RSpec.describe 'Create extension' do
9
- include FileUtils
10
-
11
- let(:gem_root) { File.expand_path('../..', __dir__) }
12
- let(:solidus_cmd) { "#{gem_root}/exe/solidus" }
13
- let(:extension_name) { 'test_extension' }
14
- let(:gemspec_name) { "solidus_#{extension_name}.gemspec" }
15
- let(:tmp_path) { Pathname.new(gem_root).join('tmp') }
16
- let(:install_path) { tmp_path.join("solidus_#{extension_name}") }
17
- let(:command_failed_error) { Class.new(StandardError) }
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_gem_version
32
- step :check_create_extension
33
- step :check_bundle_install
34
- step :check_default_task
35
- step :check_run_specs
36
- step :check_sandbox
37
- end
38
-
39
- private
40
-
41
- def check_solidus_cmd
42
- cd(tmp_path) do
43
- output = `#{solidus_cmd} -h`
44
- expect($?).to be_success
45
- expect(output).to include('Commands:')
46
- end
47
- end
48
-
49
- def check_gem_version
50
- gem_version_commands = ['version', '--version', '-v']
51
- gem_version = SolidusDevSupport::VERSION
52
- solidus_version = Spree.solidus_gem_version
53
-
54
- cd(tmp_path) do
55
- gem_version_commands.each do |gem_version_cmd|
56
- output = `#{solidus_cmd} #{gem_version_cmd}`
57
- expect($?).to be_success
58
- expect(output).to include("Solidus version #{solidus_version}")
59
- expect(output).to include("Solidus Dev Support version #{gem_version}")
60
- end
61
- end
62
- end
63
-
64
- def check_create_extension
65
- cd(tmp_path) do
66
- output = `#{solidus_cmd} extension #{extension_name}`
67
- expect($?).to be_success
68
- expect(output).to include(gemspec_name)
69
- expect(output).to include('.circleci')
70
- end
71
-
72
- cd(install_path) do
73
- aggregate_failures do
74
- %w[
75
- bin/console
76
- bin/rails
77
- bin/rails-engine
78
- bin/rails-sandbox
79
- bin/sandbox
80
- bin/setup
81
- ].each do |bin|
82
- bin = Pathname(bin)
83
- expect(
84
- name: bin,
85
- exist: bin.exist?,
86
- executable: bin.stat.executable?
87
- ).to eq(
88
- name: bin,
89
- exist: true,
90
- executable: true
91
- )
92
- end
93
- end
94
- end
95
- end
96
-
97
- def check_bundle_install
98
- cd(install_path) do
99
- open('Gemfile', 'a') { |f| f.puts "gem 'solidus_dev_support', path: '../..'" }
100
- end
101
-
102
- # Update gemspec with the required fields
103
- gemspec_path = install_path.join(gemspec_name)
104
- gemspec = gemspec_path.read.lines
105
- gemspec.grep(/spec\.author/).first.replace(" spec.author = 'John Doe'\n")
106
- gemspec.grep(/spec\.email/).first.replace(" spec.email = 'john@example.com'\n")
107
- gemspec.grep(/spec\.summary/).first.replace(" spec.summary = 'A nice extension'\n")
108
- gemspec.grep(/spec\.description/).first.replace(" spec.description = 'A super nice extension'\n")
109
- gemspec_path.write(gemspec.join)
110
-
111
- expect(bundle_install).to match(/Bundle complete/)
112
- end
113
-
114
- def check_default_task
115
- cd(install_path) do
116
- output = sh('bin/rake')
117
- expect(output).to include('Generating dummy Rails application')
118
- expect(output).to include('0 examples, 0 failures')
119
- end
120
- end
121
-
122
- def check_run_specs
123
- install_path.join('lib', 'solidus_test_extension', 'testing_support', 'factories.rb').open('a') do |factories_file|
124
- factories_file.write "\n puts 'loading test_extension factories'"
125
- end
126
-
127
- install_path.join('spec', 'some_spec.rb').write(
128
- "require 'spec_helper'\nRSpec.describe 'Some test' do it { expect(true).to be_truthy } end\n"
129
- )
130
- cd(install_path) do
131
- output = sh('bundle exec rspec')
132
- expect(output).to include('loading test_extension factories')
133
- expect(output).to include('1 example, 0 failures')
134
- expect(output).to include(ENV['CODECOV_TOKEN'] ? 'Coverage reports upload successfully' : 'Provide a CODECOV_TOKEN environment variable to enable Codecov uploads')
135
- end
136
- end
137
-
138
- def check_sandbox
139
- cd(install_path) do
140
- command = 'bin/rails-sandbox runner "puts %{The version of SolidusTestExtension is #{SolidusTestExtension::VERSION}}"'
141
-
142
- first_run_output = sh(command)
143
- expect(first_run_output).to include("Creating the sandbox app...")
144
- expect(first_run_output).to include('The version of SolidusTestExtension is 0.0.1')
145
-
146
- second_run_output = sh(command)
147
- expect(second_run_output).not_to include("Creating the sandbox app...")
148
- expect(second_run_output).to include('The version of SolidusTestExtension is 0.0.1')
149
- end
150
- end
151
-
152
- def sh(*args)
153
- command = args.size == 1 ? args.first : args.shelljoin
154
- output, status = with_unbundled_env do
155
- Open3.capture2e({ 'CI' => nil }, command)
156
- end
157
-
158
- if $DEBUG || ENV['DEBUG']
159
- warn '~' * 80
160
- warn "$ #{command}"
161
- warn output
162
- warn "$ #{command} ~~~~> EXIT STATUS: #{status.exitstatus}"
163
- end
164
-
165
- unless status.success?
166
- raise(command_failed_error, "command failed: #{command}\n#{output}")
167
- end
168
-
169
- output.to_s
170
- end
171
-
172
- def with_unbundled_env(...)
173
- if Bundler.respond_to?(:with_unbundled_env)
174
- Bundler.with_unbundled_env(...)
175
- else
176
- Bundler.with_clean_env(...)
177
- end
178
- end
179
-
180
- def bundle_install
181
- # Optimize the bundle path within the CI, in this context using bundler env
182
- # variables doesn't help because commands are run with a clean env.
183
- bundle_path = "#{gem_root}/vendor/bundle"
184
-
185
- if File.exist?(bundle_path)
186
- sh "bundle config set --local path #{bundle_path.shellescape}"
187
- end
188
-
189
- output = nil
190
- cd(install_path) { output = sh 'bundle install' }
191
- output
192
- end
193
- end
@@ -1,69 +0,0 @@
1
- require 'solidus_dev_support/extension'
2
-
3
- RSpec.describe SolidusDevSupport::Extension do
4
- describe '#path=' do
5
- specify 'with an existing extension' do
6
- allow(subject).to receive(:git).with('remote get-url origin', any_args).and_return('git@github.com:some_user/solidus_my_ext.git')
7
- allow(subject).to receive(:git).with('config user.name', any_args).and_return('John Doe')
8
- allow(subject).to receive(:git).with('config user.email', any_args).and_return('john.doe@example.com')
9
-
10
- allow(File).to receive(:exist?).with('/foo/bar/solidus_my_ext/solidus_my_ext.gemspec').and_return(true)
11
- allow(Gem::Specification).to receive(:load).with('/foo/bar/solidus_my_ext/solidus_my_ext.gemspec').and_return(
12
- Gem::Specification.new('solidus_my_ext', '0.1.1') do |gem|
13
- gem.author = "Jane Doe"
14
- gem.email = "jane.doe@example.com"
15
-
16
- gem.summary = 'This extension is awesome!'
17
- gem.license = 'MIT'
18
-
19
- gem.homepage = "some_user.github.io/solidus_my_ext"
20
- gem.metadata['changelog_uri'] = "https://github.com/some_user/solidus_my_ext/releases"
21
- gem.metadata['source_code_uri'] = "https://github.com/some_user/solidus_my_ext"
22
- end
23
- )
24
-
25
- subject.path = '/foo/bar/solidus_my_ext'
26
-
27
- aggregate_failures do
28
- expect(subject.file_name).to eq("solidus_my_ext")
29
- expect(subject.class_name).to eq("SolidusMyExt")
30
- expect(subject.root).to eq("/foo/bar")
31
- expect(subject.path).to eq("/foo/bar/solidus_my_ext")
32
- expect(subject.repo).to eq("some_user/solidus_my_ext")
33
- expect(subject.gemspec.author).to eq('Jane Doe')
34
- expect(subject.gemspec.email).to eq('jane.doe@example.com')
35
- expect(subject.gemspec.summary).to eq('This extension is awesome!')
36
- expect(subject.gemspec.license).to eq('MIT')
37
- expect(subject.gemspec.homepage).to eq("some_user.github.io/solidus_my_ext")
38
- expect(subject.gemspec.metadata['changelog_uri']).to eq("https://github.com/some_user/solidus_my_ext/releases")
39
- expect(subject.gemspec.metadata['source_code_uri']).to eq("https://github.com/some_user/solidus_my_ext")
40
- end
41
- end
42
-
43
- specify 'when creating a new extension' do
44
- allow(subject).to receive(:git).with('remote get-url origin', any_args) { |_, default| default }
45
- allow(subject).to receive(:git).with('config user.name', any_args).and_return('John Doe')
46
- allow(subject).to receive(:git).with('config user.email', any_args).and_return('john.doe@example.com')
47
-
48
- allow(Dir).to receive(:pwd).and_return('/foo/bar')
49
-
50
- subject.path = '/foo/bar/solidus_my_ext'
51
-
52
- aggregate_failures do
53
- expect(subject.file_name).to eq("solidus_my_ext")
54
- expect(subject.class_name).to eq("SolidusMyExt")
55
- expect(subject.root).to eq("/foo/bar")
56
- expect(subject.path).to eq("/foo/bar/solidus_my_ext")
57
- expect(subject.repo).to eq("solidusio-contrib/solidus_my_ext")
58
- expect(subject.gemspec.author).to eq('John Doe')
59
- expect(subject.gemspec.email).to eq('john.doe@example.com')
60
- expect(subject.gemspec.summary).to eq('TODO: Write a short summary, because RubyGems requires one.')
61
- expect(subject.gemspec.description).to eq('TODO: Write a longer description or delete this line.')
62
- expect(subject.gemspec.license).to eq('BSD-3-Clause')
63
- expect(subject.gemspec.homepage).to eq("https://github.com/solidusio-contrib/solidus_my_ext#readme")
64
- expect(subject.gemspec.metadata['changelog_uri']).to eq("https://github.com/solidusio-contrib/solidus_my_ext/blob/main/CHANGELOG.md")
65
- expect(subject.gemspec.metadata['source_code_uri']).to eq("https://github.com/solidusio-contrib/solidus_my_ext")
66
- end
67
- end
68
- end
69
- end
data/spec/spec_helper.rb DELETED
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/setup"
4
- require "solidus_dev_support"
5
-
6
- RSpec.configure do |config|
7
- # Enable flags like --only-failures and --next-failure
8
- config.example_status_persistence_file_path = ".rspec_status"
9
-
10
- # Disable RSpec exposing methods globally on `Module` and `main`
11
- config.disable_monkey_patching!
12
-
13
- config.expect_with :rspec do |c|
14
- c.syntax = :expect
15
- end
16
- end