lib/soaspec/exchange_handlers/rest_handler.rb in soaspec-0.0.42 vs lib/soaspec/exchange_handlers/rest_handler.rb in soaspec-0.0.43
- old
+ new
@@ -236,7 +236,25 @@
raise 'Unrecognised response message. Neither xml nor json detected'
end
end
+ # Convenience methods for once off usage of a REST request
+ class << self
+
+ methods = %w[post patch put get delete]
+
+ methods.each do |rest_method|
+ # Make REST Exchange within this Handler context
+ # @param [Hash] params Exchange parameters
+ # @return [Exchange] Instance of Exchange class. Assertions are made by default on the response body
+ define_method(rest_method) do |params|
+ params ||= {}
+ params[:name] ||= rest_method
+ new(params[:name])
+ Exchange.new(params[:name], method: rest_method.to_sym, **params)
+ end
+ end
+ end
+
end
end
\ No newline at end of file