Sha256: a9aa71684c21751416a73f720759a922c093cd86dfe57e460632393f356d0a50

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

require_relative '../../spec_helper'

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

  it "converts :coordinates -> :noaa_station_id" do
    query = Barometer::Query.new('34.10,-118.41')

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

    converted_query.q.should == 'KSMO'
    converted_query.format.should == :noaa_station_id
  end

  it "uses a previous coversion (if needed) on the query" do
    query = Barometer::Query.new('90210')
    query.add_conversion(:coordinates, '34.10,-118.41')

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

    converted_query.q.should == 'KSMO'
    converted_query.format.should == :noaa_station_id
  end

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

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