- Fork the project
- Clone your new fork:
git clone [email protected]:[USERNAME]/state_gate.git
- Change your working directory:
cd state_gate
- Change to the most recent version of Ruby
- Install the most recent Bundler:
gem install bundler
- Install the most recent Rake:
gem install rake
- Install the gems:
rake install
(this will take a while!) - Ensure all the tests are passing:
rake test_all
With Ruby versions below 3.0.0
, rake test_all
will test every version of ActiveRecord
from 5.0.0
onwards.
With Ruby version 3.0.0
and above, rake test_all
will test all ActiveRecord versions
from 6.1.0
onwards.
- Create your feature branch
git checkout -b new-feature-branch
- Write tests for your new feature
- Write your feature code
- Run the tests against the most recent ActiveRecord version
rake test_latest
- Check your new code is 100% tested:
rake coverage
- Run the tests against all versions of ActiveRecord
rake test_all
- Check your coding style passes:
rake rubo
- Check your documentation reads well:
rake docs
- Check that all the test pass with the latest version of Ruby
- Check that all the test pass with Ruby 2.5
- Commit your changes
git commit -am 'My New Feature'
- Push the new branch to GitHub
git push origin new-feature-branch
- Create a new Pull Request
Some versions of ActiveRecord require changes in how tests are written, or even if they are include at all.
For example: in ActiveRecord 6.1.0.rc1 the method :update_attributes
was removed.
This does not impact the gem in any way, but test written for previous versions
will now fail.
We can selectively restrict the :update_attributes
tests to only those versions
prior to 6.1.0.rc1 with:
if ActiveRecord.gem_version < Gem::Version.new('6.1.0.rc1')
.....
end
To run individual tests, add the :test
tag to each definition...
it "raises an error for an invalid :to_state", :test do
...
end
...then run rake test_tagged
Alternatively, if you want full control, you will need the rspec command that instructs Appraisal to use the latest ActiveRecord version...
rake spec_command #=> "bundle exec appraisal active-record-6-1-0-rc1 rspec spec/"
...and then use it to run any test you wish:
bundle exec appraisal active-record-6-1-0-rc1 rspec spec/builder/state_methods_spec:29
We use Appraisal to run tests against each individual version of ActiveRecord that the gem supports.
We test with the latest minor version of every Ruby from 2.5 onwards. As some gems are only available for certain Ruby versions, we need to use seperate Gemfiles for each version.
The task rake install
will automatically select the correct gemfile to use and install the gems.
It also adds the x86_64-linux
platform to the lockfile.
We use SimpleCov to ensure test coverage for every line of code. Ensure your test coverage is at 100% before submitting a Pull request.
The coverage report can be generated and opened with: rake coverage
We use SDoc to produce the documentation. Ensure your method comments match the existing style.
Documentation can be generated and opened with: rake docs
We use RuboCop to enforce a consistent style in the codebase. Reading through the exisitng code first is a great way to get started.
Cops can be run with: rake rubo
Run tests against the latest ActiveRecord version.
rake test_latest
or rake
Run tests against all ActiveRecord versions.
rake test_all
Run tagged tests against the latest ActiveRecord version.
rake test_tagged
Display the command to use for running individual tests.
rake spec_command
Install Appraisal dependencies.
rake install
Run test coverage and open report.
rake coverage
Generate documentation and open in browser.
rake doc
or rake docs
Run RuboCop.
rake rubo
Display the command for Bundler with the correct gemfile for the current ruby version.
rake bundler