Sha256: c958df36990203b7a8f78be3256814389eba4232794e6d21095a2d0e57297592

Contents?: true

Size: 1.36 KB

Versions: 7109

Compression:

Stored size: 1.36 KB

Contents

module RSpec
  module Core
    # Exposes {ExampleGroup}-level methods to a module, so you can include that
    # module in an {ExampleGroup}.
    #
    # @example
    #
    #     module LoggedInAsAdmin
    #       extend RSpec::Core::SharedContext
    #       before(:example) do
    #         log_in_as :admin
    #       end
    #     end
    #
    #     describe "admin section" do
    #       include LoggedInAsAdmin
    #       # ...
    #     end
    module SharedContext
      # @private
      def included(group)
        __shared_context_recordings.each do |recording|
          recording.playback_onto(group)
        end
      end

      # @private
      def __shared_context_recordings
        @__shared_context_recordings ||= []
      end

      # @private
      Recording = Struct.new(:method_name, :args, :block) do
        def playback_onto(group)
          group.__send__(method_name, *args, &block)
        end
      end

      # @private
      def self.record(methods)
        methods.each do |meth|
          define_method(meth) do |*args, &block|
            __shared_context_recordings << Recording.new(meth, args, block)
          end
        end
      end

      # @private
      record [:describe, :context] + Hooks.instance_methods(false) +
        MemoizedHelpers::ClassMethods.instance_methods(false)
    end
  end
  # @private
  SharedContext = Core::SharedContext
end

Version data entries

7,109 entries across 7,023 versions & 131 rubygems

Version Path
cybrid_api_id_ruby-0.122.58 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_id_ruby-0.122.57 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_bank_ruby-0.122.57 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_organization_ruby-0.122.57 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_id_ruby-0.122.54 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_bank_ruby-0.122.54 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_organization_ruby-0.122.54 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_bank_ruby-0.122.53 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_organization_ruby-0.122.53 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_id_ruby-0.122.53 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_id_ruby-0.122.52 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_bank_ruby-0.122.52 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_organization_ruby-0.122.52 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_bank_ruby-0.122.51 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_organization_ruby-0.122.51 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_id_ruby-0.122.51 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_bank_ruby-0.122.49 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_id_ruby-0.122.49 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_organization_ruby-0.122.49 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb
cybrid_api_bank_ruby-0.122.48 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/shared_context.rb