Check all ActiveRecord object validation after system spec.
This gem is designed for: rspec-rails
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
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
You can avoid validation for specific models:
RSpec.configure do |config|
config.after type: :system do
RSpec::AllRecordsValidator.validate!(ignored_models: [DoNotValidateThisModel])
end
end
RSpec.configure do |config|
config.after type: :system do
RSpec::AllRecordsValidator.validate!(only_has_many: true)
end
end
You can config This setting for feature spec
RSpec.configure do |config|
config.after type: :feature do
RSpec::AllRecordsValidator.validate!
end
end
If you use fixture or master data, ignore them is good for speed.
RSpec::AllRecordsValidator.validate!(ignored_models: [MasterDataModel])
Send me your pull requests.