Sha256: cc8526350f7d589beb96b9a7035104834421e4817b89712f7ae9e0db09b7cbb6

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

require 'spec_helper'

describe ShopifyAPI::Mock::Fixture do
  
  describe "#new" do
    context "with invalid file name" do
      it "should raise IOError" do
        expect {ShopifyAPI::Mock::Fixture.new("invalid-file") }.should raise_error, IOError
      end
    end
    
    context "with valid file name" do
      before do
        @file_name = File.expand_path("../../lib/shopify-mock/fixtures/orders.json", __FILE__)
        @fixture = ShopifyAPI::Mock::Fixture.new(@file_name)
      end
      specify { @fixture.should be_a ShopifyAPI::Mock::Fixture }
    end
  end
  
  describe "#all" do
    before { @all = ShopifyAPI::Mock::Fixture.all }
    specify { @all.should be_kind_of Array }
    specify { @all.length.should > 0 }
  end
  
  describe "#find" do
    context "with a valid fixture name" do
      before { @result = ShopifyAPI::Mock::Fixture.find :orders, :json }
      specify { @result.should be_kind_of ShopifyAPI::Mock::Fixture }
    end
    context "with an invalid fixture name" do
      before { @result = ShopifyAPI::Mock::Fixture.find :brown_chicken_brown_cow, :xml }
      specify { @result.should be_nil }
    end
  end
  
  describe "#data" do
    before { @fixture = ShopifyAPI::Mock::Fixture.find :orders, :json }
    specify { @fixture.data.should_not be_empty }
  end
  
  describe "#data=" do
    before(:all) do
      @fixture = ShopifyAPI::Mock::Fixture.find :orders, :json
      @original_data = @fixture.data
    end
    it "should override the original content" do
      @fixture.data.should eq @original_data
      @fixture.data = 'new'
      @fixture.data.should eq 'new'
    end
    it "should reset to original content when set to nil" do
      @fixture.data = nil
      @fixture.data.should eq @original_data
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shopify-mock-0.1.0 spec/fixtures_spec.rb