A gem that can automatically create the needed spec tests by reading through the files of the project.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Build Status Gem Version

SpecProducer is a library that is meant to assist users in skipping the tedious work of creating spec tests for basic Rails applications. It reads through Active Record subclasses of the project and prepares some of the basic spec tests for you.


Add this line to your application's Gemfile:

group :development do
  gem 'spec_producer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install spec_producer


Currently this gem supports the production of spec tests for active record models. If the spec file already exists then it prints out the contents it would generated for a model.

To produce all possible tests you can run the public API methods directly from a Rails console or use the rake tasks provided by the gem (run rake -T | grep spec_producer for all available rake tasks) on a rails project.

  # Using a rake task (currently supports producing only model specs)
  bundle exec rake spec_producer:all

  #or produce all tests for models:

  bundle exec rake spec_producer:models

To produce all tests for routes, run:

bundle exec rake spec_producer:routes

To produce all spec files for views, run:

bundle exec rake spec_producer:views

To produce all spec files for helpers, run:

bundle exec rake spec_producer:helpers

To produce all spec files for controllers, run:

bundle exec rake spec_producer:controllers

To produce all spec files for jobs, run:

bundle exec rake spec_producer:jobs

To produce all spec files for mailers, run:

bundle exec rake spec_producer:mailers

To produce all spec files for serializers, run:

bundle exec rake spec_producer:serializers

In case you have factory_girl gem installed, to produce a list of sample factory files for your models, run:

bundle exec rake spec_producer:factories

Additionally this gem (from version 0.2.0) allows users to print all their missing spec files by reading all directories for Views, Models, Controllers, Helpers etc.

To print all types of missing tests, run:

bundle exec rake missing_specs_printer:all

To print all missing model tests, run:

bundle exec rake missing_specs_printer:models

To print all missing controller tests, run:

bundle exec rake missing_specs_printer:controllers

To print all missing helper tests, run:

bundle exec rake missing_specs_printer:helpers

To print all missing view tests, run:

bundle exec rake missing_specs_printer:views

To print all missing job tests, run:

bundle exec rake missing_specs_printer:jobs

To print all missing mailer tests, run:

bundle exec rake missing_specs_printer:mailers

To print all missing route tests, run:

bundle exec rake missing_specs_printer:routes

To print all missing serializer tests, run:

bundle exec rake missing_specs_printer:serializers


After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests.


Bug reports and pull requests are welcome on GitHub at https://github.com/arcanoid/spec_producer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


The gem is available as open source under the terms of the MIT License.