Sha256: c1d911e7266fd9b9d41e139f104f81df7004bfa64fd6967334a73162a21b4361

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

require_relative '../../spec_helper'

describe Barometer::Query::Converter::ToWeatherId, vcr: {
  match_requests_on: [:method, :uri],
  cassette_name: "Converter::ToWeatherId"
} do

  it "converts :unknown -> :weather_id" do
    query = Barometer::Query.new('Paris, France')

    converter = Barometer::Query::Converter::ToWeatherId.new(query)
    converted_query = converter.call

    converted_query.q.should == 'FRXX0076'
    converted_query.format.should == :weather_id
  end

  it "uses a previous coversion (if needed) on the query" do
    query = Barometer::Query.new('KJFK')
    query.add_conversion(:geocode, 'New York, NY')

    converter = Barometer::Query::Converter::ToWeatherId.new(query)
    converted_query = converter.call

    converted_query.q.should == 'USNY0996'
    converted_query.format.should == :weather_id
  end

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

    converter = Barometer::Query::Converter::ToWeatherId.new(query)
    converter.call.should be_nil
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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