Sha256: cb2e505f41fcc670571c5724eb4c91f38530e9a91e4e7cfe135715f94184b922

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

require "spec_helper"

describe Savon::Spec::Fixture do

  describe ".path" do

    it "returns a specified path" do
      Savon::Spec::Fixture.path = "/Users/dr_who/some_app/spec/fixtures"
      Savon::Spec::Fixture.path.should == "/Users/dr_who/some_app/spec/fixtures"

      Savon::Spec::Fixture.path = nil  # reset to default
    end

    it "raises an ArgumentError when accessed before specified" do
      expect { Savon::Spec::Fixture.path }.to raise_error(ArgumentError)
    end

    it "defaults to spec/fixtures when used in a Rails app" do
      Rails = Class.new do
        def self.root
          Pathname.new("/Users/dr_who/another_app")
        end
      end

      Savon::Spec::Fixture.path.should == "/Users/dr_who/another_app/spec/fixtures"

      Object.send(:remove_const, "Rails")
    end

  end

  describe ".load" do

    around do |example|
      Savon::Spec::Fixture.path = "spec/fixtures"
      example.run
      Savon::Spec::Fixture.path = nil  # reset to default
    end

    it "returns a fixture for the given arguments" do
      fixture = Savon::Spec::Fixture.load :get_user, :success
      fixture.should == File.read("spec/fixtures/get_user/success.xml")
    end

    it "memoizes the fixtures" do
      Savon::Spec::Fixture.load(:get_user, :success).
        should equal(Savon::Spec::Fixture.load(:get_user, :success))
    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
savon_spec-1.3.0 spec/savon/spec/fixture_spec.rb
savon_spec-1.2.0 spec/savon/spec/fixture_spec.rb
savon_spec-1.1.0 spec/savon/spec/fixture_spec.rb