Sha256: df7f063d45c389f1b0fe656c5abdfc9fbf009a00f9b27d38bf9582f2bbfe0e19

Contents?: true

Size: 1.61 KB

Versions: 3

Compression:

Stored size: 1.61 KB

Contents

require './spec/spec_helper'

describe StandardFields do
  
  before(:each) do 
    stub_auth_request
  end

  it "should respond to get" do
    StandardFields.should respond_to(:get)
  end

  it "should find and expand all" do
    StandardFields.should respond_to(:find_and_expand_all)
    
    # stub request to standardFields
    stub_api_get('/standardfields','standardfields/standardfields.json')
    
    # stub request for City
    stub_api_get('/standardfields/City','standardfields/city.json')
    
    # stub request for StateOrProvince
    stub_api_get('/standardfields/StateOrProvince','standardfields/stateorprovince.json')
    
    # request
    fields = StandardFields.find_and_expand_all(["City","StateOrProvince"])

    # keys are present
    fields.should have_key("City")
    fields.should have_key("StateOrProvince")
    fields.should_not have_key("SubdivisionName")

    # FieldList
    fields["City"]["FieldList"].length.should eq(235)
    fields["StateOrProvince"]["FieldList"].length.should eq(5)
    
  end
  
  it "should find nearby fields" do
    StandardFields.should respond_to(:find_nearby)
    
    # stub request
    stub_api_get('/standardfields/nearby/A','standardfields/nearby.json',
      :Lat => "50",
      :Lon => "-92",
      :_expand => "1")
    
    # request
    fields = StandardFields.find_nearby(["A"], {:Lat => 50, :Lon => -92})
    
    # validate response
    fields["D"]["Success"].should eq(true)
    fields["D"]["Results"].first.should have_key("City")
    fields["D"]["Results"].first.should have_key("PostalCode")
    fields["D"]["Results"].first.should have_key("StateOrProvince")

  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flexmls_api-0.7.3 spec/unit/flexmls_api/models/standard_fields_spec.rb
flexmls_api-0.7.5 spec/unit/flexmls_api/models/standard_fields_spec.rb
flexmls_api-0.7.0 spec/unit/flexmls_api/models/standard_fields_spec.rb