This gem contains common development functionality for Solidus extensions.
If you're looking for runtime tools instead, look at solidus_support.
Add this gem as a development dependency of your extension:
spec.add_development_dependency 'solidus_dev_support'
And then execute:
$ bundle
This gem provides a generator for Solidus extensions. To use it, simply run:
$ solidus extension my_awesome_extension
This will generate the basic extension structure, already configured to use all the shiny helpers in solidus_dev_support.
This gem provides some useful helpers for RSpec to setup an extension's test environment easily.
Add this to your extension's spec/spec_helper.rb
:
require 'solidus_dev_support/rspec/feature_helper'
This helper loads configuration needed to run extension feature specs correctly, setting up Capybara and configuring a Rails test application to precompile assets before the first feature spec.
feature_helper
builds on top of rails_helper
, which you can also use a standalone helper if you
want:
require 'solidus_dev_support/rspec/rails_helper'
This will include the Rails and Solidus-related RSpec configuration, such as authorization helpers, Solidus factories, URL helpers, and other helpers to easily work with Solidus.
rails_helper
, in turn, builds on top of spec_helper
, which is responsible for setting up a
basic RSpec environment:
require 'solidus_dev_support/rspec/spec_helper'
The gem also includes a SimpleCov configuration that will send your test coverage information
directly to Codecov.io. Simply add this at the top of your spec/spec_helper.rb
:
require 'solidus_dev_support/rspec/coverage'
Note: Make sure to add this at the VERY TOP of your spec_helper, otherwise you'll get skewed coverage reports!
If your extension is in a public repo and being tested on Travis or CircleCI, there's nothing else you need to do! If your setup is more complex, look at the SimpleCov and codecov-ruby docs.
solidus_dev_support includes a default RuboCop configuration for Solidus extensions. Currently, this is based on 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.
We strongly recommend including the RuboCop configuration in your extension. All you have to do is
add this to your .rubocop.yml
:
require:
- solidus_dev_support/rubocop
You can now run RuboCop with:
$ bundle exec rubocop
Generating a changelog for your extension is possible by running this command:
$ CHANGELOG_GITHUB_TOKEN="«your-40-digit-github-token»" bundle exec github_changelog_generator github_username/github_project
This generates a CHANGELOG.md
, with pretty Markdown formatting.
For further instructions please read the GitHub Changelog Generator documentation.
By installing solidus_dev_support, you also get
gem release
, which you can use to automatically manage
releases for your gem.
For instance, you can run the following to release a new minor version:
$ gem bump --version minor --tag --release
The above command will:
- bump the gem version to the next minor;
- commit the change and push it to
upstream/master
; - create a Git tag;
- push the tag to the
upstream
remote; - release the new version on RubyGems.
You can refer to
gem release
's documentation for
further configuration and usage instructions.
To install extension-related Rake tasks, add this to your Rakefile
:
require 'solidus_dev_support/rake_tasks'
SolidusDevSupport::RakeTasks.install
task default: %w[extension:test_app extension:specs]
(If your extension used the legacy extension Rakefile, then you should completely replace its contents with the block above.)
This will provide the following tasks:
extension:test_app
, which generates a dummy app for your extensionextension:specs
(default), which runs the specs for your extension
It also allows you to run rake
to, respectively, generate a test app and run all tests.
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
rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/solidusio/solidus_dev_support.
The gem is available as open source under the terms of the MIT License.