Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Adopted Ruby 2.4+ as the minimum Ruby version in generated extensions
- Added `bin/console`, `bin/rails` and `bin/setup` to generated extensions
- Added some Bundler gemspec defaults to generated extensions

### Changed

Expand Down
27 changes: 19 additions & 8 deletions lib/solidus_dev_support/templates/extension/extension.gemspec.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,31 @@ $:.push File.expand_path('lib', __dir__)
require '<%= file_name %>/version'

Gem::Specification.new do |s|
s.name = '<%= file_name %>'
s.version = <%= class_name %>::VERSION
s.summary = 'TODO'
s.name = '<%= file_name %>'
s.version = <%= class_name %>::VERSION
s.summary = 'TODO'
s.description = 'TODO'
s.license = 'BSD-3-Clause'
s.license = 'BSD-3-Clause'

# s.author = 'You'
# s.email = 'you@example.com'
# s.homepage = 'http://www.example.com'
# s.author = 'You'
# s.email = 'you@example.com'
# s.homepage = 'http://www.example.com'

if s.respond_to?(:metadata)
s.metadata["homepage_uri"] = s.homepage if s.homepage
s.metadata["source_code_uri"] = s.homepage if s.homepage
s.metadata["changelog_uri"] = 'TODO'
end

s.required_ruby_version = '~> 2.4'

s.files = Dir["{app,config,db,lib}/**/*", 'LICENSE', 'Rakefile', 'README.md']
s.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
s.test_files = Dir['spec/**/*']
s.bindir = "exe"
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_dependency 'solidus_core', ['>= 2.0.0', '< 3']
s.add_dependency 'solidus_support', '~> 0.4.0'
Expand Down
9 changes: 5 additions & 4 deletions spec/features/create_extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
let(:gemspec_name) { "solidus_#{extension_name}.gemspec" }
let(:tmp_path) { Pathname.new(ext_root).join('spec', 'tmp') }
let(:install_path) { tmp_path.join("solidus_#{extension_name}") }
let(:command_failed) { Class.new(StandardError) }

class CommandFailed < StandardError; end
Comment thread
elia marked this conversation as resolved.

around do |example|
rm_rf(tmp_path)
Expand Down Expand Up @@ -48,11 +49,11 @@ def check_bundle_install
cd(install_path) do
sh('bundle install')
end
}.to raise_error(command_failed, /invalid gemspec/)
}.to raise_error(CommandFailed, /invalid gemspec/)

# Update gemspec with the required fields
gemspec_path = install_path.join(gemspec_name)
new_content = gemspec_path.read.gsub(/\n.*s.author[^\n]+/, "\n s.author = 'someone'").gsub(/TODO/, 'something')
new_content = gemspec_path.read.gsub(/\n.*s.author[^\n]+/, "\n s.author = 'someone'").gsub(/TODO/, 'https://example.com')
gemspec_path.write(new_content)

cd(install_path) do
Expand Down Expand Up @@ -84,7 +85,7 @@ def check_run_specs
def sh(*args)
command = args.size == 1 ? args.first : args.shelljoin
stdout, stderr, status = Bundler.with_clean_env { Open3.capture3(command) }
status.success? ? stdout : raise(command_failed, "command failed: #{command}\n#{stderr}\n#{stdout}")
status.success? ? stdout : raise(CommandFailed, "command failed: #{command}\n#{stderr}\n#{stdout}")
end

it 'checks the create extension process' do
Expand Down