Sha256: cc000b590beceecf311ab18f77920abe9e2b0884025e56976c26bf02069075b1
Contents?: true
Size: 910 Bytes
Versions: 6
Compression:
Stored size: 910 Bytes
Contents
module RR # RR::ProbeCreator uses RR::ProbeCreator#method_missing to create # a Scenario that acts like a probe. # # The following example probes method_name with arg1 and arg2 # returning return_value. # # probe(subject).method_name(arg1, arg2) { return_value } # # The ProbeCreator also supports a block sytnax. # # probe(subject) do |m| # m.method_name(arg1, arg2) { return_value } # end class ProbeCreator instance_methods.each { |m| undef_method m unless m =~ /^__/ } def initialize(space, subject) @space = space @subject = subject yield(self) if block_given? end protected def method_missing(method_name, *args, &returns) double = @space.create_double(@subject, method_name) scenario = @space.create_scenario(double) scenario.with(*args).once.implemented_by(double.original_method) end end end
Version data entries
6 entries across 6 versions & 1 rubygems