Sha256: a6c8e871579217934d70c011af91562329e9d45bf7fb5907bf72bbc45bc192ee

Contents?: true

Size: 1.65 KB

Versions: 45

Compression:

Stored size: 1.65 KB

Contents

require './spec/spec_helper'


describe SharedListing do
  before(:each) do
    stub_auth_request
  end

  it "should respond to the finders" do
    SharedListing.should respond_to(:find)
  end

  context "/sharedlistings", :support do
    on_post_it "should create shared listings" do
      stub_api_post("/#{subject.class.element_name}", 'listings/shared_listing_new.json', 'listings/shared_listing_post.json')
      subject.ListingIds = ["20110224152431857619000000","20110125122333785431000000"]
      subject.ViewId = "20080125122333787615000000"
      subject.save.should be(true)
      subject.Id.should eq("15Ar")
      subject.Mode.should eq("Public")
      subject.ResourceUri.should eq("/v1/sharedlistings/15Ar")
      subject.SharedUri.should eq("http://www.flexmls.com/share/15Ar/3544-N-Olsen-Avenue-Tucson-AZ-85719")
    end

    on_post_it "should fail creating" do
      stub_api_post("/#{subject.class.element_name}", nil) do |request|
        request.to_return(:status => 400, :body => fixture('errors/failure.json'))
      end
      subject
      subject.save.should be(false)
      expect{ subject.save! }.to raise_error(SparkApi::ClientError){ |e| e.status.should == 400 }
    end
  end

  context "/sharedlistings/<shared_listing_id>", :support do
    on_get_it "should get shared listing" do
      shared_id = '15Ar'
      stub_api_get("/#{subject.class.element_name}/#{shared_id}",
                   'listings/shared_listing_get.json')

      shared = SharedListing.find(shared_id)
      shared.should respond_to('SharedUri')
      shared.should respond_to('Mode')
      shared.Mode.should eq('Public')
      shared.ListingIds.should be_an(Array)
    end
  end

end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
spark_api-1.4.34 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.32 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.31 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.29 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.28 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.27 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.26 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.25 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.24 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.23 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.22 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.21 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.20 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.19 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.18 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.17 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.16 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.15 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.14 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.4.13 spec/unit/spark_api/models/shared_listing_spec.rb