Last active
March 2, 2021 02:21
-
-
Save DiegoOrejuela/e497dacf3c04d8583c5276022c3e8963 to your computer and use it in GitHub Desktop.
Validations fields Devise on Ruby on Rails with Rspec and Shoulda Matchers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
group :test do | |
gem 'rspec-rails' | |
gem 'shoulda-matchers' | |
end | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/spec_helper.rb | |
... | |
# Config Shoulda Matchers | |
Shoulda::Matchers.configure do |config| | |
config.integrate do |with| | |
with.test_framework :rspec | |
with.library :rails | |
end | |
end | |
# Shared examples and Shared context | |
# read more: | |
# - https://relishapp.com/rspec/rspec-core/docs/example-groups/shared-examples | |
# - https://cassidy.codes/blog/2019-09-28-rspec-shared-examples-contexts/ | |
Dir["./spec/support/**/*.rb"].sort.each { |f| require f } | |
... | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/models/user_spec.rb | |
require 'rails_helper' | |
RSpec.describe User, type: :model do | |
include_examples "devise_model_shared_example" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment