-
-
Save mikegehard/910773 to your computer and use it in GitHub Desktop.
RSpec shared examples for ActiveModel::Lint
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
# adapted from rspec-rails http://github.com/rspec/rspec-rails/blob/master/spec/rspec/rails/mocks/mock_model_spec.rb | |
# put this in a file in your spec/support directory | |
# USAGE: | |
# | |
# let(:model) { ModelUnderTest.new(params) } | |
# it_behaves_like "ActiveModel" | |
shared_examples_for "ActiveModel" do | |
require 'test/unit/assertions' | |
require 'active_model/lint' | |
include Test::Unit::Assertions | |
include ActiveModel::Lint::Tests | |
ActiveModel::Lint::Tests.public_instance_methods.map { |method| method.to_s }.grep(/^test/).each do |method| | |
example(method.gsub('_', ' ')) { send method } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment