Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

colorbox/rspec-all_records_validator

Open more actions menu

Repository files navigation

RSpec::AllRecordsValidator

Check all ActiveRecord object validation after system spec.

This gem is designed for: rspec-rails

Setup

Install

Add this line to your application's Gemfile in test group:

group :test do
  gem 'rspec-all_records_validator'
end

And then execute:

$ bundle install

Configure

Add below to your spec_helper.rb

require 'rspec/all_records_validator'

RSpec.configure do |config|
  config.after type: :system do
    RSpec::AllRecordsValidator.validate!
  end
end

Avoid validation for specific model

You can avoid validation for specific models:

RSpec.configure do |config|
  config.after type: :system do
    RSpec::AllRecordsValidator.validate!(ignored_models: [DoNotValidateThisModel])
  end
end

Avoid validation for model whitch has no has_many association

RSpec.configure do |config|
  config.after type: :system do
    RSpec::AllRecordsValidator.validate!(only_has_many: true)
  end
end

For feature spec

You can config This setting for feature spec

RSpec.configure do |config|
  config.after type: :feature do
    RSpec::AllRecordsValidator.validate!
  end
end

Pro Tip

If you use fixture or master data, ignore them is good for speed.

RSpec::AllRecordsValidator.validate!(ignored_models: [MasterDataModel])

Contributing

Send me your pull requests.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
Morty Proxy This is a proxified and sanitized view of the page, visit original site.