Sha256: 0715adeb8293be064d8d089fc52cf6b809f28323f146d52daaf262320b8ea17e
Contents?: true
Size: 1.27 KB
Versions: 10
Compression:
Stored size: 1.27 KB
Contents
module Spec module Example # In the future, modules will no longer be automatically included # in the Example Group (based on the description name); when that # time comes, this code should be removed. module ModuleInclusionWarnings # Thanks, Francis Hwang. class MethodDispatcher def initialize(mod, target=nil) @mod = mod @target = target end def respond_to?(sym) @mod && @mod.instance_methods.include?(sym.to_s) end def call(sym, *args, &blk) Kernel.warn("Modules will no longer be automatically included in RSpec version 1.1.4. Called from #{caller[2]}") @target.extend @mod @target.send(sym, *args, &blk) end end # NOTE - we don't need the second arg, but extenders do: http://www.ruby-doc.org/core/classes/Object.html#M000604 def respond_to?(sym, include_private_data=false) MethodDispatcher.new(self.class.described_module).respond_to?(sym) ? true : super end private def method_missing(sym, *args, &blk) md = MethodDispatcher.new(self.class.described_module, self) self.respond_to?(sym) ? md.call(sym, *args, &blk) : super end end end end
Version data entries
10 entries across 10 versions & 3 rubygems