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:
And then execute:
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.
Updating existing extensions
If you have an existing extension and want to update it to use the latest standards from this gem, you can run the following in the extension's directory:
$ solidus extension .
In case of conflicting files, you will be prompted for an action. You can overwrite the files with the new version, keep the current version or view the diff and only apply the adjustments that make sense to you.
When developing an extension you will surely need to try it out within a Rails app with Solidus
installed. Using solidus_dev_support your extension will have a
bin/rails-sandbox executable that will
operate on a sandbox app (creating it if necessary).
The path for the sandbox app is
bin/rails-sandbox will forward any Rails command
$ bin/rails-sandbox server => Booting Puma => Rails 126.96.36.199 application starting in development * Listening on tcp://127.0.0.1:3000 Use Ctrl-C to stop
Rebuilding the sandbox app
To rebuild the sandbox app just remove the
./sandbox folder or run
You can control the DB adapter and Solidus version used with the sandbox by providing
SOLIDUS_BRANCH env variables.
DB=[postgres|mysql|sqlite] SOLIDUS_BRANCH=<BRANCH-NAME> bin/sandbox
By default we use sqlite3 and the master branch.
Your extension will have a
bin/rails-engine executable that you can use for generating models, migrations
etc. It's the same as the default
rails command in Rails engines.
$ bin/rails-engine generate migration AddStoreIdToProducts
For convenience a
bin/rails executable is also provided that will run everything but generators on the sandbox application. Generators will instead be processed in the context of the extension.
This gem provides some useful helpers for RSpec to setup an extension's test environment easily.
Add this to your extension's
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
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:
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
Note: Make sure to add this at the VERY TOP of your spec_helper, otherwise you'll get skewed coverage reports!
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
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 -v minor -r
The above command will:
- bump the gem version to the next minor (you can also use
majoror a specific version number);
- commit the change and push it to
- create a Git tag;
- push the tag to the
- 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
require 'solidus_dev_support/rake_tasks' SolidusDevSupport::RakeTasks.install task default: '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 extension
extension:specs(default), which runs the specs for your extension
If your extension requires the
test_app to be always recreated you can do so by running:
bin/rake extension:test_app extension:specs
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
To install this gem onto your local machine, run
To release a new version:
- update the version number in
- update the changelog with
- commit the changes using
Bump SolidusDevSupport to 1.2.3as the message
The last command will create a git tag for the version, push git commits and tags, and push the
.gem file to
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.