Sha256: 944ff0795316b78319bf9c9a8397afefb2298c3ae4c10a92aa31b7c6d0d0a5ad
Contents?: true
Size: 1.61 KB
Versions: 2
Compression:
Stored size: 1.61 KB
Contents
module ShopifyAPI module Mock # used to manage the mocked responses class Response # creates and registers a new mocked response # @param [Symbol] method The method of the reponse. Can be one of [:put, :get, :post, :delete] # @param [String] resource The path to the resource. # @param [String] response The response to provide when that URL is called # @return [FakeWeb] The FakeWeb object for the mocked response # @example Registering a response to the path "/orders.count.xml" with the response "hello world" # ShopifyAPI::Mock::Response.register :get, "orders/count.xml", "hello world" # @api public def initialize(method, resource, response) @@responses += FakeWeb.register_uri( method, /#{SHOPIFY_MOCK_SHOP_BASE_URL}#{resource}/, :body => response ) end class << self # store for all registered responses @@responses = [] # finds all the registered responses # @return [Array, FakeWeb] all the FakeWeb registered responses # @example List all the registered responses # puts ShopifyAPI::Mock::Response.all # @api public def all @@responses end # clears all the currently registered responses # @return [Array] the registered responses after clearing (should be empty) # @example Clearing all registered responses # ShopifyAPI::Mock::Response.clear # @api public def clear FakeWeb.clean_registry @@responses = [] end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shopify-mock-0.1.1 | lib/shopify-mock/response.rb |
shopify-mock-0.1.0 | lib/shopify-mock/response.rb |