Sha256: 03ee1b19485e1d7f3119599ab1c7e33e15bb2c2484cd1c557ba674c260a03896

Contents?: true

Size: 1.29 KB

Versions: 8

Compression:

Stored size: 1.29 KB

Contents

require_relative '../../spec_helper'

module Barometer::Query
  describe Converter::FromWeatherIdToGeocode, vcr: {
    match_requests_on: [:method, :uri],
    cassette_name: 'Converter::FromWeatherIdToGeocode'
  } do
    describe '.call' do
      it 'converts :weather_id -> :geocode' do
        query = Barometer::Query.new('USGA0028')

        converter = Converter::FromWeatherIdToGeocode.new(query)
        converted_query = converter.call

        expect( converted_query.q ).to eq 'Atlanta, GA, US'
        expect( converted_query.format ).to eq :geocode
        expect( converted_query.geo ).not_to be_nil
      end

      it 'uses a previous :weather_id coversion (if needed) on the query' do
        query = Barometer::Query.new('30301')
        query.add_conversion(:weather_id, 'USGA0028')

        converter = Converter::FromWeatherIdToGeocode.new(query)
        converted_query = converter.call

        expect( converted_query.q ).to eq 'Atlanta, GA, US'
        expect( converted_query.format ).to eq :geocode
        expect( converted_query.geo ).not_to be_nil
      end

      it 'does not convert any other format' do
        query = Barometer::Query.new('90210')

        converter = Converter::FromWeatherIdToGeocode.new(query)
        expect( converter.call ).to be_nil
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
barometer-0.9.7 spec/query/converters/from_weather_id_to_geocode_spec.rb
barometer-0.9.6 spec/query/converters/from_weather_id_to_geocode_spec.rb
barometer-0.9.5 spec/query/converters/from_weather_id_to_geocode_spec.rb
barometer-0.9.4 spec/query/converters/from_weather_id_to_geocode_spec.rb
barometer-0.9.3 spec/query/converters/from_weather_id_to_geocode_spec.rb
barometer-0.9.2 spec/query/converters/from_weather_id_to_geocode_spec.rb
barometer-0.9.1 spec/query/converters/from_weather_id_to_geocode_spec.rb
barometer-0.9.0 spec/query/converters/from_weather_id_to_geocode_spec.rb