Sha256: f6fe502f26fa6a62c1a004dc9c024fc1de0332cf09ab66d5ae7d5b94aa4f1001
Contents?: true
Size: 827 Bytes
Versions: 16
Compression:
Stored size: 827 Bytes
Contents
class Object # Create a stub method on an object. Simply returns a value for a method call on # an object. # # ==== Examples # # my_string = "a wooden rabbit" # my_string.stub!(:retreat!, :return => "run away! run away!") # # # test/your_test.rb # my_string.retreat! # => "run away! run away!" # def stub!(method, options = {}, &block) behavior = (block_given? ? block : proc { return options[:return] }) meta_def method, &behavior end end module Kernel # Create a pure stub object. # # ==== Examples # # stubbalicious = stub(:failure, "wat u say?") # stubbalicious.failure # => "wat u say?" # def stub(method, options = {}, &block) stub_object = Object.new stub_object.stub!(method, options, &block) stub_object end end
Version data entries
16 entries across 16 versions & 4 rubygems