Forked from dmitriy-kiriyenko/active_model_lint.rb
Created
February 26, 2016 14:26
-
-
Save mrgenixus/37dcddfc831180a939e8 to your computer and use it in GitHub Desktop.
ActiveModel lint tests for rspec
This file contains hidden or 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
# put the file into spec/support | |
shared_examples_for "ActiveModel" do | |
include ActiveModel::Lint::Tests | |
# to_s is to support ruby-1.9 | |
ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m| | |
example m.gsub('_',' ') do | |
send m | |
end | |
end | |
def model | |
subject | |
end | |
end |
This file contains hidden or 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
# implicit subject | |
describe MyLooksLikeModelClass do | |
it_behaves_like "ActiveModel" | |
end | |
# explicit subject | |
describe "my looks like model class" do | |
subject { MyLooksLikeModelClass.new } | |
it_behaves_like "ActiveModel" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment