Class: Capyspy::Spy
- Inherits:
-
Object
- Object
- Capyspy::Spy
- Defined in:
- lib/capyspy/spy.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
- #and_call_fake(function) ⇒ Object
- #and_call_through ⇒ Object
- #and_return(value) ⇒ Object
- #calls ⇒ Object
-
#initialize(page, method) ⇒ Spy
constructor
A new instance of Spy.
- #to_s ⇒ Object
Constructor Details
#initialize(page, method) ⇒ Spy
Returns a new instance of Spy.
5 6 7 8 9 10 |
# File 'lib/capyspy/spy.rb', line 5 def initialize(page, method) @page = page @method = method.to_s init end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
3 4 5 |
# File 'lib/capyspy/spy.rb', line 3 def method @method end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
3 4 5 |
# File 'lib/capyspy/spy.rb', line 3 def page @page end |
Instance Method Details
#and_call_fake(function) ⇒ Object
22 23 24 25 |
# File 'lib/capyspy/spy.rb', line 22 def and_call_fake(function) with_spy 'callThrough = false', "fake = #{function}" self end |
#and_call_through ⇒ Object
12 13 14 15 |
# File 'lib/capyspy/spy.rb', line 12 def and_call_through with_spy 'callThrough = true' self end |
#and_return(value) ⇒ Object
17 18 19 20 |
# File 'lib/capyspy/spy.rb', line 17 def and_return(value) with_spy 'callThrough = false', "fake = function() { return #{value.to_json}; }" self end |
#calls ⇒ Object
27 28 29 |
# File 'lib/capyspy/spy.rb', line 27 def calls with_spy 'calls' end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/capyspy/spy.rb', line 31 def to_s method end |