Sha256: ee7d7e823f136729edd003397ae4bfea40c047237d38b4511945671dc411beb0

Contents?: true

Size: 1.36 KB

Versions: 7

Compression:

Stored size: 1.36 KB

Contents

require "spec_helper"

describe Savon::Spec::Fixture do

  describe ".path" do
    it "should return a specified path" do
      Savon::Spec::Fixture.path = "/Users/rubiii/my_app/spec/fixtures"
      Savon::Spec::Fixture.path.should == "/Users/rubiii/my_app/spec/fixtures"
      
      Savon::Spec::Fixture.path = nil  # reset to default
    end

    it "should raise an ArgumentError if accessed before specified" do
      lambda { Savon::Spec::Fixture.path }.should raise_error(ArgumentError)
    end

    it "should default to spec/fixtures if used in a Rails app" do
      Rails = Class.new
      Rails.expects(:root).returns(Pathname.new("/Users/rubiii/another_app"))
      
      Savon::Spec::Fixture.path.should == "/Users/rubiii/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 "should return 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 "should memoize 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

7 entries across 7 versions & 1 rubygems

Version Path
savon_spec-0.1.6 spec/savon/spec/fixture_spec.rb
savon_spec-0.1.5 spec/savon/spec/fixture_spec.rb
savon_spec-0.1.4 spec/savon/spec/fixture_spec.rb
savon_spec-0.1.3 spec/savon/spec/fixture_spec.rb
savon_spec-0.1.2 spec/savon/spec/fixture_spec.rb
savon_spec-0.1.1 spec/savon/spec/fixture_spec.rb
savon_spec-0.1.0 spec/savon/spec/fixture_spec.rb