aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/test/support/shared_examples.rb
blob: e846af404710dcea98f0d0181b243438100e61a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Adapted from https://gist.github.com/jodosha/1560208
MiniTest::Spec.class_eval do
  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, *args, &block)
    instance_exec(*args, &MiniTest::Spec.shared_examples[desc])
    instance_eval(&block) if block_given?
  end
end

Object.class_eval do
  include(MiniTest::Spec::SharedExamples)
end