Sha256: 2696b2483f849e292f0444fc419f8e1f0a42c4513febdf72dd84c5cf6722d2f3

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "Query::Geocode" do
  
  before(:each) do
    @zipcode = "90210"
  end
  
  describe "and the class methods" do
    
    describe "fetch," do
      
      it "requires a Query object" do
        lambda { Barometer::WebService::Geocode.fetch }.should raise_error(ArgumentError)
        lambda { Barometer::WebService::Geocode.fetch("invalid") }.should raise_error(ArgumentError)
        query = Barometer::Query.new(@zipcode)
        query.is_a?(Barometer::Query).should be_true
        lambda { Barometer::WebService::Geocode.fetch(query) }.should_not raise_error(ArgumentError)
      end
      
      it "detects the key" do
        query = Barometer::Query.new(@zipcode)
        Barometer.google_geocode_key = nil
        Barometer::WebService::Geocode.fetch(query).should be_nil
        Barometer.google_geocode_key = KEY
        Barometer::WebService::Geocode.fetch(query).should_not be_nil
      end
      
      it "returns a Geo object" do
        query = Barometer::Query.new(@zipcode)
        Barometer::WebService::Geocode.fetch(query).is_a?(Data::Geo).should be_true
      end
      
    end
    
    it "detects the Google Geocode Key" do
      Barometer.google_geocode_key = nil
      Barometer::WebService::Geocode.send("_has_geocode_key?").should be_false
      Barometer.google_geocode_key = KEY
      Barometer::WebService::Geocode.send("_has_geocode_key?").should be_true
    end
    
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
barometer-0.7.1 spec/web_services/geocode_spec.rb
barometer-0.7.0 spec/web_services/geocode_spec.rb
barometer-0.6.7 spec/web_services/geocode_spec.rb
barometer-0.6.6 spec/web_services/geocode_spec.rb