module RSpec::SleepingKingStudios::Concerns::SharedExampleGroup
Methods for creating reusable shared example groups and shared contexts in a module that can be mixed into multiple RSpec
example groups.
@example
module MySharedExamples extend RSpec::SleepingKingStudios::Concerns::SharedExampleGroup shared_examples 'my examples' do # Define shared examples here. end # shared_examples end # module RSpec.describe MyObject do include MySharedExamples include_examples 'my examples' end # describe
Public Instance Methods
included(other)
click to toggle source
@api private
Hook to merge defined example groups when included in another module.
Calls superclass method
# File lib/rspec/sleeping_king_studios/concerns/shared_example_group.rb, line 50 def included other super merge_shared_example_groups other end
Private Instance Methods
example_group_definition(example_group)
click to toggle source
# File lib/rspec/sleeping_king_studios/concerns/shared_example_group.rb, line 79 def example_group_definition example_group if example_group.is_a?(Proc) example_group elsif defined?(RSpec::Core::SharedExampleGroupModule) && example_group.is_a?(RSpec::Core::SharedExampleGroupModule) example_group.definition else nil end # if-elsif-else end