Class: BooticClient::Stubbing::Stub
- Inherits:
-
Object
- Object
- BooticClient::Stubbing::Stub
- Includes:
- Stubber
- Defined in:
- lib/bootic_client/stubbing.rb
Instance Method Summary collapse
- #and_return_data(data) ⇒ Object
-
#initialize(method_name = '', opts = {}) ⇒ Stub
constructor
A new instance of Stub.
- #returns ⇒ Object
- #returns? ⇒ Boolean
Methods included from Stubber
#from_hash, #method_missing, #respond_to_missing?, #stub, #stub_chain
Constructor Details
#initialize(method_name = '', opts = {}) ⇒ Stub
Returns a new instance of Stub.
91 92 93 94 95 |
# File 'lib/bootic_client/stubbing.rb', line 91 def initialize(method_name = '', opts = {}) @method_name, @opts = method_name, opts @return_data = nil @stubs = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class BooticClient::Stubbing::Stubber
Instance Method Details
#and_return_data(data) ⇒ Object
97 98 99 100 |
# File 'lib/bootic_client/stubbing.rb', line 97 def and_return_data(data) @return_data = data self end |
#returns ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/bootic_client/stubbing.rb', line 106 def returns if @return_data.is_a?(Array) @return_data.map{|d| BooticClient::Entity.new(d, nil)} else BooticClient::Entity.new(@return_data || {}, nil) end end |
#returns? ⇒ Boolean
102 103 104 |
# File 'lib/bootic_client/stubbing.rb', line 102 def returns? !!@return_data end |