Class: Quickie::Stub
Instance Method Summary collapse
-
#initialize(object, method, options = {}) ⇒ Stub
constructor
To set up a stub with optional return value: obj.stub(:method, :return => something).
Constructor Details
#initialize(object, method, options = {}) ⇒ Stub
To set up a stub with optional return value:
obj.stub(:method, :return => something)
To remove existing stub and restore original method:
obj.stub(:method, :remove)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/quickie/stub.rb', line 16 def initialize(object, method, = {}) = { => true } if .is_a?(Symbol) @object, @options = object, @@stash ||= [] # # Create a new stub by intercepting the method or remove existing stub # by restoring the original method. # unless @options[:remove] intercept(method) else restore(method) end end |