/usr/lib/ruby/vendor_ruby/rspec/core/shared_context.rb is in ruby-rspec-core 3.5.0c3e0m0s0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 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
|