Sha256: ad30c148e6f58be4e4a751e1b4e932bf83fc44ab0dbe13917ec8f9b4a817f761

Contents?: true

Size: 1.89 KB

Versions: 3

Compression:

Stored size: 1.89 KB

Contents

require './spec/spec_helper'

describe Photo do
  before(:each) do
    @photo = Photo.new({
      "ResourceUri" => "/listings/20100815153524571646000000/photos/20101124153422574618000000",
      "Id"          => "20101124153422574618000000",
      "Name"        => "Photo 1 name",
      "Caption"     => "caption here",
      "UriThumb"    => "http://photos.cdn.flexmls.com/xyz-t.jpg",
      "Uri300"      => "http://photos.cdn.flexmls.com/xyz.jpg",
      "Uri640"      => "http://cdn.resize.flexmls.com/az/640x480/true/20101124153422574618000000-o.jpg",
      "Uri800"      => "http://cdn.resize.flexmls.com/az/800x600/true/20101124153422574618000000-o.jpg",
      "Uri1024"     => "http://cdn.resize.flexmls.com/az/1024x768/true/20101124153422574618000000-o.jpg",
      "Uri1280"     => "http://cdn.resize.flexmls.com/az/1280x1024/true/20101124153422574618000000-o.jpg",
      "UriLarge"    => "http://photos.cdn.flexmls.com/xyz-o.jpg",
      "Primary"     => true
    })

  end


  it "responds to" do
    @photo.should respond_to(:primary?)
    Photo.should respond_to(:find_by_listing_key)
  end

  it "knows if it's the primary photo" do
    @photo.primary?.should be_true
    @photo.Primary = false
    @photo.primary?.should be_false
  end

  describe "find photos by listing id"  do
    before do
      stub_auth_request
      stub_request(:get, "#{FlexmlsApi.endpoint}/#{FlexmlsApi.version}/listings/1234/photos").
                   with(:query => {
                     :ApiSig => "d060aa12d3ef573aff7298302e0237fa", 
                     :AuthToken => "c401736bf3d3f754f07c04e460e09573",
                     :ApiUser => "foobar"
                   }).
                   to_return(:body => fixture('listing_photos_index.json'))
    end

    it "should get an array of photos" do
      p = Photo.find_by_listing_key('1234', 'foobar')
      p.should be_an Array
    end

  end


  after(:each) do  
    @photo = nil
  end


end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flexmls_api-0.3.6 spec/unit/flexmls_api/models/photo_spec.rb
flexmls_api-0.3.3 spec/unit/flexmls_api/models/photo_spec.rb
flexmls_api-0.3.2 spec/unit/flexmls_api/models/photo_spec.rb