Sha256: 8415f76d4267c305192f4d1a95496c1f6070e05b24f42292d92610df020e75ca

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'
require 'shopify_theme'
require 'shopify_theme/api_checker'

module ShopifyTheme
  describe "APIChecker" do
    attr_reader :checker

    before do
      config = {
        api_key: 'abracadabra',
        password: 'alakazam',
        store: 'something.myshopify.com'
      }
      ShopifyTheme.config = config
      @checker = APIChecker.new(ShopifyTheme)
    end

    after do
      ShopifyTheme.config = nil
    end

    it "should return an APIResponse that says if the API is accessible when it gets a 200 response" do
      VCR.use_cassette("api_check_success") do
        response = checker.test_connectivity
        assert response.accessed_api?
      end
    end

    it "should return an APIResponse that says the API is down if it gets a 500-series response" do
      VCR.use_cassette("api_check_api_down") do
        response = checker.test_connectivity
        assert response.api_down?
      end
    end

    it "should return an APIResponse that says the client is misconfigured if it gets a 401 response" do
      VCR.use_cassette("api_check_unauthorized") do
        response = checker.test_connectivity
        assert response.invalid_config?
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shopify_theme-0.0.25 spec/unit/api_checker_spec.rb
shopify_theme-0.0.24 spec/unit/api_checker_spec.rb
shopify_theme-0.0.23 spec/unit/api_checker_spec.rb