Method: RSpec::Core::SharedExampleGroup#shared_examples
- Defined in:
- lib/rspec/core/shared_example_group.rb
permalink #shared_examples(name, &block) ⇒ void #shared_examples(name, metadata, &block) ⇒ void Also known as: ,
Stores the block for later use. The block will be evaluated
in the context of an example group via include_examples
,
include_context
, or it_behaves_like
.
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/rspec/core/shared_example_group.rb', line 90 def shared_examples(name, *args, &block) top_level = self == ExampleGroup if top_level && RSpec::Support.thread_local_data[:in_example_group] raise "Creating isolated shared examples from within a context is " \ "not allowed. Remove `RSpec.` prefix or move this to a " \ "top-level scope." end RSpec.world.shared_example_group_registry.add(self, name, *args, &block) end |