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
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ and [codecov-ruby](https://github.com/codecov/codecov-ruby) docs.
### RuboCop configuration

solidus_extension_dev_tools includes a default [RuboCop](https://github.com/rubocop-hq/rubocop)
configuration for Solidus extensions. Currently, this is based on
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.

Expand All @@ -78,7 +78,7 @@ add this to your `.rubocop.yml`:
```yaml
require:
- solidus_extension_dev_tools/rubocop
```
```

You can now run RuboCop with:

Expand Down Expand Up @@ -118,19 +118,30 @@ The above command will:
* push the tag to the `upstream` remote;
* release the new version on RubyGems.

You can refer to
You can refer to
[`gem release`'s documentation](https://github.com/svenfuchs/gem-release/blob/master/README.md) for
further configuration and usage instructions.

### Rake tasks

Put this in your `Rakefile`:

```rb
require 'solidus_extension_dev_tools/rake_tasks'
SolidusExtensionDevTools::RakeTasks.install

task default: 'extension:specs'
```

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run
the tests. You can also run `bin/console` for an interactive prompt that will allow you to
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run
the tests. You can also run `bin/console` for an interactive prompt that will allow you to
experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new
version, update the version number in `version.rb`, and then run `bundle exec rake release`, which
will create a git tag for the version, push git commits and tags, and push the `.gem` file to
To install this gem onto your local machine, run `bundle exec rake install`. To release a new
version, update the version number in `version.rb`, and then run `bundle exec rake release`, which
will create a git tag for the version, push git commits and tags, and push the `.gem` file to
[rubygems.org](https://rubygems.org).

## Contributing
Expand Down
51 changes: 51 additions & 0 deletions lib/solidus_extension_dev_tools/rake_tasks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# frozen_string_literal: true

require 'rake'
require 'pathname'

module SolidusExtensionDevTools
class RakeTasks
include Rake::DSL

def self.install(*args)
new(*args).tap(&:install)
end

def initialize(root: Dir.pwd)
@root = Pathname(root)
@test_app_path = @root.join(ENV['DUMMY_PATH'] || 'spec/dummy')
@gemspec = Bundler.load_gemspec(@root.glob("{,*}.gemspec").first)
end

attr_reader :test_app_path, :root, :gemspec

def install
install_test_app_task
install_rspec_task
end

def install_test_app_task
require 'rake/clean'
::CLOBBER.include test_app_path

ENV['DUMMY_PATH'] = test_app_path
ENV['LIB_NAME'] = gemspec.name
require 'spree/testing_support/extension_rake'
end

def install_rspec_task
namespace :extension do
require 'rspec/core/rake_task'
::RSpec::Core::RakeTask.new(:specs, [] => :test_app) 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']
t.rspec_opts =
"--format progress " \
"--format RspecJunitFormatter --out #{ENV['TEST_RESULTS_PATH']}"
end
end
end
end
end
end
1 change: 1 addition & 0 deletions solidus_extension_dev_tools.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'gem-release', '~> 2.1'
spec.add_dependency 'github_changelog_generator', '~> 1.15'
spec.add_dependency 'rspec-rails', '~> 4.0.0.beta3'
spec.add_dependency 'rspec_junit_formatter'
Comment thread
aldesantis marked this conversation as resolved.
spec.add_dependency 'rubocop', '~> 0.76.0'
spec.add_dependency 'rubocop-performance', '~> 1.5'
spec.add_dependency 'rubocop-rails', '~> 2.3'
Expand Down