Skip to content

Instantly share code, notes, and snippets.

@aliang
Created July 7, 2016 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aliang/3e824becdb74e21eccbb07d3fc334d54 to your computer and use it in GitHub Desktop.
Save aliang/3e824becdb74e21eccbb07d3fc334d54 to your computer and use it in GitHub Desktop.
ActiveModel::Lint tests for MiniTest 5
shared_examples_for "ActiveModel" do
require 'minitest/assertions'
require 'active_model/lint'
include MiniTest::Assertions
include ActiveModel::Lint::Tests
# This is the main difference between MiniTest 4 and 5.
# We must keep a counter of assertions.
attr_accessor :assertions
before do
@model = subject
@assertions = 0
end
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