Class: AndSon::TestClient
- Inherits:
-
Object
- Object
- AndSon::TestClient
- Includes:
- Client
- Defined in:
- lib/and-son/client.rb
Defined Under Namespace
Classes: Call
Instance Attribute Summary collapse
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
-
#logger_value ⇒ Object
Returns the value of attribute logger_value.
-
#params_value ⇒ Object
Returns the value of attribute params_value.
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
-
#timeout_value ⇒ Object
Returns the value of attribute timeout_value.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #add_response(*args, &block) ⇒ Object
- #call(name, params = nil) ⇒ Object
- #call_runner ⇒ Object
- #hash ⇒ Object
-
#initialize(host, port) ⇒ TestClient
constructor
A new instance of TestClient.
- #remove_response(*args) ⇒ Object
- #reset ⇒ Object
Methods included from Client
Constructor Details
#initialize(host, port) ⇒ TestClient
Returns a new instance of TestClient.
62 63 64 65 66 67 |
# File 'lib/and-son/client.rb', line 62 def initialize(host, port) super @params_value = {} @calls = [] @responses = AndSon::StoredResponses.new end |
Instance Attribute Details
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
60 61 62 |
# File 'lib/and-son/client.rb', line 60 def calls @calls end |
#logger_value ⇒ Object
Returns the value of attribute logger_value.
59 60 61 |
# File 'lib/and-son/client.rb', line 59 def logger_value @logger_value end |
#params_value ⇒ Object
Returns the value of attribute params_value.
59 60 61 |
# File 'lib/and-son/client.rb', line 59 def params_value @params_value end |
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
60 61 62 |
# File 'lib/and-son/client.rb', line 60 def responses @responses end |
#timeout_value ⇒ Object
Returns the value of attribute timeout_value.
59 60 61 |
# File 'lib/and-son/client.rb', line 59 def timeout_value @timeout_value end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
104 105 106 |
# File 'lib/and-son/client.rb', line 104 def ==(other) other.kind_of?(self.class) ? self.hash == other.hash : super end |
#add_response(*args, &block) ⇒ Object
82 83 84 |
# File 'lib/and-son/client.rb', line 82 def add_response(*args, &block) self.responses.add(*args, &block) end |
#call(name, params = nil) ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/and-son/client.rb', line 69 def call(name, params = nil) params ||= {} response = self.responses.get(name, params) self.calls << Call.new(name, params, response.protocol_response) if block_given? yield response.protocol_response else response.data end end |
#call_runner ⇒ Object
80 |
# File 'lib/and-son/client.rb', line 80 def call_runner; self; end |
#hash ⇒ Object
95 96 97 98 99 100 101 102 |
# File 'lib/and-son/client.rb', line 95 def hash [ self.host, self.port, self.timeout_value, self.params_value, self.logger_value ].hash end |
#remove_response(*args) ⇒ Object
86 87 88 |
# File 'lib/and-son/client.rb', line 86 def remove_response(*args) self.responses.remove(*args) end |
#reset ⇒ Object
90 91 92 93 |
# File 'lib/and-son/client.rb', line 90 def reset self.calls.clear self.responses.remove_all end |