Module: Crspec::SharedDSL

Included in:
ExampleGroup
Defined in:
lib/crspec/shared_examples.rb

Instance Method Summary collapse

Instance Method Details

#include_context(name, *args) ⇒ Object Also known as: include_examples



48
49
50
51
52
53
54
55
# File 'lib/crspec/shared_examples.rb', line 48

def include_context(name, *args)
  block = Crspec::SharedRegistry.fetch(name)
  if args.empty?
    instance_eval(&block)
  else
    instance_exec(*args, &block)
  end
end

#it_behaves_like(name, *args) ⇒ Object Also known as: it_should_behave_like



58
59
60
61
62
63
64
65
66
67
# File 'lib/crspec/shared_examples.rb', line 58

def it_behaves_like(name, *args)
  block = Crspec::SharedRegistry.fetch(name)
  child = describe("behaves like #{name}") {}
  if args.empty?
    child.instance_eval(&block)
  else
    child.instance_exec(*args, &block)
  end
  child
end

#shared_examples(name, &block) ⇒ Object Also known as: shared_examples_for, shared_context



42
43
44
# File 'lib/crspec/shared_examples.rb', line 42

def shared_examples(name, &block)
  Crspec::SharedRegistry.register(name, block)
end