Sha256: 5b9601d2bb88817e72bb1edb7f046007261d47459d726fd3487292393991dd47

Contents?: true

Size: 1.7 KB

Versions: 12

Compression:

Stored size: 1.7 KB

Contents

require './spec/spec_helper'


describe SharedListing do
  before(:each) do
    stub_auth_request
  end

  it "should respond to the finders" do
    expect(SharedListing).to 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"
      expect(subject.save).to be(true)
      expect(subject.Id).to eq("15Ar")
      expect(subject.Mode).to eq("Public")
      expect(subject.ResourceUri).to eq("/v1/sharedlistings/15Ar")
      expect(subject.SharedUri).to 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
      expect(subject.save).to be(false)
      expect{ subject.save! }.to raise_error(SparkApi::ClientError){ |e| expect(e.status).to eq(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)
      expect(shared).to respond_to('SharedUri')
      expect(shared).to respond_to('Mode')
      expect(shared.Mode).to eq('Public')
      expect(shared.ListingIds).to be_an(Array)
    end
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
spark_api-1.6.3 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.6.2 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.6.1 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.5.7 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.6.0 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.5.6 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.5.5 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.5.4 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.5.3 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.5.2 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.5.1 spec/unit/spark_api/models/shared_listing_spec.rb
spark_api-1.5.0 spec/unit/spark_api/models/shared_listing_spec.rb