Skip to content

Instantly share code, notes, and snippets.

@skatkov
Forked from mpouleijn/shared_example.rb
Last active August 29, 2015 14:06
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 skatkov/59078afc543829c681fa to your computer and use it in GitHub Desktop.
Save skatkov/59078afc543829c681fa to your computer and use it in GitHub Desktop.
class MiniTest::Spec
def self.shared_examples
@shared_examples ||= {}
end
end
module MiniTest::Spec::SharedExamples
def shared_examples_for(desc, &block)
MiniTest::Spec.shared_examples[desc] = block
end
def it_behaves_like(desc)
self.instance_eval do
MiniTest::Spec.shared_examples[desc].call
end
end
end
Object.class_eval { include(MiniTest::Spec::SharedExamples) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment