lib/soaspec/exchange.rb in soaspec-0.0.78 vs lib/soaspec/exchange.rb in soaspec-0.0.79
- old
+ new
@@ -28,11 +28,10 @@
# This represents a request / response pair
# Essentially, params in the exchange that are set are related to the request
# What is returned is related to the response
class Exchange
-
extend ExchangeAccessors
# Instance of ExchangeHandler for which this exchange is made
attr_accessor :exchange_handler
# How many times to retry for a success
@@ -40,10 +39,15 @@
# Name used for displaying class
attr_accessor :test_name
# Expect Factory to fail upon trying to create
attr_writer :fail_factory
+
+ def values_from_path(path, attribute: nil)
+ exchange_handler.values_from_path(response, path, attribute: attribute)
+ end
+
# Set retry for success variable to true so that request will be retried
# for retry_count until it's true
def retry_for_success
@retry_for_success = true
self
@@ -192,16 +196,19 @@
# Implement undefined setter with []= for FactoryBot to use without needing to define params to set
# @param [Object] method_name Name of method not defined
# @param [Object] args Arguments passed to method
# @param [Object] block
def method_missing(method_name, *args, &block)
+ set_value = args.first
if method_name[-1] == '=' # A setter method
- if args.first.class < Exchange # This would be prerequisite exchange
- define_singleton_method(method_name[0..-2]) do
- args.first
+ getter_name = method_name[0..-2]
+ if set_value.class < Exchange # This would be prerequisite exchange
+ define_singleton_method(getter_name) do
+ set_value
end
+ self[getter_name] = set_value.id if set_value.respond_to?(:id)
else
- self[method_name[0..-2]] = args.first
+ self[getter_name] = set_value
end
else
super
end
end
\ No newline at end of file