Sha256: 6bbfe3df31fe51480307ada1bdecec8cd62f6714353b0e2eb3ed46432cc89275

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe ShopifyAPI::Mock::Fixtures do
  
  context "when given a valid fixture name" do
    it "should return the contents of a fixture" do
      @json = read_fixture :test
      ShopifyAPI::Mock::Fixtures.read(:test).should eq @json
    end
  end
  
  context "when given an invalid fixture name" do
    it "should raise an error" do
      expect { ShopifyAPI::Mock::Fixtures.read(:brown_chicken_brown_cow) }.should raise_error
    end
  end
  
  context "custom fixtures" do
    before { @json = '{ "count": 10 }' }
    describe "#use" do
      context "with custom fixture for content" do
        it "should override default fixture" do
          ShopifyAPI::Mock::Fixtures.read(:orders).should eq read_fixture :orders
          ShopifyAPI::Mock::Fixtures.use :count, @json
          ShopifyAPI::Mock::Fixtures.read(:count).should eq @json
        end
      end
      context "with :default for content" do
        it "should reset back to default texture" do
          ShopifyAPI::Mock::Fixtures.use :count, @json
          ShopifyAPI::Mock::Fixtures.read(:count).should eq @json
          ShopifyAPI::Mock::Fixtures.use :count, :default
          ShopifyAPI::Mock::Fixtures.read(:orders).should eq read_fixture :orders
        end
      end
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shopify-mock-0.0.1 spec/mockify/fixtures_spec.rb