diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..6bb18c04 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,3 @@ +# .git-blame-ignore-revs +# Convert to standardrb +e466db2b9cf9ae6f8b905bedb758228204ee80ab diff --git a/.rubocop-https---relaxed-ruby-style-rubocop-yml b/.rubocop-https---relaxed-ruby-style-rubocop-yml deleted file mode 100644 index 10f11931..00000000 --- a/.rubocop-https---relaxed-ruby-style-rubocop-yml +++ /dev/null @@ -1,153 +0,0 @@ -# Relaxed.Ruby.Style -## Version 2.5 - -Style/Alias: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylealias - -Style/AsciiComments: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#styleasciicomments - -Style/BeginBlock: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylebeginblock - -Style/BlockDelimiters: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#styleblockdelimiters - -Style/CommentAnnotation: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylecommentannotation - -Style/Documentation: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#styledocumentation - -Layout/DotPosition: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#layoutdotposition - -Style/DoubleNegation: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#styledoublenegation - -Style/EndBlock: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#styleendblock - -Style/FormatString: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#styleformatstring - -Style/IfUnlessModifier: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#styleifunlessmodifier - -Style/Lambda: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylelambda - -Style/ModuleFunction: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylemodulefunction - -Style/MultilineBlockChain: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylemultilineblockchain - -Style/NegatedIf: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylenegatedif - -Style/NegatedWhile: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylenegatedwhile - -Style/NumericPredicate: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylenumericpredicate - -Style/ParallelAssignment: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#styleparallelassignment - -Style/PercentLiteralDelimiters: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylepercentliteraldelimiters - -Style/PerlBackrefs: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#styleperlbackrefs - -Style/Semicolon: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylesemicolon - -Style/SignalException: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylesignalexception - -Style/SingleLineBlockParams: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylesinglelineblockparams - -Style/SingleLineMethods: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylesinglelinemethods - -Layout/SpaceBeforeBlockBraces: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#layoutspacebeforeblockbraces - -Layout/SpaceInsideParens: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#layoutspaceinsideparens - -Style/SpecialGlobalVars: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylespecialglobalvars - -Style/StringLiterals: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylestringliterals - -Style/TrailingCommaInArguments: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarguments - -Style/TrailingCommaInArrayLiteral: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#styletrailingcommainarrayliteral - -Style/TrailingCommaInHashLiteral: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#styletrailingcommainhashliteral - -Style/SymbolArray: - Enabled: false - StyleGuide: http://relaxed.ruby.style/#stylesymbolarray - -Style/WhileUntilModifier: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylewhileuntilmodifier - -Style/WordArray: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#stylewordarray - -Lint/AmbiguousRegexpLiteral: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#lintambiguousregexpliteral - -Lint/AssignmentInCondition: - Enabled: false - StyleGuide: https://relaxed.ruby.style/#lintassignmentincondition - -Layout/LineLength: - Enabled: false - -Metrics: - Enabled: false - diff --git a/.rubocop.yml b/.rubocop.yml index 4f18ebc6..2b8b4216 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,59 +1,8 @@ -inherit_from: - - https://relaxed.ruby.style/rubocop.yml +require: + - standard -Gemspec/RequiredRubyVersion: - Enabled: false -Layout/EmptyLinesAroundAttributeAccessor: - Enabled: true -Layout/SpaceAroundMethodCallOperator: - Enabled: true -Lint/DeprecatedOpenSSLConstant: - Enabled: true -Lint/MixedRegexpCaptureTypes: - Enabled: true -Lint/RaiseException: - Enabled: true -Lint/StructNewOverride: - Enabled: true -Style/AccessorGrouping: - Enabled: true -Style/BisectedAttrAccessor: - Enabled: true -Style/ExponentialNotation: - Enabled: true -Style/HashEachMethods: - Enabled: true -Style/HashTransformKeys: - Enabled: true -Style/HashTransformValues: - Enabled: true -Style/RedundantAssignment: - Enabled: true -Style/RedundantFetchBlock: - Enabled: true -Style/RedundantRegexpCharacterClass: - Enabled: true -Style/RedundantRegexpEscape: - Enabled: true -Style/SlicingWithRange: - Enabled: true - -# Disable this cop until this isssue gets a clear answer: -# https://github.com/rubocop/rubocop/issues/10675 -Gemspec/DeprecatedAttributeAssignment: - Enabled: false +inherit_gem: + standard: config/base.yml AllCops: TargetRubyVersion: 3.0 - Exclude: - - tmp/**/* - - "vendor/**/*" - # Generated binstubs - - bin/rake - NewCops: enable - -Style/FrozenStringLiteralComment: - Exclude: - - "**/bin/*" - - "**/exe/*" - - "spec/**/*" diff --git a/.standard.yml b/.standard.yml new file mode 100644 index 00000000..d8dda41d --- /dev/null +++ b/.standard.yml @@ -0,0 +1,2 @@ +parallel: true # default: false +format: progress # default: Standard::Formatter diff --git a/Gemfile b/Gemfile index ce5c8603..1065eb85 100644 --- a/Gemfile +++ b/Gemfile @@ -7,27 +7,27 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } # Specify your gem's dependencies in solidus_dev_support.gemspec gemspec -branch = ENV.fetch('SOLIDUS_BRANCH', 'main') -gem 'solidus', github: 'solidusio/solidus', branch: branch +branch = ENV.fetch("SOLIDUS_BRANCH", "main") +gem "solidus", github: "solidusio/solidus", branch: branch rails_version = ENV.fetch("RAILS_VERSION", "7.0") -gem 'rails', "~> #{rails_version}" +gem "rails", "~> #{rails_version}" -gem 'bundler' -gem 'rake' +gem "bundler" +gem "rake" # These gems will be used by the temporary extensions generated by tests group :test do - gem 'mysql2' - gem 'pg' - gem 'solidus_auth_devise' - gem 'sqlite3', rails_version < '7.2' ? '~> 1.4' : '~> 2.0' + gem "mysql2" + gem "pg" + gem "solidus_auth_devise" + gem "sqlite3", (rails_version < "7.2") ? "~> 1.4" : "~> 2.0" end # Use a local Gemfile to include development dependencies that might not be # relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`. -eval_gemfile 'Gemfile-local' if File.exist? 'Gemfile-local' +eval_gemfile "Gemfile-local" if File.exist? "Gemfile-local" if rails_version == "7.0" - gem 'concurrent-ruby', '< 1.3.5' + gem "concurrent-ruby", "< 1.3.5" end diff --git a/README.md b/README.md index 113eb50d..facc06de 100644 --- a/README.md +++ b/README.md @@ -168,9 +168,7 @@ jobs: ### RuboCop configuration solidus_dev_support includes a default [RuboCop](https://github.com/rubocop-hq/rubocop) -configuration for Solidus extensions. Currently, this is based on -[Relaxed Ruby Style](https://relaxed.ruby.style) with a few customizations, but in the future we -plan to provide custom cops to ensure your extension follows established Solidus best practices. +configuration for Solidus extensions. This configuration is based on the excellent [`standardrb`](https://github.com/standardrb/standard) gem. We strongly recommend including the RuboCop configuration in your extension. All you have to do is add this to your `.rubocop.yml`: diff --git a/bin/setup b/bin/setup index 4b7cfa1c..859da40c 100755 --- a/bin/setup +++ b/bin/setup @@ -1,11 +1,11 @@ #!/usr/bin/env ruby -require 'fileutils' +require "fileutils" include FileUtils # rubocop:disable Style/MixinUsage -GEM_ROOT = File.expand_path('..', __dir__) +GEM_ROOT = File.expand_path("..", __dir__) def system(*args) - puts "$ #{args.size == 1 ? args.first : args.shelljoin}" + puts "$ #{(args.size == 1) ? args.first : args.shelljoin}" super end @@ -16,5 +16,5 @@ end cd GEM_ROOT puts "\n== Installing Ruby dependencies ==" -system! %{gem install bundler --conservative} -system! %{bundle check || bundle install} +system! %(gem install bundler --conservative) +system! %(bundle check || bundle install) diff --git a/bin/solidus b/bin/solidus index 0cef6dd1..bfd2f480 100755 --- a/bin/solidus +++ b/bin/solidus @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -require 'bundler/setup' +require "bundler/setup" load "#{__dir__}/../exe/solidus" diff --git a/exe/solidus b/exe/solidus index e6a90866..06c3a87e 100755 --- a/exe/solidus +++ b/exe/solidus @@ -1,6 +1,6 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require 'solidus_dev_support/solidus_command' +require "solidus_dev_support/solidus_command" SolidusDevSupport::SolidusCommand.start diff --git a/lib/solidus_dev_support.rb b/lib/solidus_dev_support.rb index a7c0724a..babee4e8 100644 --- a/lib/solidus_dev_support.rb +++ b/lib/solidus_dev_support.rb @@ -7,7 +7,7 @@ class Error < StandardError; end class << self def reset_spree_preferences_deprecated? - first_version_without_reset = Gem::Requirement.new('>= 2.9') + first_version_without_reset = Gem::Requirement.new(">= 2.9") first_version_without_reset.satisfied_by?(Spree.solidus_gem_version) end end diff --git a/lib/solidus_dev_support/extension.rb b/lib/solidus_dev_support/extension.rb index 7e54b69d..36f0accf 100644 --- a/lib/solidus_dev_support/extension.rb +++ b/lib/solidus_dev_support/extension.rb @@ -1,47 +1,47 @@ # frozen_string_literal: true -require 'thor' -require 'pathname' +require "thor" +require "pathname" -require 'solidus_dev_support/version' +require "solidus_dev_support/version" module SolidusDevSupport class Extension < Thor include Thor::Actions - PREFIX = 'solidus_' + PREFIX = "solidus_" default_command :generate - desc 'generate PATH', 'Generates a new Solidus extension' - def generate(raw_path = '.') + desc "generate PATH", "Generates a new Solidus extension" + def generate(raw_path = ".") self.path = raw_path empty_directory path - directory 'app', "#{path}/app" - directory 'lib', "#{path}/lib" - directory 'bin', "#{path}/bin" - directory '.circleci', "#{path}/.circleci" - directory '.github', "#{path}/.github" + directory "app", "#{path}/app" + directory "lib", "#{path}/lib" + directory "bin", "#{path}/bin" + directory ".circleci", "#{path}/.circleci" + directory ".github", "#{path}/.github" Dir["#{path}/bin/*"].each do |bin| make_executable bin end - template 'CHANGELOG.md', "#{path}/CHANGELOG.md" - template 'extension.gemspec', "#{path}/#{file_name}.gemspec" - template 'Gemfile', "#{path}/Gemfile" - template 'gitignore', "#{path}/.gitignore" - template 'gem_release.yml.tt', "#{path}/.gem_release.yml" - template 'LICENSE', "#{path}/LICENSE" - template 'Rakefile', "#{path}/Rakefile" - template 'README.md', "#{path}/README.md" - template 'config/routes.rb', "#{path}/config/routes.rb" - template 'config/locales/en.yml', "#{path}/config/locales/en.yml" - template 'rspec', "#{path}/.rspec" - template 'spec/spec_helper.rb.tt', "#{path}/spec/spec_helper.rb" - template 'rubocop.yml', "#{path}/.rubocop.yml" - template 'github_changelog_generator', "#{path}/.github_changelog_generator" + template "CHANGELOG.md", "#{path}/CHANGELOG.md" + template "extension.gemspec", "#{path}/#{file_name}.gemspec" + template "Gemfile", "#{path}/Gemfile" + template "gitignore", "#{path}/.gitignore" + template "gem_release.yml.tt", "#{path}/.gem_release.yml" + template "LICENSE", "#{path}/LICENSE" + template "Rakefile", "#{path}/Rakefile" + template "README.md", "#{path}/README.md" + template "config/routes.rb", "#{path}/config/routes.rb" + template "config/locales/en.yml", "#{path}/config/locales/en.yml" + template "rspec", "#{path}/.rspec" + template "spec/spec_helper.rb.tt", "#{path}/spec/spec_helper.rb" + template "rubocop.yml", "#{path}/.rubocop.yml" + template "github_changelog_generator", "#{path}/.github_changelog_generator" end no_tasks do @@ -70,17 +70,17 @@ def gemspec_path end def default_gemspec - @default_gemspec ||= Gem::Specification.new(file_name, '0.0.1') do |gem| - gem.author = git('config user.name', 'TODO: Write your name') - gem.email = git('config user.email', 'TODO: Write your email address') + @default_gemspec ||= Gem::Specification.new(file_name, "0.0.1") do |gem| + gem.author = git("config user.name", "TODO: Write your name") + gem.email = git("config user.email", "TODO: Write your email address") - gem.summary = 'TODO: Write a short summary, because RubyGems requires one.' - gem.description = 'TODO: Write a longer description or delete this line.' - gem.license = 'BSD-3-Clause' + gem.summary = "TODO: Write a short summary, because RubyGems requires one." + gem.description = "TODO: Write a longer description or delete this line." + gem.license = "BSD-3-Clause" - gem.metadata['homepage_uri'] = gem.homepage = "https://github.com/#{repo}#readme" - gem.metadata['changelog_uri'] = "https://github.com/#{repo}/blob/main/CHANGELOG.md" - gem.metadata['source_code_uri'] = "https://github.com/#{repo}" + gem.metadata["homepage_uri"] = gem.homepage = "https://github.com/#{repo}#readme" + gem.metadata["changelog_uri"] = "https://github.com/#{repo}/blob/main/CHANGELOG.md" + gem.metadata["source_code_uri"] = "https://github.com/#{repo}" end end @@ -95,9 +95,9 @@ def existing_gemspec spec.license ||= default_gemspec.license spec.homepage ||= default_gemspec.homepage - spec.metadata['source_code_uri'] ||= default_gemspec.metadata['source_code_uri'] - spec.metadata['changelog_uri'] ||= default_gemspec.metadata['changelog_uri'] - spec.metadata['source_code_uri'] ||= default_gemspec.metadata['source_code_uri'] + spec.metadata["source_code_uri"] ||= default_gemspec.metadata["source_code_uri"] + spec.metadata["changelog_uri"] ||= default_gemspec.metadata["changelog_uri"] + spec.metadata["source_code_uri"] ||= default_gemspec.metadata["source_code_uri"] end end @@ -106,7 +106,7 @@ def default_repo end def existing_repo - git('remote get-url origin')&.sub(%r{^.*github\.com.([^/]+)/([^/.]+).*$}, '\1/\2') + git("remote get-url origin")&.sub(%r{^.*github\.com.([^/]+)/([^/.]+).*$}, '\1/\2') end def git(command, default = nil) diff --git a/lib/solidus_dev_support/rake_tasks.rb b/lib/solidus_dev_support/rake_tasks.rb index 7fefc13e..3bcca655 100644 --- a/lib/solidus_dev_support/rake_tasks.rb +++ b/lib/solidus_dev_support/rake_tasks.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require 'rake' -require 'pathname' +require "rake" +require "pathname" module SolidusDevSupport class RakeTasks @@ -13,7 +13,7 @@ def self.install(**args) def initialize(root: Dir.pwd, user_class: "Spree::LegacyUser") @root = Pathname(root) - @test_app_path = @root.join(ENV.fetch('DUMMY_PATH', 'spec/dummy')) + @test_app_path = @root.join(ENV.fetch("DUMMY_PATH", "spec/dummy")) @gemspec = Bundler.load_gemspec(@root.glob("{,*}.gemspec").first) @user_class = user_class end @@ -28,11 +28,11 @@ def install end def install_test_app_task - require 'rake/clean' - require 'spree/testing_support/extension_rake' + require "rake/clean" + require "spree/testing_support/extension_rake" - ENV['DUMMY_PATH'] = test_app_path.to_s - ENV['LIB_NAME'] = gemspec.name + ENV["DUMMY_PATH"] = test_app_path.to_s + ENV["LIB_NAME"] = gemspec.name ::CLOBBER.include test_app_path @@ -40,12 +40,12 @@ def install_test_app_task # We need to go back to the gem root since the upstream # extension:test_app changes the working directory to be the dummy app. task :test_app do - Rake::Task['extension:test_app'].invoke(@user_class) + Rake::Task["extension:test_app"].invoke(@user_class) cd root end - directory ENV.fetch('DUMMY_PATH', nil) do - Rake::Task['extension:test_app'].invoke(@user_class) + directory ENV.fetch("DUMMY_PATH", nil) do + Rake::Task["extension:test_app"].invoke(@user_class) end end end @@ -59,31 +59,31 @@ def install_dev_app_task end def install_rspec_task - require 'rspec/core/rake_task' + require "rspec/core/rake_task" namespace :extension do - ::RSpec::Core::RakeTask.new(:specs, [] => FileList[ENV.fetch('DUMMY_PATH', nil)]) do |t| + ::RSpec::Core::RakeTask.new(:specs, [] => FileList[ENV.fetch("DUMMY_PATH", nil)]) do |t| # Ref: https://circleci.com/docs/2.0/configuration-reference#store_test_results # Ref: https://github.com/solidusio/circleci-orbs-extensions#test-results-rspec - if ENV['TEST_RESULTS_PATH'] + if ENV["TEST_RESULTS_PATH"] t.rspec_opts = "--format progress " \ - "--format RspecJunitFormatter --out #{ENV['TEST_RESULTS_PATH']}" + "--format RspecJunitFormatter --out #{ENV["TEST_RESULTS_PATH"]}" end end end end def install_changelog_task - require 'github_changelog_generator/task' + require "github_changelog_generator/task" GitHubChangelogGenerator::RakeTask.new(:changelog) do |config| - require 'octokit' - repo = Octokit::Repository.from_url(gemspec.metadata['source_code_uri'] || gemspec.homepage) + require "octokit" + repo = Octokit::Repository.from_url(gemspec.metadata["source_code_uri"] || gemspec.homepage) config.user = repo.owner config.project = repo.name - config.future_release = "v#{ENV.fetch('UNRELEASED_VERSION') { gemspec.version }}" + config.future_release = "v#{ENV.fetch("UNRELEASED_VERSION") { gemspec.version }}" rescue Octokit::InvalidRepository warn <<~WARN It won't be possible to automatically generate the CHANGELOG for this extension because the diff --git a/lib/solidus_dev_support/rspec/capybara.rb b/lib/solidus_dev_support/rspec/capybara.rb index 3f548655..2fea86e7 100644 --- a/lib/solidus_dev_support/rspec/capybara.rb +++ b/lib/solidus_dev_support/rspec/capybara.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true # Allow to override the initial windows size -CAPYBARA_WINDOW_SIZE = ENV.fetch('CAPYBARA_WINDOW_SIZE', '1920x1080').split('x', 2).map(&:to_i) +CAPYBARA_WINDOW_SIZE = ENV.fetch("CAPYBARA_WINDOW_SIZE", "1920x1080").split("x", 2).map(&:to_i) CAPYBARA_WINDOW_WIDTH = CAPYBARA_WINDOW_SIZE[0] CAPYBARA_WINDOW_HEIGHT = CAPYBARA_WINDOW_SIZE[1] -Capybara.javascript_driver = ENV.fetch('CAPYBARA_JAVASCRIPT_DRIVER', "solidus_chrome_headless").to_sym +Capybara.javascript_driver = ENV.fetch("CAPYBARA_JAVASCRIPT_DRIVER", "solidus_chrome_headless").to_sym Capybara.default_max_wait_time = 10 -Capybara.server = :puma, { Silent: true } # A fix for rspec/rspec-rails#1897 +Capybara.server = :puma, {Silent: true} # A fix for rspec/rspec-rails#1897 Capybara.drivers[:selenium_chrome_headless].tap do |original_driver| Capybara.register_driver :solidus_chrome_headless do |app| @@ -19,10 +19,10 @@ end end -require 'capybara-screenshot/rspec' +require "capybara-screenshot/rspec" Capybara::Screenshot.register_driver(:solidus_chrome_headless) do |driver, path| driver.browser.save_screenshot(path) end -require 'spree/testing_support/capybara_ext' +require "spree/testing_support/capybara_ext" diff --git a/lib/solidus_dev_support/rspec/coverage.rb b/lib/solidus_dev_support/rspec/coverage.rb index 0f74fe45..bebeae6c 100644 --- a/lib/solidus_dev_support/rspec/coverage.rb +++ b/lib/solidus_dev_support/rspec/coverage.rb @@ -9,23 +9,23 @@ # Note that things may not work properly if you don't include this at the very top! # -require 'simplecov' -SimpleCov.start('rails') do +require "simplecov" +SimpleCov.start("rails") do add_filter %r{^/lib/generators/.*/install/install_generator.rb} add_filter %r{^/lib/.*/factories.rb} add_filter %r{^/lib/.*/version.rb} end -if ENV['CODECOV_TOKEN'] - require 'codecov' +if ENV["CODECOV_TOKEN"] + require "codecov" SimpleCov.formatter = SimpleCov::Formatter::Codecov warn <<~WARN DEPRECATION WARNING: The Codecov ruby uploader is deprecated. Please use the Codecov CLI uploader to upload code coverage reports. See https://docs.codecov.com/docs/deprecated-uploader-migration-guide#ruby-uploader for more information on upgrading. WARN -elsif ENV['CODECOV_COVERAGE_PATH'] - require 'simplecov-cobertura' +elsif ENV["CODECOV_COVERAGE_PATH"] + require "simplecov-cobertura" SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter else warn "Provide a CODECOV_COVERAGE_PATH environment variable to enable Codecov uploads" diff --git a/lib/solidus_dev_support/rspec/feature_helper.rb b/lib/solidus_dev_support/rspec/feature_helper.rb index 24d94d52..55a4908b 100644 --- a/lib/solidus_dev_support/rspec/feature_helper.rb +++ b/lib/solidus_dev_support/rspec/feature_helper.rb @@ -7,8 +7,8 @@ # require 'solidus_dev_support/rspec/feature_helper' # -require 'solidus_dev_support/rspec/rails_helper' -require 'solidus_dev_support/rspec/capybara' +require "solidus_dev_support/rspec/rails_helper" +require "solidus_dev_support/rspec/capybara" dev_support_assets_preload = ->(*) { if Rails.application.respond_to?(:precompiled_assets) diff --git a/lib/solidus_dev_support/rspec/rails_helper.rb b/lib/solidus_dev_support/rspec/rails_helper.rb index 3adb985d..94ca4a0a 100644 --- a/lib/solidus_dev_support/rspec/rails_helper.rb +++ b/lib/solidus_dev_support/rspec/rails_helper.rb @@ -7,20 +7,20 @@ # require 'solidus_dev_support/rspec/rails_helper' # -require 'solidus_dev_support/rspec/spec_helper' -require 'solidus_dev_support' +require "solidus_dev_support/rspec/spec_helper" +require "solidus_dev_support" -require 'rspec/rails' -require 'database_cleaner' -require 'factory_bot' -require 'ffaker' +require "rspec/rails" +require "database_cleaner" +require "factory_bot" +require "ffaker" -require 'spree/testing_support/authorization_helpers' -require 'spree/testing_support/url_helpers' -require 'spree/testing_support/preferences' -require 'spree/testing_support/controller_requests' -require 'solidus_dev_support/testing_support/factories' -require 'solidus_dev_support/testing_support/preferences' +require "spree/testing_support/authorization_helpers" +require "spree/testing_support/url_helpers" +require "spree/testing_support/preferences" +require "spree/testing_support/controller_requests" +require "solidus_dev_support/testing_support/factories" +require "solidus_dev_support/testing_support/preferences" RSpec.configure do |config| config.infer_spec_type_from_file_location! @@ -66,8 +66,8 @@ class ZeitwerkNameError < NameError; end error_message = - if e.message =~ /expected file .*? to define constant [\w:]+/ - e.message.sub(/expected file #{Regexp.escape(File.expand_path('../..', Rails.root))}./, "expected file ") + if /expected file .*? to define constant [\w:]+/.match?(e.message) + e.message.sub(/expected file #{Regexp.escape(File.expand_path("../..", Rails.root))}./, "expected file ") else e.message end diff --git a/lib/solidus_dev_support/rspec/spec_helper.rb b/lib/solidus_dev_support/rspec/spec_helper.rb index ee86b9fc..6a5c9560 100644 --- a/lib/solidus_dev_support/rspec/spec_helper.rb +++ b/lib/solidus_dev_support/rspec/spec_helper.rb @@ -14,8 +14,8 @@ config.mock_with :rspec config.color = true - config.fail_fast = ENV.fetch('FAIL_FAST', false) - config.order = 'random' + config.fail_fast = ENV.fetch("FAIL_FAST", false) + config.order = "random" config.raise_errors_for_deprecations! diff --git a/lib/solidus_dev_support/rubocop/config.yml b/lib/solidus_dev_support/rubocop/config.yml index ed66061f..b7cdeecd 100644 --- a/lib/solidus_dev_support/rubocop/config.yml +++ b/lib/solidus_dev_support/rubocop/config.yml @@ -1,82 +1,12 @@ -require: ["rubocop-rspec", "rubocop-rails", "rubocop-performance"] +require: + - standard -AllCops: {TargetRubyVersion: 2.5, Exclude: ["spec/dummy/**/*", "sandbox/**/*", "vendor/**/*"]} +inherit_gem: + standard: config/base.yml -Layout/ArgumentAlignment: {EnforcedStyle: with_fixed_indentation} -Layout/DotPosition: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#layoutdotposition"} -Layout/EmptyLinesAroundAttributeAccessor: {Enabled: true} -Layout/FirstArgumentIndentation: {EnforcedStyle: "consistent"} -Layout/FirstArrayElementIndentation: {EnforcedStyle: "consistent"} -Layout/LineLength: {Enabled: true, Max: 120} -Layout/MultilineOperationIndentation: {Enabled: false} -Layout/SpaceAroundMethodCallOperator: {Enabled: true} -Layout/SpaceBeforeBlockBraces: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#layoutspacebeforeblockbraces"} -Layout/SpaceInsideParens: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#layoutspaceinsideparens"} -Lint/AmbiguousRegexpLiteral: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#lintambiguousregexpliteral"} -Lint/AssignmentInCondition: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#lintassignmentincondition"} -Lint/DeprecatedOpenSSLConstant: {Enabled: true} -Lint/MixedRegexpCaptureTypes: {Enabled: true} -Lint/RaiseException: {Enabled: true} -Lint/StructNewOverride: {Enabled: true} -Metrics/AbcSize: {Enabled: false} -Metrics/BlockLength: {Enabled: false} -Metrics/BlockNesting: {Enabled: false} -Metrics/ClassLength: {Enabled: false} -Metrics/CyclomaticComplexity: {Enabled: false} -Metrics/MethodLength: {Enabled: false} -Metrics/ModuleLength: {Enabled: false} -Metrics/ParameterLists: {Enabled: false} -Metrics/PerceivedComplexity: {Enabled: false} -Performance/AncestorsInclude: {Enabled: true} -Performance/BigDecimalWithNumericArgument: {Enabled: true} -Performance/RedundantSortBlock: {Enabled: true} -Performance/RedundantStringChars: {Enabled: true} -Performance/ReverseFirst: {Enabled: true} -Performance/SortReverse: {Enabled: true} -Performance/Squeeze: {Enabled: true} -Performance/StringInclude: {Enabled: true} -RSpec/DescribeClass: {Exclude: ["spec/features/**/*"]} # Feature specs are not describing any class or module. -RSpec/ExampleLength: {Enabled: false} -Style/AccessorGrouping: {Enabled: true} -Style/Alias: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylealias"} -Style/AsciiComments: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#styleasciicomments"} -Style/BeginBlock: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylebeginblock"} -Style/BisectedAttrAccessor: {Enabled: true} -Style/BlockDelimiters: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#styleblockdelimiters"} -Style/CommentAnnotation: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylecommentannotation"} -Style/Documentation: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#styledocumentation"} -Style/DoubleNegation: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#styledoublenegation"} -Style/EndBlock: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#styleendblock"} -Style/ExponentialNotation: {Enabled: true} -Style/FormatString: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#styleformatstring"} -Style/FrozenStringLiteralComment: {Exclude: ["spec/**/*", "db/migrate/**/*", "bin/**/*"]} -Style/HashEachMethods: {Enabled: true} -Style/HashTransformKeys: {Enabled: true} -Style/HashTransformValues: {Enabled: true} -Style/IfUnlessModifier: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#styleifunlessmodifier"} -Style/Lambda: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylelambda"} -Style/ModuleFunction: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylemodulefunction"} -Style/MultilineBlockChain: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylemultilineblockchain"} -Style/NegatedIf: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylenegatedif"} -Style/NegatedWhile: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylenegatedwhile"} -Style/NumericPredicate: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylenumericpredicate"} -Style/ParallelAssignment: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#styleparallelassignment"} -Style/PercentLiteralDelimiters: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylepercentliteraldelimiters"} -Style/PerlBackrefs: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#styleperlbackrefs"} -Style/RedundantAssignment: {Enabled: true} -Style/RedundantFetchBlock: {Enabled: true} -Style/RedundantRegexpCharacterClass: {Enabled: true} -Style/RedundantRegexpEscape: {Enabled: true} -Style/Semicolon: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylesemicolon"} -Style/SignalException: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylesignalexception"} -Style/SingleLineBlockParams: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylesinglelineblockparams"} -Style/SingleLineMethods: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylesinglelinemethods"} -Style/SlicingWithRange: {Enabled: true} -Style/SpecialGlobalVars: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylespecialglobalvars"} -Style/StringLiterals: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylestringliterals"} -Style/SymbolArray: {Enabled: false, StyleGuide: "http://relaxed.ruby.style/#stylesymbolarray"} -Style/TrailingCommaInArguments: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#styletrailingcommainarguments"} -Style/TrailingCommaInArrayLiteral: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#styletrailingcommainarrayliteral"} -Style/TrailingCommaInHashLiteral: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#styletrailingcommainhashliteral"} -Style/WhileUntilModifier: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylewhileuntilmodifier"} -Style/WordArray: {Enabled: false, StyleGuide: "https://relaxed.ruby.style/#stylewordarray"} +AllCops: + TargetRubyVersion: 3.0 + Exclude: + - spec/dummy/**/* + - sandbox/**/* + - vendor/**/* diff --git a/lib/solidus_dev_support/solidus_command.rb b/lib/solidus_dev_support/solidus_command.rb index 9f2bf9fd..a7d5c31d 100644 --- a/lib/solidus_dev_support/solidus_command.rb +++ b/lib/solidus_dev_support/solidus_command.rb @@ -1,25 +1,25 @@ # frozen_string_literal: true -require 'thor' -require 'solidus_dev_support/extension' -require 'spree/core/version' +require "thor" +require "solidus_dev_support/extension" +require "spree/core/version" module SolidusDevSupport class SolidusCommand < Thor - namespace '' + namespace "" - desc 'extension', 'Manage solidus extensions' - subcommand 'extension', Extension + desc "extension", "Manage solidus extensions" + subcommand "extension", Extension - desc 'e', 'Manage solidus extensions (shortcut for "extension")' - subcommand 'e', Extension + desc "e", 'Manage solidus extensions (shortcut for "extension")' + subcommand "e", Extension - desc 'version', 'Displays solidus_dev_support version' + desc "version", "Displays solidus_dev_support version" def version puts "Solidus version #{Spree.solidus_gem_version}" puts "Solidus Dev Support version #{SolidusDevSupport::VERSION}" end - map ['-v', '--version'] => :version + map ["-v", "--version"] => :version def self.exit_on_failure? true diff --git a/lib/solidus_dev_support/templates/extension/Rakefile b/lib/solidus_dev_support/templates/extension/Rakefile index a6562a8d..404fc652 100644 --- a/lib/solidus_dev_support/templates/extension/Rakefile +++ b/lib/solidus_dev_support/templates/extension/Rakefile @@ -1,7 +1,7 @@ # frozen_string_literal: true require "bundler/gem_tasks" -require 'solidus_dev_support/rake_tasks' +require "solidus_dev_support/rake_tasks" SolidusDevSupport::RakeTasks.install -task default: 'extension:specs' +task default: "extension:specs" diff --git a/lib/solidus_dev_support/templates/extension/bin/rails-sandbox b/lib/solidus_dev_support/templates/extension/bin/rails-sandbox index ad2df04d..8661d4e0 100755 --- a/lib/solidus_dev_support/templates/extension/bin/rails-sandbox +++ b/lib/solidus_dev_support/templates/extension/bin/rails-sandbox @@ -1,16 +1,16 @@ #!/usr/bin/env ruby -app_root = 'sandbox' +app_root = "sandbox" unless File.exist? "#{app_root}/bin/rails" - warn 'Creating the sandbox app...' + warn "Creating the sandbox app..." Dir.chdir "#{__dir__}/.." do system "#{__dir__}/sandbox" or begin - warn 'Automatic creation of the sandbox app failed' + warn "Automatic creation of the sandbox app failed" exit 1 end end end Dir.chdir app_root -exec 'bin/rails', *ARGV +exec "bin/rails", *ARGV diff --git a/lib/solidus_dev_support/testing_support/factories.rb b/lib/solidus_dev_support/testing_support/factories.rb index fa27bdaf..e7594bd0 100644 --- a/lib/solidus_dev_support/testing_support/factories.rb +++ b/lib/solidus_dev_support/testing_support/factories.rb @@ -1,19 +1,19 @@ # frozen_string_literal: true -require 'factory_bot' -require 'spree/testing_support/factory_bot' +require "factory_bot" +require "spree/testing_support/factory_bot" module SolidusDevSupport module TestingSupport module Factories def self.load_for(*engines) paths = engines.flat_map do |engine| - engine.root.glob('lib/**/testing_support/factories{,.rb}') - end.map { |path| path.sub(/.rb\z/, '').to_s } + engine.root.glob("lib/**/testing_support/factories{,.rb}") + end.map { |path| path.sub(/.rb\z/, "").to_s } FactoryBot.definition_file_paths = [ Spree::TestingSupport::FactoryBot.definition_file_paths, - paths, + paths ].flatten FactoryBot.reload diff --git a/solidus_dev_support.gemspec b/solidus_dev_support.gemspec index dd20c946..f884c697 100644 --- a/solidus_dev_support.gemspec +++ b/solidus_dev_support.gemspec @@ -1,51 +1,47 @@ # frozen_string_literal: true -require_relative 'lib/solidus_dev_support/version' +require_relative "lib/solidus_dev_support/version" Gem::Specification.new do |spec| - spec.name = 'solidus_dev_support' + spec.name = "solidus_dev_support" spec.version = SolidusDevSupport::VERSION - spec.authors = ['Alessandro Desantis'] - spec.email = ['alessandrodesantis@nebulab.it'] + spec.authors = ["Alessandro Desantis"] + spec.email = ["alessandrodesantis@nebulab.it"] - spec.summary = 'Development tools for Solidus extensions.' - spec.homepage = 'https://github.com/solidusio/solidus_dev_support' - spec.license = 'MIT' + spec.summary = "Development tools for Solidus extensions." + spec.homepage = "https://github.com/solidusio/solidus_dev_support" + spec.license = "MIT" - spec.metadata['homepage_uri'] = spec.homepage - spec.metadata['source_code_uri'] = 'https://github.com/solidusio/solidus_dev_support' - spec.metadata['changelog_uri'] = 'https://github.com/solidusio/solidus_dev_support/releases' - spec.metadata['rubygems_mfa_required'] = 'true' + spec.metadata["homepage_uri"] = spec.homepage + spec.metadata["source_code_uri"] = "https://github.com/solidusio/solidus_dev_support" + spec.metadata["changelog_uri"] = "https://github.com/solidusio/solidus_dev_support/releases" + spec.metadata["rubygems_mfa_required"] = "true" - spec.required_ruby_version = '>= 3.0.0' + spec.required_ruby_version = ">= 3.0.0" # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") } spec.files = files.grep_v(%r{^(test|spec|features)/}) - spec.test_files = files.grep(%r{^(test|spec|features)/}) spec.bindir = "exe" spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency 'capybara', '~> 3.29' - spec.add_dependency 'capybara-screenshot', '~> 1.0' - spec.add_dependency 'codecov', '~> 0.2' - spec.add_dependency 'database_cleaner', ['>= 1.7', '< 3'] - spec.add_dependency 'factory_bot', '>= 4.8' - spec.add_dependency 'factory_bot_rails' - spec.add_dependency 'ffaker', '~> 2.13' - spec.add_dependency 'gem-release', '~> 2.1' - spec.add_dependency 'github_changelog_generator', '~> 1.15' - spec.add_dependency 'puma', '>= 4.3', '< 7.0' - spec.add_dependency 'rspec_junit_formatter' - spec.add_dependency 'rspec-rails', '>= 5.0', '< 7.0' - spec.add_dependency 'rubocop', '~> 1.0' - spec.add_dependency 'rubocop-performance', '~> 1.5' - spec.add_dependency 'rubocop-rails', '~> 2.3' - spec.add_dependency 'rubocop-rspec', '~> 2.0' - spec.add_dependency 'selenium-webdriver', '~> 4.11' - spec.add_dependency 'simplecov-cobertura', '~> 2.1' - spec.add_dependency 'solidus_core', ['>= 2.0', '< 5'] + spec.add_dependency "capybara", "~> 3.29" + spec.add_dependency "capybara-screenshot", "~> 1.0" + spec.add_dependency "codecov", "~> 0.2" + spec.add_dependency "database_cleaner", [">= 1.7", "< 3"] + spec.add_dependency "factory_bot", ">= 4.8" + spec.add_dependency "factory_bot_rails" + spec.add_dependency "ffaker", "~> 2.13" + spec.add_dependency "gem-release", "~> 2.1" + spec.add_dependency "github_changelog_generator", "~> 1.15" + spec.add_dependency "puma", ">= 4.3", "< 7.0" + spec.add_dependency "rspec_junit_formatter" + spec.add_dependency "rspec-rails", ">= 5.0", "< 7.0" + spec.add_dependency "selenium-webdriver", "~> 4.11" + spec.add_dependency "simplecov-cobertura", "~> 2.1" + spec.add_dependency "solidus_core", [">= 2.0", "< 5"] + spec.add_dependency "standard", "~> 1.49" end diff --git a/spec/features/create_extension_spec.rb b/spec/features/create_extension_spec.rb index 8575a719..8cda7e0e 100644 --- a/spec/features/create_extension_spec.rb +++ b/spec/features/create_extension_spec.rb @@ -1,18 +1,18 @@ # frozen_string_literal: true -require 'fileutils' -require 'open3' -require 'spec_helper' -require 'spree/core/version' +require "fileutils" +require "open3" +require "spec_helper" +require "spree/core/version" -RSpec.describe 'Create extension' do +RSpec.describe "Create extension" do include FileUtils - let(:gem_root) { File.expand_path('../..', __dir__) } + let(:gem_root) { File.expand_path("../..", __dir__) } let(:solidus_cmd) { "#{gem_root}/exe/solidus" } - let(:extension_name) { 'test_extension' } + let(:extension_name) { "test_extension" } let(:gemspec_name) { "solidus_#{extension_name}.gemspec" } - let(:tmp_path) { Pathname.new(gem_root).join('tmp') } + let(:tmp_path) { Pathname.new(gem_root).join("tmp") } let(:install_path) { tmp_path.join("solidus_#{extension_name}") } let(:command_failed_error) { Class.new(StandardError) } @@ -26,7 +26,7 @@ def step(method_name) send method_name end - it 'checks the create extension process' do + it "checks the create extension process" do step :check_solidus_cmd step :check_gem_version step :check_create_extension @@ -42,12 +42,12 @@ def check_solidus_cmd cd(tmp_path) do output = `#{solidus_cmd} -h` expect($?).to be_success - expect(output).to include('Commands:') + expect(output).to include("Commands:") end end def check_gem_version - gem_version_commands = ['version', '--version', '-v'] + gem_version_commands = ["version", "--version", "-v"] gem_version = SolidusDevSupport::VERSION solidus_version = Spree.solidus_gem_version @@ -66,7 +66,7 @@ def check_create_extension output = `#{solidus_cmd} extension #{extension_name}` expect($?).to be_success expect(output).to include(gemspec_name) - expect(output).to include('.circleci') + expect(output).to include(".circleci") end cd(install_path) do @@ -96,7 +96,7 @@ def check_create_extension def check_bundle_install cd(install_path) do - open('Gemfile', 'a') { |f| f.puts "gem 'solidus_dev_support', path: '../..'" } + open("Gemfile", "a") { |f| f.puts "gem 'solidus_dev_support', path: '../..'" } end # Update gemspec with the required fields @@ -113,25 +113,25 @@ def check_bundle_install def check_default_task cd(install_path) do - output = sh('bin/rake') - expect(output).to include('Generating dummy Rails application') - expect(output).to include('0 examples, 0 failures') + output = sh("bin/rake") + expect(output).to include("Generating dummy Rails application") + expect(output).to include("0 examples, 0 failures") end end def check_run_specs - install_path.join('lib', 'solidus_test_extension', 'testing_support', 'factories.rb').open('a') do |factories_file| + install_path.join("lib", "solidus_test_extension", "testing_support", "factories.rb").open("a") do |factories_file| factories_file.write "\n puts 'loading test_extension factories'" end - install_path.join('spec', 'some_spec.rb').write( + install_path.join("spec", "some_spec.rb").write( "require 'spec_helper'\nRSpec.describe 'Some test' do it { expect(true).to be_truthy } end\n" ) cd(install_path) do - output = sh('bundle exec rspec') - expect(output).to include('loading test_extension factories') - expect(output).to include('1 example, 0 failures') - expect(output).to include(ENV['CODECOV_TOKEN'] ? 'Coverage reports upload successfully' : 'Provide a CODECOV_COVERAGE_PATH environment variable to enable Codecov uploads') + output = sh("bundle exec rspec") + expect(output).to include("loading test_extension factories") + expect(output).to include("1 example, 0 failures") + expect(output).to include(ENV["CODECOV_TOKEN"] ? "Coverage reports upload successfully" : "Provide a CODECOV_COVERAGE_PATH environment variable to enable Codecov uploads") end end @@ -141,22 +141,22 @@ def check_sandbox first_run_output = sh(command) expect(first_run_output).to include("Creating the sandbox app...") - expect(first_run_output).to include('The version of SolidusTestExtension is 0.0.1') + expect(first_run_output).to include("The version of SolidusTestExtension is 0.0.1") second_run_output = sh(command) expect(second_run_output).not_to include("Creating the sandbox app...") - expect(second_run_output).to include('The version of SolidusTestExtension is 0.0.1') + expect(second_run_output).to include("The version of SolidusTestExtension is 0.0.1") end end def sh(*args) - command = args.size == 1 ? args.first : args.shelljoin + command = (args.size == 1) ? args.first : args.shelljoin output, status = with_unbundled_env do - Open3.capture2e({ 'CI' => nil }, command) + Open3.capture2e({"CI" => nil}, command) end - if $DEBUG || ENV['DEBUG'] - warn '~' * 80 + if $DEBUG || ENV["DEBUG"] + warn "~" * 80 warn "$ #{command}" warn output warn "$ #{command} ~~~~> EXIT STATUS: #{status.exitstatus}" @@ -187,7 +187,7 @@ def bundle_install end output = nil - cd(install_path) { output = sh 'bundle install' } + cd(install_path) { output = sh "bundle install" } output end end diff --git a/spec/lib/extension_spec.rb b/spec/lib/extension_spec.rb index 08f09a16..e6a74116 100644 --- a/spec/lib/extension_spec.rb +++ b/spec/lib/extension_spec.rb @@ -1,28 +1,28 @@ -require 'solidus_dev_support/extension' +require "solidus_dev_support/extension" RSpec.describe SolidusDevSupport::Extension do - describe '#path=' do - specify 'with an existing extension' do - allow(subject).to receive(:git).with('remote get-url origin', any_args).and_return('git@github.com:some_user/solidus_my_ext.git') - allow(subject).to receive(:git).with('config user.name', any_args).and_return('John Doe') - allow(subject).to receive(:git).with('config user.email', any_args).and_return('john.doe@example.com') + describe "#path=" do + specify "with an existing extension" do + allow(subject).to receive(:git).with("remote get-url origin", any_args).and_return("git@github.com:some_user/solidus_my_ext.git") + allow(subject).to receive(:git).with("config user.name", any_args).and_return("John Doe") + allow(subject).to receive(:git).with("config user.email", any_args).and_return("john.doe@example.com") - allow(File).to receive(:exist?).with('/foo/bar/solidus_my_ext/solidus_my_ext.gemspec').and_return(true) - allow(Gem::Specification).to receive(:load).with('/foo/bar/solidus_my_ext/solidus_my_ext.gemspec').and_return( - Gem::Specification.new('solidus_my_ext', '0.1.1') do |gem| + allow(File).to receive(:exist?).with("/foo/bar/solidus_my_ext/solidus_my_ext.gemspec").and_return(true) + allow(Gem::Specification).to receive(:load).with("/foo/bar/solidus_my_ext/solidus_my_ext.gemspec").and_return( + Gem::Specification.new("solidus_my_ext", "0.1.1") do |gem| gem.author = "Jane Doe" gem.email = "jane.doe@example.com" - gem.summary = 'This extension is awesome!' - gem.license = 'MIT' + gem.summary = "This extension is awesome!" + gem.license = "MIT" gem.homepage = "some_user.github.io/solidus_my_ext" - gem.metadata['changelog_uri'] = "https://github.com/some_user/solidus_my_ext/releases" - gem.metadata['source_code_uri'] = "https://github.com/some_user/solidus_my_ext" + gem.metadata["changelog_uri"] = "https://github.com/some_user/solidus_my_ext/releases" + gem.metadata["source_code_uri"] = "https://github.com/some_user/solidus_my_ext" end ) - subject.path = '/foo/bar/solidus_my_ext' + subject.path = "/foo/bar/solidus_my_ext" aggregate_failures do expect(subject.file_name).to eq("solidus_my_ext") @@ -30,24 +30,24 @@ expect(subject.root).to eq("/foo/bar") expect(subject.path).to eq("/foo/bar/solidus_my_ext") expect(subject.repo).to eq("some_user/solidus_my_ext") - expect(subject.gemspec.author).to eq('Jane Doe') - expect(subject.gemspec.email).to eq('jane.doe@example.com') - expect(subject.gemspec.summary).to eq('This extension is awesome!') - expect(subject.gemspec.license).to eq('MIT') + expect(subject.gemspec.author).to eq("Jane Doe") + expect(subject.gemspec.email).to eq("jane.doe@example.com") + expect(subject.gemspec.summary).to eq("This extension is awesome!") + expect(subject.gemspec.license).to eq("MIT") expect(subject.gemspec.homepage).to eq("some_user.github.io/solidus_my_ext") - expect(subject.gemspec.metadata['changelog_uri']).to eq("https://github.com/some_user/solidus_my_ext/releases") - expect(subject.gemspec.metadata['source_code_uri']).to eq("https://github.com/some_user/solidus_my_ext") + expect(subject.gemspec.metadata["changelog_uri"]).to eq("https://github.com/some_user/solidus_my_ext/releases") + expect(subject.gemspec.metadata["source_code_uri"]).to eq("https://github.com/some_user/solidus_my_ext") end end - specify 'when creating a new extension' do - allow(subject).to receive(:git).with('remote get-url origin', any_args) { |_, default| default } - allow(subject).to receive(:git).with('config user.name', any_args).and_return('John Doe') - allow(subject).to receive(:git).with('config user.email', any_args).and_return('john.doe@example.com') + specify "when creating a new extension" do + allow(subject).to receive(:git).with("remote get-url origin", any_args) { |_, default| default } + allow(subject).to receive(:git).with("config user.name", any_args).and_return("John Doe") + allow(subject).to receive(:git).with("config user.email", any_args).and_return("john.doe@example.com") - allow(Dir).to receive(:pwd).and_return('/foo/bar') + allow(Dir).to receive(:pwd).and_return("/foo/bar") - subject.path = '/foo/bar/solidus_my_ext' + subject.path = "/foo/bar/solidus_my_ext" aggregate_failures do expect(subject.file_name).to eq("solidus_my_ext") @@ -55,14 +55,14 @@ expect(subject.root).to eq("/foo/bar") expect(subject.path).to eq("/foo/bar/solidus_my_ext") expect(subject.repo).to eq("solidusio-contrib/solidus_my_ext") - expect(subject.gemspec.author).to eq('John Doe') - expect(subject.gemspec.email).to eq('john.doe@example.com') - expect(subject.gemspec.summary).to eq('TODO: Write a short summary, because RubyGems requires one.') - expect(subject.gemspec.description).to eq('TODO: Write a longer description or delete this line.') - expect(subject.gemspec.license).to eq('BSD-3-Clause') + expect(subject.gemspec.author).to eq("John Doe") + expect(subject.gemspec.email).to eq("john.doe@example.com") + expect(subject.gemspec.summary).to eq("TODO: Write a short summary, because RubyGems requires one.") + expect(subject.gemspec.description).to eq("TODO: Write a longer description or delete this line.") + expect(subject.gemspec.license).to eq("BSD-3-Clause") expect(subject.gemspec.homepage).to eq("https://github.com/solidusio-contrib/solidus_my_ext#readme") - expect(subject.gemspec.metadata['changelog_uri']).to eq("https://github.com/solidusio-contrib/solidus_my_ext/blob/main/CHANGELOG.md") - expect(subject.gemspec.metadata['source_code_uri']).to eq("https://github.com/solidusio-contrib/solidus_my_ext") + expect(subject.gemspec.metadata["changelog_uri"]).to eq("https://github.com/solidusio-contrib/solidus_my_ext/blob/main/CHANGELOG.md") + expect(subject.gemspec.metadata["source_code_uri"]).to eq("https://github.com/solidusio-contrib/solidus_my_ext") end end end