Sha256: 4dbe6884597ac2b61aad13c54b19ae365d184e6985afa95e7693b64fc1b3c0f4

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'fakeweb'

require 'shopify-mock/version'
require 'shopify-mock/urls'
require 'shopify-mock/fixtures'
require 'shopify-mock/response'

module ShopifyAPI
  module Mock
    class << self
      def enabled
        @enabled || false
      end
      
      def enabled=(value=false)
        return @enabled if value == @enabled
        if value
          #load File.expand_path("../shopify-mock/responses.rb", __FILE__)
          ShopifyAPI::Mock::Response.register_all
        else
          FakeWeb.clean_registry
        end
        @enabled = value
      end
      
      def reset
        ShopifyAPI::Mock.enabled = false
        ShopifyAPI::Mock.enabled = true
      end
      
      def allow_internet
        @allow_internet || true
      end
      
      def allow_internet=(state = true)
        return @allow_internet if @allow_internet == state
        @allow_internet = state
        FakeWeb.allow_net_connect = @allow_internet
      end
    end
  end
end

ShopifyAPI::Mock.enabled = defined?(Rails) && Rails.env.test?

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shopify-mock-0.0.3 lib/shopify-mock.rb