lib/soaspec/exchange_handlers/rest_handler.rb in soaspec-0.0.31 vs lib/soaspec/exchange_handlers/rest_handler.rb in soaspec-0.0.32

- old
+ new

@@ -52,35 +52,30 @@ options.merge!(specific_options) @resource = RestClient::Resource.new(base_url_value, options) # @resource[url_extension].get super end - def name(name) - @test_name = name - self - end - # Used in together with Exchange request that passes such override parameters # @param [Hash] override_parameters Params to characterize REST request + # @param_value [params] Extra parameters (E.g. headers) + # @param_value [suburl] URL appended to base_url of clss + # @param_value [method] REST method (get, post, etc) def make_request(override_parameters) test_values = override_parameters test_values[:params] ||= {} test_values[:suburl] = test_values[:suburl].to_s if test_values[:suburl] + @resource_used = test_values[:suburl] ? @resource[test_values[:suburl]] : @resource + begin response = case test_values[:method] when :post - if test_values[:suburl] - @resource[test_values[:suburl]].send(test_values[:method].to_s, test_values[:payload], test_values[:params]) - else - @resource.send(test_values[:method].to_s, test_values[:payload], test_values[:params]) + unless test_values[:payload] + test_values[:payload] = JSON.generate(test_values[:body]).to_s if test_values[:body] end + @resource_used.send(test_values[:method].to_s, test_values[:payload], test_values[:params]) else - if test_values[:suburl] - @resource[test_values[:suburl]].send(test_values[:method].to_s, test_values[:params]) - else - @resource.send(test_values[:method].to_s, test_values[:params]) - end + @resource_used.send(test_values[:method].to_s, test_values[:params]) end rescue RestClient::ExceptionWithResponse => e response = e.response end Soaspec::SpecLogger.add_to(response) \ No newline at end of file