by ndea

Generate specs for your rails application the easy way. Regressor generates model and controller spe...

204 Stars 33 Forks Last release: Not found MIT License 219 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Gem Version Code Climate Bitdeli Badge


Regressor is a regression based testing tool. What is regression testing? see here. You can generate specs based on your ActiveRecord models.

Made with ♥ at Qurasoft

Get Regressor

Directly from GitHub
gem 'regressor', git: '', branch: 'master'


gem 'regressor', '~> 0.6.2'


bundle install
rails g regressor:install

This will create an initializer in config/initializers. This initializers looks like this:

# If the regressor gem is inside a group wrap your initializer in
# if defined?(Regressor) do .. end
Regressor.configure do |config|
  # Defines the path where the generated files for your models will be placed
  # config.regression_path = 'spec/models/regression'

Defines the path where the generated files for your controllers will be placed

config.regression_controller_path = 'spec/controllers/regression'

Exclude Models for regression spec generation.

Provide model names as String (e.g. 'User')

config.excluded_models = []

Exclude Controllers for regression generation.

Provide controller names as String (e.g. 'UsersController').

config.excluded_controllers = []

If you are using enums in Rails 4 enable this option to generate regression specs for enums.

If your Rails version is =< Rails 3 set this option to false.

Default this option is set to true.

config.include_enums = true


Then require the gem dependency 'shoulda-matchers' in your railshelper (or spechelper if you're using RSpec 2.x):

require 'shoulda/matchers'

If you are using mongoid please add mongoid-rspec.


Run the generator:

Be sure to run the generators in the

environment so that
-only gems are not being loaded, causing strange issues with controller filters and ActiveRecord callbacks.
RAILS_ENV=test rails generate regressor:model # Create Regression specs for your models
RAILS_ENV=test rails generate regressor:controller # Create Regression specs for your controllers
RAILS_ENV=test rails generate regressor:mongoid:model # Create regression specs for your mongoid models

You can even generate empty factories for your models simply by running

RAILS_ENV=test rails generate regressor:factory # Create empty factories based on your models
Supported Regressions

Empty factories can be created.

  • Relations
    • belongs_to
    • has_many
    • has_one
  • Nested Attributes
  • Validations
    • Length
    • Presence
    • Numericality
  • Database
    • Columns
    • Indexes
  • Enums (Rails 4)
  • Relations
    • belongs_to
    • has_many
    • has_one
    • embeds_one
    • embeds_many
  • Database
    • Fields
  • Document
    • Includes
    • Versioning
  • Routing
  • Callbacks
    • Before filter
    • After filter
    • Around filter

Also see

Airpair - Generate specs for your Rails application

Guard for regressor


  1. Fork it ( )
  2. Create your feature branch (
    git checkout -b my-new-feature
  3. Commit your changes (
    git commit -am 'Add some feature'
  4. Push to the branch (
    git push origin my-new-feature
  5. Create a new Pull Request

Contribution topics wanted

  • Specs
  • Documentation
  • Bugfixes
  • Codestyle
  • Anything that improves this gem

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.