solidus_dev_support 2.1.0 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 775cf185474367ed130d07d17702a80fe73b1f30c16c904d3f0ec2a6ae6d030b
4
- data.tar.gz: 3cb289f1aa0ac28cae5d1df0f2508acf87c705f07cd706ee4c05f014517d7357
3
+ metadata.gz: 2909d8c487345aa45ebf8962ace27cbc7d8e2a34eeb2f3eb6ba380913b50c2b4
4
+ data.tar.gz: a921fad3ec04944509f46f7a113a073b48100971395950525242c48a83b994e4
5
5
  SHA512:
6
- metadata.gz: 8051cde4fdfb198b4e034fd67204e8f04f0e91eda4d8c92bf1f7a88b62bfd4a3ebb5d3c9e6e253bf52f3d6589efc9c9c866ccf06124cd77adbff0f06bed23f00
7
- data.tar.gz: d06396c50c33c207ecbbbc9181a92aa1eeda7daab6f79268128d72b8419d7f755ef923aea33b25505e6faaad187d7bce6428a84b6f2436c5d8ce20702e9aec47
6
+ metadata.gz: bbb86bd58f06496f53b3c5f4d84ce47b41b9be72135d77aba58ee12b0bffdbc3afef0325fc4ec1dd2926d6cf6a97b11527380372ba28e4adb26719f5d3c9dc4d
7
+ data.tar.gz: 39e02e67c9b94436456bf5c751196a6b600dac9ac70b7c90488fa5f2793f959c41302cfc8b66ad860c1daac28ea8811e41571fd711f18ba55526ea59133b3fae
data/.mergify.yml CHANGED
@@ -34,6 +34,8 @@ pull_request_rules:
34
34
  - base=master
35
35
  - -label="needs changelog label"
36
36
  - -label=blocked
37
+ - "#approved-reviews-by>=1"
38
+ - -draft
37
39
  actions:
38
40
  merge:
39
41
  method: merge
data/.rubocop.yml CHANGED
@@ -36,7 +36,6 @@ Style/RedundantRegexpEscape:
36
36
  Style/SlicingWithRange:
37
37
  Enabled: true
38
38
 
39
-
40
39
  AllCops:
41
40
  TargetRubyVersion: 2.5
42
41
  Exclude:
@@ -44,6 +43,7 @@ AllCops:
44
43
  - "vendor/**/*"
45
44
  # Generated binstubs
46
45
  - bin/rake
46
+ NewCops: enable
47
47
 
48
48
  Style/FrozenStringLiteralComment:
49
49
  Exclude:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,69 @@
1
1
  # Changelog
2
2
 
3
+ ## [v2.4.0](https://github.com/solidusio/solidus_dev_support/tree/v2.4.0) (2021-02-05)
4
+
5
+ [Full Changelog](https://github.com/solidusio/solidus_dev_support/compare/v2.3.0...v2.4.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Improve engine's requires to remove double inclusions [\#165](https://github.com/solidusio/solidus_dev_support/pull/165) ([kennyadsl](https://github.com/kennyadsl))
10
+ - Remove double require of core factories from rails\_helper [\#164](https://github.com/solidusio/solidus_dev_support/pull/164) ([kennyadsl](https://github.com/kennyadsl))
11
+
12
+ **Fixed bugs:**
13
+
14
+ - Fix typo in configuration.rb.tt [\#166](https://github.com/solidusio/solidus_dev_support/pull/166) ([brchristian](https://github.com/brchristian))
15
+
16
+ **Merged pull requests:**
17
+
18
+ - Rename spree:install to solidus:install in the sandbox template [\#167](https://github.com/solidusio/solidus_dev_support/pull/167) ([blocknotes](https://github.com/blocknotes))
19
+
20
+ ## [v2.3.0](https://github.com/solidusio/solidus_dev_support/tree/v2.3.0) (2021-01-14)
21
+
22
+ [Full Changelog](https://github.com/solidusio/solidus_dev_support/compare/v2.2.0...v2.3.0)
23
+
24
+ **Implemented enhancements:**
25
+
26
+ - Do not raise if source\_code\_uri is missing in the gemspec [\#163](https://github.com/solidusio/solidus_dev_support/pull/163) ([kennyadsl](https://github.com/kennyadsl))
27
+ - Factory bot fixes for latest Solidus 2.11 release [\#162](https://github.com/solidusio/solidus_dev_support/pull/162) ([elia](https://github.com/elia))
28
+
29
+ **Fixed bugs:**
30
+
31
+ - use rubocop-rspec 2.x [\#161](https://github.com/solidusio/solidus_dev_support/pull/161) ([ccarruitero](https://github.com/ccarruitero))
32
+
33
+ ## [v2.2.0](https://github.com/solidusio/solidus_dev_support/tree/v2.2.0) (2020-11-27)
34
+
35
+ [Full Changelog](https://github.com/solidusio/solidus_dev_support/compare/v2.1.0...v2.2.0)
36
+
37
+ **Implemented enhancements:**
38
+
39
+ - Improve the URL generation for the gemspec and Readme \(defaulting to the solidusio-contrib organization\), consistently use a file-based Changelog [\#159](https://github.com/solidusio/solidus_dev_support/pull/159) ([elia](https://github.com/elia))
40
+ - Configuration Cleanup [\#158](https://github.com/solidusio/solidus_dev_support/pull/158) ([elia](https://github.com/elia))
41
+ - Refer to Solidus wiki page for gem release info [\#157](https://github.com/solidusio/solidus_dev_support/pull/157) ([spaghetticode](https://github.com/spaghetticode))
42
+ - Upgrade to RuboCop 1.0 [\#156](https://github.com/solidusio/solidus_dev_support/pull/156) ([aldesantis](https://github.com/aldesantis))
43
+ - Add a command to display gem's version [\#154](https://github.com/solidusio/solidus_dev_support/pull/154) ([igorbp](https://github.com/igorbp))
44
+
45
+ **Fixed bugs:**
46
+
47
+ - Require "webdrivers" before using it as the default javascript driver [\#152](https://github.com/solidusio/solidus_dev_support/pull/152) ([ccarruitero](https://github.com/ccarruitero))
48
+
49
+ **Merged pull requests:**
50
+
51
+ - Don't let mergify mark a PR as red because it's missing a review [\#153](https://github.com/solidusio/solidus_dev_support/pull/153) ([elia](https://github.com/elia))
52
+
53
+ ## [v2.1.0](https://github.com/solidusio/solidus_dev_support/tree/v2.1.0) (2020-10-02)
54
+
55
+ [Full Changelog](https://github.com/solidusio/solidus_dev_support/compare/v2.0.1...v2.1.0)
56
+
57
+ **Implemented enhancements:**
58
+
59
+ - Add standard github\_changelog\_generator configuration [\#151](https://github.com/solidusio/solidus_dev_support/pull/151) ([aldesantis](https://github.com/aldesantis))
60
+ - Move generated factories to `testing\_support/` [\#150](https://github.com/solidusio/solidus_dev_support/pull/150) ([aldesantis](https://github.com/aldesantis))
61
+ - Add extension configuration boilerplate [\#149](https://github.com/solidusio/solidus_dev_support/pull/149) ([aldesantis](https://github.com/aldesantis))
62
+
63
+ **Fixed bugs:**
64
+
65
+ - Fix `NewCops: Enable` option for RuboCop [\#148](https://github.com/solidusio/solidus_dev_support/pull/148) ([aldesantis](https://github.com/aldesantis))
66
+
3
67
  ## [v2.0.1](https://github.com/solidusio/solidus_dev_support/tree/v2.0.1) (2020-09-22)
4
68
 
5
69
  [Full Changelog](https://github.com/solidusio/solidus_dev_support/compare/v2.0.0...v2.0.1)
@@ -10,7 +74,7 @@
10
74
 
11
75
  ## [v2.0.0](https://github.com/solidusio/solidus_dev_support/tree/v2.0.0) (2020-09-22)
12
76
 
13
- [Full Changelog](https://github.com/solidusio/solidus_dev_support/compare/v1.5.0...v2.0.0)
77
+ [Full Changelog](https://github.com/solidusio/solidus_dev_support/compare/v1.6.0...v2.0.0)
14
78
 
15
79
  **Breaking changes:**
16
80
 
@@ -21,17 +85,26 @@
21
85
  - Enable new RuboCop cops automatically [\#143](https://github.com/solidusio/solidus_dev_support/pull/143) ([aldesantis](https://github.com/aldesantis))
22
86
  - Don't forcefully close issues via stale-bot [\#139](https://github.com/solidusio/solidus_dev_support/pull/139) ([elia](https://github.com/elia))
23
87
  - Add the approximate recommendation for dev-support to the gemspec [\#137](https://github.com/solidusio/solidus_dev_support/pull/137) ([elia](https://github.com/elia))
88
+
89
+ **Fixed bugs:**
90
+
91
+ - fix capybara driver declaration [\#141](https://github.com/solidusio/solidus_dev_support/pull/141) ([ccarruitero](https://github.com/ccarruitero))
92
+ - Bump RuboCop to latest 0.90.0 version [\#138](https://github.com/solidusio/solidus_dev_support/pull/138) ([peterberkenbosch](https://github.com/peterberkenbosch))
93
+ - Fix missing backslash in solidus install command [\#135](https://github.com/solidusio/solidus_dev_support/pull/135) ([nirebu](https://github.com/nirebu))
94
+
95
+ ## [v1.6.0](https://github.com/solidusio/solidus_dev_support/tree/v1.6.0) (2020-08-26)
96
+
97
+ [Full Changelog](https://github.com/solidusio/solidus_dev_support/compare/v1.5.0...v1.6.0)
98
+
99
+ **Implemented enhancements:**
100
+
24
101
  - Let the extension name include spaces [\#133](https://github.com/solidusio/solidus_dev_support/pull/133) ([elia](https://github.com/elia))
25
102
  - Add precompiled badges fro CI and coverage [\#132](https://github.com/solidusio/solidus_dev_support/pull/132) ([elia](https://github.com/elia))
26
103
  - Add Changelog Rake task [\#128](https://github.com/solidusio/solidus_dev_support/pull/128) ([tvdeyen](https://github.com/tvdeyen))
27
104
  - Readme fixes [\#122](https://github.com/solidusio/solidus_dev_support/pull/122) ([elia](https://github.com/elia))
28
- - Restore the generic bin/rails command [\#106](https://github.com/solidusio/solidus_dev_support/pull/106) ([elia](https://github.com/elia))
29
105
 
30
106
  **Fixed bugs:**
31
107
 
32
- - fix capybara driver declaration [\#141](https://github.com/solidusio/solidus_dev_support/pull/141) ([ccarruitero](https://github.com/ccarruitero))
33
- - Bump RuboCop to latest 0.90.0 version [\#138](https://github.com/solidusio/solidus_dev_support/pull/138) ([peterberkenbosch](https://github.com/peterberkenbosch))
34
- - Fix missing backslash in solidus install command [\#135](https://github.com/solidusio/solidus_dev_support/pull/135) ([nirebu](https://github.com/nirebu))
35
108
  - Don't install a payment-method in the sandbox [\#131](https://github.com/solidusio/solidus_dev_support/pull/131) ([elia](https://github.com/elia))
36
109
  - Run extension generator in sandbox [\#127](https://github.com/solidusio/solidus_dev_support/pull/127) ([elia](https://github.com/elia))
37
110
 
data/Gemfile CHANGED
@@ -15,7 +15,6 @@ gem 'rails', '>0.a'
15
15
 
16
16
  # These gems will be used by the temporary extensions generated by tests
17
17
  group :test do
18
- gem 'factory_bot', '> 4.10.0'
19
18
  gem 'mysql2'
20
19
  gem 'pg'
21
20
  gem 'solidus_auth_devise'
data/README.md CHANGED
@@ -232,9 +232,16 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
232
232
  the tests. You can also run `bin/console` for an interactive prompt that will allow you to
233
233
  experiment.
234
234
 
235
- To install this gem onto your local machine, run `bin/rake install`. To release a new
236
- version, update the version number in `version.rb`, and then run `bin/rake release`, which
237
- will create a git tag for the version, push git commits and tags, and push the `.gem` file to
235
+ To install this gem onto your local machine, run `bin/rake install`.
236
+
237
+ To release a new version:
238
+
239
+ 1. update the version number in `version.rb`
240
+ 2. update the changelog with `bin/rake changelog`
241
+ 3. commit the changes using `Bump SolidusDevSupport to 1.2.3` as the message
242
+ 3. run `bin/rake release`
243
+
244
+ The last command will create a git tag for the version, push git commits and tags, and push the `.gem` file to
238
245
  [rubygems.org](https://rubygems.org).
239
246
 
240
247
  ## Contributing
data/Rakefile CHANGED
@@ -2,14 +2,16 @@
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
 
5
- require 'github_changelog_generator/task'
6
- GitHubChangelogGenerator::RakeTask.new :changelog do |config|
7
- config.user = 'solidusio'
8
- config.project = 'solidus_dev_support'
9
- config.exclude_labels = %w[infrastructure]
10
- config.issues = false
11
- config.base = "#{__dir__}/OLD_CHANGELOG.md"
12
- config.since_tag = 'v1.4.0'
5
+ desc "Update the changelog, specify the version for the unreleased changes appending VERSION=1.2.3 to the command"
6
+ task :changelog do
7
+ require_relative "lib/solidus_dev_support/version"
8
+
9
+ future_release = ENV.fetch("VERSION") {
10
+ warn "Using current version (#{SolidusDevSupport::VERSION}) for unreleased changes, use VERSION=1.2.3 to select a different one."
11
+ SolidusDevSupport::VERSION
12
+ }
13
+
14
+ sh "bundle exec github_changelog_generator --project solidus_dev_support --user solidusio --future-release #{future_release}"
13
15
  end
14
16
 
15
17
  require "rspec/core/rake_task"
@@ -28,6 +28,7 @@ module SolidusDevSupport
28
28
  make_executable bin
29
29
  end
30
30
 
31
+ template 'CHANGELOG.md', "#{path}/CHANGELOG.md"
31
32
  template 'extension.gemspec', "#{path}/#{file_name}.gemspec"
32
33
  template 'Gemfile', "#{path}/Gemfile"
33
34
  template 'gitignore', "#{path}/.gitignore"
@@ -50,27 +51,36 @@ module SolidusDevSupport
50
51
  @file_name = Thor::Util.snake_case(File.basename(path))
51
52
  @file_name = PREFIX + @file_name unless @file_name.start_with?(PREFIX)
52
53
 
53
- @class_name = Thor::Util.camel_case @file_name
54
+ @class_name = Thor::Util.camel_case file_name
54
55
 
55
56
  @root = File.dirname(path)
56
- @path = File.join(@root, @file_name)
57
+ @path = File.join(root, file_name)
58
+
59
+ @repo = existing_repo || default_repo
57
60
 
58
61
  @gemspec = existing_gemspec || default_gemspec
59
62
  end
60
63
 
64
+ attr_reader :root, :path, :file_name, :class_name, :gemspec, :repo
65
+
66
+ private
67
+
61
68
  def gemspec_path
62
69
  @gemspec_path ||= File.join(path, "#{file_name}.gemspec")
63
70
  end
64
71
 
65
72
  def default_gemspec
66
- @default_gemspec ||= Gem::Specification.new(@file_name, '0.0.1') do |gem|
73
+ @default_gemspec ||= Gem::Specification.new(file_name, '0.0.1') do |gem|
67
74
  gem.author = git('config user.name', 'TODO: Write your name')
68
- gem.description = 'TODO: Write a longer description or delete this line.'
69
75
  gem.email = git('config user.email', 'TODO: Write your email address')
70
- gem.homepage = default_homepage
71
- gem.license = 'BSD-3-Clause'
72
- gem.metadata['changelog_uri'] = default_homepage + '/releases'
76
+
73
77
  gem.summary = 'TODO: Write a short summary, because RubyGems requires one.'
78
+ gem.description = 'TODO: Write a longer description or delete this line.'
79
+ gem.license = 'BSD-3-Clause'
80
+
81
+ gem.metadata['homepage_uri'] = gem.homepage = "https://github.com/#{repo}#readme"
82
+ gem.metadata['changelog_uri'] = "https://github.com/#{repo}/blob/master/CHANGELOG.md"
83
+ gem.metadata['source_code_uri'] = "https://github.com/#{repo}"
74
84
  end
75
85
  end
76
86
 
@@ -80,28 +90,26 @@ module SolidusDevSupport
80
90
  @existing_gemspec ||= Gem::Specification.load(gemspec_path).tap do |spec|
81
91
  spec.author ||= default_gemspec.author
82
92
  spec.email ||= default_gemspec.email
83
- spec.homepage ||= default_gemspec.homepage
84
- spec.license ||= default_gemspec.license
85
- spec.metadata['changelog_uri'] ||= default_gemspec.metadata[:changelog_uri]
93
+
86
94
  spec.summary ||= default_gemspec.summary
95
+ spec.license ||= default_gemspec.license
96
+
97
+ spec.homepage ||= default_gemspec.homepage
98
+ spec.metadata['source_code_uri'] ||= default_gemspec.metadata['source_code_uri']
99
+ spec.metadata['changelog_uri'] ||= default_gemspec.metadata['changelog_uri']
100
+ spec.metadata['source_code_uri'] ||= default_gemspec.metadata['source_code_uri']
87
101
  end
88
102
  end
89
103
 
90
- def default_homepage
91
- @default_homepage ||= git(
92
- 'remote get-url origin',
93
- "git@github.com:#{github_user}/#{file_name}.git"
94
- ).sub(
95
- %r{^.*github\.com.([^/]+)/([^/.]+).*$},
96
- 'https://github.com/\1/\2'
97
- )
104
+ def default_repo
105
+ "solidusio-contrib/#{file_name}"
98
106
  end
99
107
 
100
- def github_user
101
- @github_user ||= git('config github.user', '[USERNAME]')
108
+ def existing_repo
109
+ git('remote get-url origin')&.sub(%r{^.*github\.com.([^/]+)/([^/.]+).*$}, '\1/\2')
102
110
  end
103
111
 
104
- def git(command, default)
112
+ def git(command, default = nil)
105
113
  result = `git #{command} 2> /dev/null`.strip
106
114
  result.empty? ? default : result
107
115
  end
@@ -111,8 +119,6 @@ module SolidusDevSupport
111
119
  executable = (path.stat.mode | 0o111)
112
120
  path.chmod(executable)
113
121
  end
114
-
115
- attr_reader :root, :path, :file_name, :class_name, :gemspec
116
122
  end
117
123
 
118
124
  def self.source_root
@@ -76,11 +76,23 @@ module SolidusDevSupport
76
76
  def install_changelog_task
77
77
  require 'github_changelog_generator/task'
78
78
 
79
- user, project = gemspec.homepage.split("/")[3..5]
80
79
  GitHubChangelogGenerator::RakeTask.new(:changelog) do |config|
81
- config.user = user || 'solidus-contrib'
82
- config.project = project || gemspec.name
83
- config.future_release = "v#{gemspec.version}"
80
+ require 'octokit'
81
+ repo = Octokit::Repository.from_url(gemspec.metadata['source_code_uri'] || gemspec.homepage)
82
+
83
+ config.user = repo.owner
84
+ config.project = repo.name
85
+ config.future_release = "v#{ENV['UNRELEASED_VERSION'] || gemspec.version}"
86
+
87
+ rescue Octokit::InvalidRepository
88
+ warn <<~WARN
89
+ It won't be possible to automatically generate the CHANGELOG for this extension because the
90
+ gemspec is missing the `source_code_uri` metadata. Please add this line to the gemspec to
91
+ enable automatic CHANGELOG generation:
92
+
93
+ s.metadata["source_code_uri"] = 'https://github.com/org/repo'
94
+
95
+ WARN
84
96
  end
85
97
  end
86
98
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'webdrivers/chromedriver'
4
+
3
5
  # Allow to override the initial windows size
4
6
  CAPYBARA_WINDOW_SIZE = (ENV['CAPYBARA_WINDOW_SIZE'] || '1920x1080').split('x', 2).map(&:to_i)
5
7
 
@@ -16,14 +16,12 @@ require 'factory_bot'
16
16
  require 'ffaker'
17
17
 
18
18
  require 'spree/testing_support/authorization_helpers'
19
- require 'spree/testing_support/factories'
20
19
  require 'spree/testing_support/url_helpers'
21
20
  require 'spree/testing_support/preferences'
22
21
  require 'spree/testing_support/controller_requests'
22
+ require 'solidus_dev_support/testing_support/factories'
23
23
  require 'solidus_dev_support/testing_support/preferences'
24
24
 
25
- FactoryBot.find_definitions
26
-
27
25
  RSpec.configure do |config|
28
26
  config.infer_spec_type_from_file_location!
29
27
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'thor'
4
4
  require 'solidus_dev_support/extension'
5
+ require 'spree/core/version'
5
6
 
6
7
  module SolidusDevSupport
7
8
  class SolidusCommand < Thor
@@ -13,6 +14,13 @@ module SolidusDevSupport
13
14
  desc 'e', 'Manage solidus extensions (shortcut for "extension")'
14
15
  subcommand 'e', Extension
15
16
 
17
+ desc 'version', 'Displays solidus_dev_support version'
18
+ def version
19
+ puts "Solidus version #{Spree.solidus_gem_version}"
20
+ puts "Solidus Dev Support version #{SolidusDevSupport::VERSION}"
21
+ end
22
+ map ['-v', '--version'] => :version
23
+
16
24
  def self.exit_on_failure?
17
25
  true
18
26
  end
@@ -1,13 +1,9 @@
1
1
  # <%= class_name.gsub(/(?<=[^A-Z])([A-Z])/, ' \1') %>
2
2
 
3
- <!-- Replace REPO_ORG and uncomment the following to show badges for CI and coverage. -->
3
+ [![CircleCI](https://circleci.com/gh/<%= repo %>.svg?style=shield)](https://circleci.com/gh/<%= repo %>)
4
+ [![codecov](https://codecov.io/gh/<%= repo %>/branch/master/graph/badge.svg)](https://codecov.io/gh/<%= repo %>)
4
5
 
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.]
6
+ <!-- Explain what your extension does. -->
11
7
 
12
8
  ## Installation
13
9
 
@@ -25,7 +21,7 @@ bin/rails generate <%= file_name %>:install
25
21
 
26
22
  ## Usage
27
23
 
28
- [Explain how to use your extension once it's been installed.]
24
+ <!-- Explain how to use your extension once it's been installed. -->
29
25
 
30
26
  ## Development
31
27
 
@@ -81,15 +77,7 @@ git commit -m "Update the changelog"
81
77
 
82
78
  ### Releasing new versions
83
79
 
84
- Your new extension version can be released using `gem-release` like this:
85
-
86
- ```shell
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
92
- ```
80
+ Please refer to the dedicated [page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) on Solidus wiki.
93
81
 
94
82
  ## License
95
83
 
@@ -67,7 +67,7 @@ unbundled bundle install --gemfile Gemfile
67
67
 
68
68
  unbundled bundle exec rake db:drop db:create
69
69
 
70
- unbundled bundle exec rails generate spree:install \
70
+ unbundled bundle exec rails generate solidus:install \
71
71
  --auto-accept \
72
72
  --user_class=Spree::User \
73
73
  --enforce_available_locales=true \
@@ -9,12 +9,12 @@ Gem::Specification.new do |spec|
9
9
  spec.email = '<%= gemspec.email %>'
10
10
 
11
11
  spec.summary = '<%= gemspec.summary %>'
12
- spec.description = '<%= gemspec.description %>'
13
- spec.homepage = '<%= gemspec.homepage %>'
12
+ <% if gemspec.description %>spec.description = '<%= gemspec.description %>'
13
+ <% end %>spec.homepage = '<%= gemspec.homepage %>'
14
14
  spec.license = '<%= gemspec.license %>'
15
15
 
16
16
  spec.metadata['homepage_uri'] = spec.homepage
17
- spec.metadata['source_code_uri'] = '<%= gemspec.homepage %>'
17
+ spec.metadata['source_code_uri'] = '<%= gemspec.metadata["source_code_uri"] %>'
18
18
  spec.metadata['changelog_uri'] = '<%= gemspec.metadata["changelog_uri"] %>'
19
19
 
20
20
  spec.required_ruby_version = Gem::Requirement.new('~> 2.5')
@@ -1,20 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'solidus_core'
4
- require 'solidus_support'
5
-
6
3
  require '<%=file_name%>/configuration'
7
4
  require '<%=file_name%>/version'
8
5
  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
@@ -2,7 +2,20 @@
2
2
 
3
3
  module <%= class_name %>
4
4
  class Configuration
5
- # TODO: Remember to change this with your extension's actual preferences!
6
- # attr_accessor :sample_preference
5
+ # Define here the settings for this extension, e.g.:
6
+ #
7
+ # attr_accessor :my_setting
8
+ end
9
+
10
+ class << self
11
+ def configuration
12
+ @configuration ||= Configuration.new
13
+ end
14
+
15
+ alias config configuration
16
+
17
+ def configure
18
+ yield configuration
19
+ end
7
20
  end
8
21
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spree/core'
4
- require '<%= file_name %>'
3
+ require 'solidus_core'
4
+ require 'solidus_support'
5
5
 
6
6
  module <%= class_name %>
7
7
  class Engine < Rails::Engine
@@ -2,4 +2,4 @@ require:
2
2
  - solidus_dev_support/rubocop
3
3
 
4
4
  AllCops:
5
- NewCops: Enable
5
+ NewCops: disable
@@ -19,7 +19,7 @@ require 'solidus_dev_support/rspec/feature_helper'
19
19
  Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
20
20
 
21
21
  # Requires factories defined in lib/<%= file_name %>/testing_support/factories.rb
22
- require '<%= file_name %>/testing_support/factories'
22
+ SolidusDevSupport::TestingSupport::Factories.load_for(<%= class_name %>::Engine)
23
23
 
24
24
  RSpec.configure do |config|
25
25
  config.infer_spec_type_from_file_location!
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'factory_bot'
4
+
5
+ Spree::Deprecation.silence do
6
+ require 'spree/testing_support/factories'
7
+ puts <<~MSG
8
+ We are transitioning to a new way of loading factories for extensions.
9
+ Be sure this extension does not load factories using require but uses
10
+ the load_for() method in its spec_helper.rb, eg:
11
+
12
+ SolidusDevSupport::TestingSupport::Factories.load_for(ExtensionName1::Engine, ExtensionName2::Engine)
13
+
14
+ This will load Solidus Core factories right before the ones defined in
15
+ lib/extension_name/testing_support/factories/*_factory.rb or
16
+ lib/extension_name/testing_support/factories.rb
17
+
18
+ This message will be removed when all extensions are updated.
19
+ MSG
20
+ end
21
+
22
+ begin
23
+ require 'spree/testing_support/factory_bot'
24
+ rescue LoadError
25
+ # Do nothing, we are testing the extension against an old version of Solidus
26
+ end
27
+
28
+ module SolidusDevSupport
29
+ module TestingSupport
30
+ module Factories
31
+ def self.load_for(*engines)
32
+ paths = engines.flat_map do |engine|
33
+ # Check if the extension has a lib/*/factories.rb. If it does, we emit a
34
+ # deprecation warning and just use it.
35
+ obsolete_factories_file = engine.root.glob('lib/*/factories.rb').first # 'lib/*/factories/*_factory.rb'
36
+ if obsolete_factories_file.present?
37
+ ActiveSupport::Deprecation.warn <<-WARN.squish, caller(4)
38
+ SolidusDevSupport::TestingSupport::Factories.load_for() is automatically loading
39
+ all factories present in #{obsolete_factories_file.dirname.to_s.gsub(engine.root.to_s, '')}/testing_support/factories/.
40
+ Please move the content of #{obsolete_factories_file.to_s.gsub(engine.root.to_s, '')} to that directory.
41
+ WARN
42
+
43
+ [obsolete_factories_file]
44
+ else
45
+ # If there are both a lib/*/testing_support/factories.rb and a lib/*/testing_support/factories/,
46
+ # we assume that the factories.rb file is only used to load all factories prensent in the directory.
47
+ # That file can be removed from the extension, in fact, we ignore it and emit a message asking to
48
+ # remove it.
49
+ factories_file_or_folder = engine.root.glob('lib/*/testing_support/factories{,.rb}')
50
+ if factories_file_or_folder.size == 2
51
+ folder, file = factories_file_or_folder.partition(&:directory?).map(&:first).map { |path| path.to_s.gsub(engine.root.to_s, '') }
52
+ ActiveSupport::Deprecation.warn <<-WARN.squish, caller(4)
53
+ SolidusDevSupport::TestingSupport::Factories.load_for() is automatically loading
54
+ all factories present into #{folder}. You should now safely remove #{file} if it
55
+ is only used to load ./factories content.
56
+ WARN
57
+
58
+ engine.root.glob('lib/*/testing_support/factories/**/*_factory.rb')
59
+ else
60
+ factories_file_or_folder
61
+ end
62
+ end
63
+ end.map { |path| path.sub(/.rb\z/, '').to_s }
64
+
65
+ if using_factory_bot_definition_file_paths?
66
+ FactoryBot.definition_file_paths = [
67
+ Spree::TestingSupport::FactoryBot.definition_file_paths,
68
+ paths,
69
+ ].flatten
70
+
71
+ FactoryBot.reload
72
+ else
73
+ FactoryBot.find_definitions
74
+
75
+ paths.each { |path| require path }
76
+ end
77
+ end
78
+
79
+ def self.using_factory_bot_definition_file_paths?
80
+ defined?(Spree::TestingSupport::FactoryBot) &&
81
+ Spree::TestingSupport::FactoryBot.respond_to?(:definition_file_paths)
82
+ end
83
+ end
84
+ end
85
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusDevSupport
4
- VERSION = "2.1.0"
4
+ VERSION = "2.4.2"
5
5
 
6
6
  def self.gem_version
7
7
  Gem::Version.new(VERSION)
@@ -32,17 +32,18 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency 'capybara-screenshot', '~> 1.0'
33
33
  spec.add_dependency 'codecov', '~> 0.2'
34
34
  spec.add_dependency 'database_cleaner', '~> 1.7'
35
- spec.add_dependency 'factory_bot_rails', '~> 5.1'
35
+ spec.add_dependency 'factory_bot', '~> 4.8'
36
+ spec.add_dependency 'factory_bot_rails'
36
37
  spec.add_dependency 'ffaker', '~> 2.13'
37
38
  spec.add_dependency 'gem-release', '~> 2.1'
38
39
  spec.add_dependency 'github_changelog_generator', '~> 1.15'
39
40
  spec.add_dependency 'puma', '~> 4.3'
40
41
  spec.add_dependency 'rspec_junit_formatter'
41
42
  spec.add_dependency 'rspec-rails', '~> 4.0.0.beta3'
42
- spec.add_dependency 'rubocop', '~> 0.90'
43
+ spec.add_dependency 'rubocop', '~> 1.0'
43
44
  spec.add_dependency 'rubocop-performance', '~> 1.5'
44
45
  spec.add_dependency 'rubocop-rails', '~> 2.3'
45
- spec.add_dependency 'rubocop-rspec', '~> 1.36'
46
+ spec.add_dependency 'rubocop-rspec', '~> 2.0'
46
47
  spec.add_dependency 'solidus_core', ['>= 2.0', '< 3']
47
48
  spec.add_dependency 'webdrivers', '~> 4.4'
48
49
 
@@ -3,6 +3,7 @@
3
3
  require 'fileutils'
4
4
  require 'open3'
5
5
  require 'spec_helper'
6
+ require 'spree/core/version'
6
7
 
7
8
  RSpec.describe 'Create extension' do
8
9
  include FileUtils
@@ -13,8 +14,7 @@ RSpec.describe 'Create extension' do
13
14
  let(:gemspec_name) { "solidus_#{extension_name}.gemspec" }
14
15
  let(:tmp_path) { Pathname.new(gem_root).join('tmp') }
15
16
  let(:install_path) { tmp_path.join("solidus_#{extension_name}") }
16
-
17
- class CommandFailed < StandardError; end
17
+ let(:command_failed_error) { Class.new(StandardError) }
18
18
 
19
19
  before do
20
20
  rm_rf(install_path)
@@ -28,6 +28,7 @@ RSpec.describe 'Create extension' do
28
28
 
29
29
  it 'checks the create extension process' do
30
30
  step :check_solidus_cmd
31
+ step :check_gem_version
31
32
  step :check_create_extension
32
33
  step :check_bundle_install
33
34
  step :check_default_task
@@ -45,6 +46,21 @@ RSpec.describe 'Create extension' do
45
46
  end
46
47
  end
47
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
+
48
64
  def check_create_extension
49
65
  cd(tmp_path) do
50
66
  output = `#{solidus_cmd} extension #{extension_name}`
@@ -83,7 +99,7 @@ RSpec.describe 'Create extension' do
83
99
  open('Gemfile', 'a') { |f| f.puts "gem 'solidus_dev_support', path: '../../..'" }
84
100
  end
85
101
 
86
- expect { bundle_install }.to raise_error(CommandFailed, /invalid gemspec/)
102
+ expect { bundle_install }.to raise_error(command_failed_error, /invalid gemspec/)
87
103
 
88
104
  # Update gemspec with the required fields
89
105
  gemspec_path = install_path.join(gemspec_name)
@@ -106,11 +122,16 @@ RSpec.describe 'Create extension' do
106
122
  end
107
123
 
108
124
  def check_run_specs
125
+ install_path.join('lib', 'solidus_test_extension', 'testing_support', 'factories.rb').open('a') do |factories_file|
126
+ factories_file.write "\n puts 'loading test_extension factories'"
127
+ end
128
+
109
129
  install_path.join('spec', 'some_spec.rb').write(
110
130
  "require 'spec_helper'\nRSpec.describe 'Some test' do it { expect(true).to be_truthy } end\n"
111
131
  )
112
132
  cd(install_path) do
113
133
  output = sh('bundle exec rspec')
134
+ expect(output).to include('loading test_extension factories')
114
135
  expect(output).to include('1 example, 0 failures')
115
136
  expect(output).to include(ENV['CODECOV_TOKEN'] ? 'Coverage reports upload successfully' : 'Provide a CODECOV_TOKEN environment variable to enable Codecov uploads')
116
137
  end
@@ -144,7 +165,7 @@ RSpec.describe 'Create extension' do
144
165
  warn "$ #{command}"
145
166
  warn output.to_s
146
167
  end
147
- raise(CommandFailed, "command failed: #{command}\n#{output}")
168
+ raise(command_failed_error, "command failed: #{command}\n#{output}")
148
169
  end
149
170
  end
150
171
 
@@ -1,33 +1,69 @@
1
1
  require 'solidus_dev_support/extension'
2
2
 
3
3
  RSpec.describe SolidusDevSupport::Extension do
4
- describe '#default_homepage' do
5
- before do
6
- expect(subject).to receive(:git).with('remote get-url origin', any_args).and_return(remote)
7
- expect(subject).to receive(:github_user).and_return('[USERNAME]')
8
- expect(subject).to receive(:file_name).and_return('solidus_foo_bar')
9
- end
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')
10
9
 
11
- context 'with a git ssh-style remote' do
12
- let(:remote) { 'git@github.com:solidusio-contrib/solidus_extension_dev_tools.git' }
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"
13
15
 
14
- it 'generates a github home page value' do
15
- expect(subject.default_homepage).to eq('https://github.com/solidusio-contrib/solidus_extension_dev_tools')
16
- end
17
- end
16
+ gem.summary = 'This extension is awesome!'
17
+ gem.license = 'MIT'
18
18
 
19
- context 'with a git https remote' do
20
- let(:remote) { 'https://github.com/solidusio-contrib/solidus_extension_dev_tools.git' }
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
+ )
21
24
 
22
- it 'generates a github home page value' do
23
- expect(subject.default_homepage).to eq('https://github.com/solidusio-contrib/solidus_extension_dev_tools')
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")
24
40
  end
25
41
  end
26
- end
27
42
 
28
- describe '#default_gemspec' do
29
- it 'has a changelog_uri' do
30
- expect(subject.default_gemspec.metadata['changelog_uri']).to end_with('/releases')
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/master/CHANGELOG.md")
65
+ expect(subject.gemspec.metadata['source_code_uri']).to eq("https://github.com/solidusio-contrib/solidus_my_ext")
66
+ end
31
67
  end
32
68
  end
33
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_dev_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Desantis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-02 00:00:00.000000000 Z
11
+ date: 2021-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -67,19 +67,33 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.7'
69
69
  - !ruby/object:Gem::Dependency
70
- name: factory_bot_rails
70
+ name: factory_bot
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '5.1'
75
+ version: '4.8'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '5.1'
82
+ version: '4.8'
83
+ - !ruby/object:Gem::Dependency
84
+ name: factory_bot_rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: ffaker
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -170,14 +184,14 @@ dependencies:
170
184
  requirements:
171
185
  - - "~>"
172
186
  - !ruby/object:Gem::Version
173
- version: '0.90'
187
+ version: '1.0'
174
188
  type: :runtime
175
189
  prerelease: false
176
190
  version_requirements: !ruby/object:Gem::Requirement
177
191
  requirements:
178
192
  - - "~>"
179
193
  - !ruby/object:Gem::Version
180
- version: '0.90'
194
+ version: '1.0'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: rubocop-performance
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -212,14 +226,14 @@ dependencies:
212
226
  requirements:
213
227
  - - "~>"
214
228
  - !ruby/object:Gem::Version
215
- version: '1.36'
229
+ version: '2.0'
216
230
  type: :runtime
217
231
  prerelease: false
218
232
  version_requirements: !ruby/object:Gem::Requirement
219
233
  requirements:
220
234
  - - "~>"
221
235
  - !ruby/object:Gem::Version
222
- version: '1.36'
236
+ version: '2.0'
223
237
  - !ruby/object:Gem::Dependency
224
238
  name: solidus_core
225
239
  requirement: !ruby/object:Gem::Requirement
@@ -323,6 +337,7 @@ files:
323
337
  - lib/solidus_dev_support/solidus_command.rb
324
338
  - lib/solidus_dev_support/templates/extension/.circleci/config.yml
325
339
  - lib/solidus_dev_support/templates/extension/.github/stale.yml
340
+ - lib/solidus_dev_support/templates/extension/CHANGELOG.md
326
341
  - lib/solidus_dev_support/templates/extension/CONTRIBUTING.md
327
342
  - lib/solidus_dev_support/templates/extension/Gemfile
328
343
  - lib/solidus_dev_support/templates/extension/LICENSE
@@ -355,6 +370,7 @@ files:
355
370
  - lib/solidus_dev_support/templates/extension/rspec
356
371
  - lib/solidus_dev_support/templates/extension/rubocop.yml
357
372
  - lib/solidus_dev_support/templates/extension/spec/spec_helper.rb.tt
373
+ - lib/solidus_dev_support/testing_support/factories.rb
358
374
  - lib/solidus_dev_support/testing_support/preferences.rb
359
375
  - lib/solidus_dev_support/version.rb
360
376
  - solidus_dev_support.gemspec
@@ -383,7 +399,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
383
399
  - !ruby/object:Gem::Version
384
400
  version: '0'
385
401
  requirements: []
386
- rubygems_version: 3.1.2
402
+ rubygems_version: 3.1.4
387
403
  signing_key:
388
404
  specification_version: 4
389
405
  summary: Development tools for Solidus extensions.