From 663561f1cc93bebd1cb6b44835faac32a74b8dc9 Mon Sep 17 00:00:00 2001 From: Troy Anderson Date: Tue, 2 Jul 2024 15:56:10 -0700 Subject: [PATCH 1/3] Rubocop autocorrections --- lib/open_weather/connection.rb | 2 +- lib/open_weather/endpoints/current.rb | 8 ++++---- lib/open_weather/endpoints/one_call.rb | 2 +- lib/open_weather/raise_error.rb | 2 +- spec/lib/open_weather/models/station_spec.rb | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/open_weather/connection.rb b/lib/open_weather/connection.rb index 74965bc..aba20a4 100644 --- a/lib/open_weather/connection.rb +++ b/lib/open_weather/connection.rb @@ -19,7 +19,7 @@ def connection options[:headers]['User-Agent'] = user_agent if user_agent options[:proxy] = proxy if proxy - options[:ssl] = { ca_path: ca_path, ca_file: ca_file } if ca_path || ca_file + options[:ssl] = { ca_path:, ca_file: } if ca_path || ca_file request_options = {} request_options[:timeout] = timeout if timeout diff --git a/lib/open_weather/endpoints/current.rb b/lib/open_weather/endpoints/current.rb index cebb705..d09f75d 100644 --- a/lib/open_weather/endpoints/current.rb +++ b/lib/open_weather/endpoints/current.rb @@ -4,22 +4,22 @@ module OpenWeather module Endpoints module Current def current_zip(code, country = nil, options = {}) - options = code.is_a?(Hash) ? options.merge(code) : options.merge(zip: code, country: country) + options = code.is_a?(Hash) ? options.merge(code) : options.merge(zip: code, country:) current_weather(options) end def current_geo(lat, lon = nil, options = {}) - options = lat.is_a?(Hash) ? options.merge(lat) : options.merge(lat: lat, lon: lon) + options = lat.is_a?(Hash) ? options.merge(lat) : options.merge(lat:, lon:) current_weather(options) end def current_city(name, state = nil, country = nil, options = {}) - options = name.is_a?(Hash) ? options.merge(name) : options.merge(city: name, state: state, country: country) + options = name.is_a?(Hash) ? options.merge(name) : options.merge(city: name, state:, country:) current_weather(options) end def current_city_id(id, options = {}) - options = id.is_a?(Hash) ? options.merge(id) : options.merge(id: id) + options = id.is_a?(Hash) ? options.merge(id) : options.merge(id:) current_weather(options) end diff --git a/lib/open_weather/endpoints/one_call.rb b/lib/open_weather/endpoints/one_call.rb index 38c793a..8310932 100644 --- a/lib/open_weather/endpoints/one_call.rb +++ b/lib/open_weather/endpoints/one_call.rb @@ -4,7 +4,7 @@ module OpenWeather module Endpoints module OneCall def one_call(lat, lon = nil, options = {}) - options = lat.is_a?(Hash) ? options.merge(lat) : options.merge(lat: lat, lon: lon) + options = lat.is_a?(Hash) ? options.merge(lat) : options.merge(lat:, lon:) options[:exclude] = options[:exclude].join(',') if options[:exclude].is_a?(Array) options[:dt] = options[:dt].to_i if options[:dt].is_a?(Time) path = options.key?(:dt) ? '3.0/onecall/timemachine' : '3.0/onecall' diff --git a/lib/open_weather/raise_error.rb b/lib/open_weather/raise_error.rb index 6677953..5dbcba0 100644 --- a/lib/open_weather/raise_error.rb +++ b/lib/open_weather/raise_error.rb @@ -10,7 +10,7 @@ def on_complete(env) when 407 # mimic the behavior that we get with proxy requests with HTTPS raise Faraday::ConnectionFailed, %(407 "Proxy Authentication Required ") - when (400...600).freeze + when (400...600) raise OpenWeather::Errors::Fault, response_values(env) end end diff --git a/spec/lib/open_weather/models/station_spec.rb b/spec/lib/open_weather/models/station_spec.rb index a4f78fc..d013f25 100644 --- a/spec/lib/open_weather/models/station_spec.rb +++ b/spec/lib/open_weather/models/station_spec.rb @@ -60,7 +60,7 @@ .with(id) .and_call_original - model = OpenWeather::Models::Station.new(id: id) + model = OpenWeather::Models::Station.new(id:) result = model.delete! expect(result).to be_nil end From 3c2d2687019d0e76e27f7b3f51b354dced376a3b Mon Sep 17 00:00:00 2001 From: Troy Anderson Date: Tue, 2 Jul 2024 16:28:35 -0700 Subject: [PATCH 2/3] Revert "Rubocop autocorrections" This reverts commit 6a044fc4a90fc7053ad7d788ad38e5ed9477a346. --- lib/open_weather/connection.rb | 2 +- lib/open_weather/endpoints/current.rb | 8 ++++---- lib/open_weather/endpoints/one_call.rb | 2 +- lib/open_weather/raise_error.rb | 2 +- spec/lib/open_weather/models/station_spec.rb | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/open_weather/connection.rb b/lib/open_weather/connection.rb index aba20a4..74965bc 100644 --- a/lib/open_weather/connection.rb +++ b/lib/open_weather/connection.rb @@ -19,7 +19,7 @@ def connection options[:headers]['User-Agent'] = user_agent if user_agent options[:proxy] = proxy if proxy - options[:ssl] = { ca_path:, ca_file: } if ca_path || ca_file + options[:ssl] = { ca_path: ca_path, ca_file: ca_file } if ca_path || ca_file request_options = {} request_options[:timeout] = timeout if timeout diff --git a/lib/open_weather/endpoints/current.rb b/lib/open_weather/endpoints/current.rb index d09f75d..cebb705 100644 --- a/lib/open_weather/endpoints/current.rb +++ b/lib/open_weather/endpoints/current.rb @@ -4,22 +4,22 @@ module OpenWeather module Endpoints module Current def current_zip(code, country = nil, options = {}) - options = code.is_a?(Hash) ? options.merge(code) : options.merge(zip: code, country:) + options = code.is_a?(Hash) ? options.merge(code) : options.merge(zip: code, country: country) current_weather(options) end def current_geo(lat, lon = nil, options = {}) - options = lat.is_a?(Hash) ? options.merge(lat) : options.merge(lat:, lon:) + options = lat.is_a?(Hash) ? options.merge(lat) : options.merge(lat: lat, lon: lon) current_weather(options) end def current_city(name, state = nil, country = nil, options = {}) - options = name.is_a?(Hash) ? options.merge(name) : options.merge(city: name, state:, country:) + options = name.is_a?(Hash) ? options.merge(name) : options.merge(city: name, state: state, country: country) current_weather(options) end def current_city_id(id, options = {}) - options = id.is_a?(Hash) ? options.merge(id) : options.merge(id:) + options = id.is_a?(Hash) ? options.merge(id) : options.merge(id: id) current_weather(options) end diff --git a/lib/open_weather/endpoints/one_call.rb b/lib/open_weather/endpoints/one_call.rb index 8310932..38c793a 100644 --- a/lib/open_weather/endpoints/one_call.rb +++ b/lib/open_weather/endpoints/one_call.rb @@ -4,7 +4,7 @@ module OpenWeather module Endpoints module OneCall def one_call(lat, lon = nil, options = {}) - options = lat.is_a?(Hash) ? options.merge(lat) : options.merge(lat:, lon:) + options = lat.is_a?(Hash) ? options.merge(lat) : options.merge(lat: lat, lon: lon) options[:exclude] = options[:exclude].join(',') if options[:exclude].is_a?(Array) options[:dt] = options[:dt].to_i if options[:dt].is_a?(Time) path = options.key?(:dt) ? '3.0/onecall/timemachine' : '3.0/onecall' diff --git a/lib/open_weather/raise_error.rb b/lib/open_weather/raise_error.rb index 5dbcba0..6677953 100644 --- a/lib/open_weather/raise_error.rb +++ b/lib/open_weather/raise_error.rb @@ -10,7 +10,7 @@ def on_complete(env) when 407 # mimic the behavior that we get with proxy requests with HTTPS raise Faraday::ConnectionFailed, %(407 "Proxy Authentication Required ") - when (400...600) + when (400...600).freeze raise OpenWeather::Errors::Fault, response_values(env) end end diff --git a/spec/lib/open_weather/models/station_spec.rb b/spec/lib/open_weather/models/station_spec.rb index d013f25..a4f78fc 100644 --- a/spec/lib/open_weather/models/station_spec.rb +++ b/spec/lib/open_weather/models/station_spec.rb @@ -60,7 +60,7 @@ .with(id) .and_call_original - model = OpenWeather::Models::Station.new(id:) + model = OpenWeather::Models::Station.new(id: id) result = model.delete! expect(result).to be_nil end From f66b03a660828203e510ec05ac0617d408641f23 Mon Sep 17 00:00:00 2001 From: Troy Anderson Date: Wed, 3 Jul 2024 17:17:59 -0700 Subject: [PATCH 3/3] Updated .rubocop.yml with suggested rules and applied changes to appease the cop. Removed .rubocop_todo.yml as it's no longer needed to pass rubocop. --- .rubocop.yml | 181 +++++++++++++++++- .rubocop_todo.yml | 44 ----- CHANGELOG.md | 1 + lib/open_weather/endpoints/stations.rb | 2 +- lib/open_weather/logger.rb | 2 +- lib/open_weather/models/forecast/forecast.rb | 2 +- lib/open_weather/models/mixins/temp.rb | 4 +- .../models/one_call/current_weather.rb | 4 +- .../models/one_call/daily_weather.rb | 4 +- .../models/one_call/hourly_weather.rb | 4 +- .../models/stations/measurement.rb | 2 +- spec/open_weather/client_spec.rb | 4 +- spec/open_weather/current/cities_box_spec.rb | 4 +- spec/open_weather/endpoints/stations_spec.rb | 43 +++-- .../open_weather/errors/access_denied_spec.rb | 4 +- 15 files changed, 222 insertions(+), 83 deletions(-) delete mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 4fc00db..9daa722 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,13 +1,184 @@ -Style/NumericLiterals: +AllCops: + SuggestExtensions: false + +Gemspec/RequiredRubyVersion: + Exclude: + - 'open-weather-ruby-client.gemspec' + +Naming/FileName: + Exclude: + - 'lib/open-weather-ruby-client.rb' + +Gemspec/DevelopmentDependencies: + Enabled: false +Gemspec/RequireMFA: Enabled: false +Gemspec/DeprecatedAttributeAssignment: + Enabled: true +Style/NumericLiterals: + Enabled: false Style/ModuleFunction: Enabled: false - Style/Documentation: Enabled: false - Metrics: Enabled: false - -inherit_from: .rubocop_todo.yml +Layout/LineContinuationLeadingSpace: + Enabled: true +Layout/LineContinuationSpacing: + Enabled: true +Layout/LineEndStringConcatenationIndentation: + Enabled: true +Layout/SpaceBeforeBrackets: + Enabled: true +Lint/AmbiguousAssignment: + Enabled: true +Lint/AmbiguousOperatorPrecedence: + Enabled: true +Lint/AmbiguousRange: + Enabled: true +Lint/ConstantOverwrittenInRescue: + Enabled: true +Lint/DeprecatedConstants: + Enabled: true +Lint/DuplicateBranch: + Enabled: true +Lint/DuplicateMagicComment: + Enabled: true +Lint/DuplicateRegexpCharacterClassElement: + Enabled: true +Lint/EmptyBlock: + Enabled: true +Lint/EmptyClass: + Enabled: true +Lint/EmptyInPattern: + Enabled: true +Lint/IncompatibleIoSelectWithFiberScheduler: + Enabled: true +Lint/LambdaWithoutLiteralBlock: + Enabled: true +Lint/NoReturnInBeginEndBlocks: + Enabled: true +Lint/NonAtomicFileOperation: + Enabled: true +Lint/NumberedParameterAssignment: + Enabled: true +Lint/OrAssignmentToConstant: + Enabled: true +Lint/RedundantDirGlobSort: + Enabled: true +Lint/RefinementImportMethods: + Enabled: true +Lint/RequireRangeParentheses: + Enabled: true +Lint/RequireRelativeSelfPath: + Enabled: true +Lint/SymbolConversion: + Enabled: true +Lint/ToEnumArguments: + Enabled: true +Lint/TripleQuotes: + Enabled: true +Lint/UnexpectedBlockArity: + Enabled: true +Lint/UnmodifiedReduceAccumulator: + Enabled: true +Lint/UselessRescue: + Enabled: true +Lint/UselessRuby2Keywords: + Enabled: true +Naming/BlockForwarding: + Enabled: true +Security/CompoundHash: + Enabled: true +Security/IoMethods: + Enabled: true +Style/ArgumentsForwarding: + Enabled: true +Style/ArrayIntersect: + Enabled: true +Style/CollectionCompact: + Enabled: true +Style/ComparableClamp: + Enabled: true +Style/ConcatArrayLiterals: + Enabled: true +Style/DirEmpty: + Enabled: true +Style/DocumentDynamicEvalDefinition: + Enabled: true +Style/EmptyHeredoc: + Enabled: true +Style/EndlessMethod: + Enabled: true +Style/EnvHome: + Enabled: true +Style/FetchEnvVar: + Enabled: true +Style/FileEmpty: + Enabled: true +Style/FileRead: + Enabled: true +Style/FileWrite: + Enabled: true +Style/HashConversion: + Enabled: true +Style/HashExcept: + Enabled: true +Style/IfWithBooleanLiteralBranches: + Enabled: true +Style/InPatternThen: + Enabled: true +Style/MagicCommentFormat: + Enabled: true +Style/MapCompactWithConditionalBlock: + Enabled: true +Style/MapToHash: + Enabled: true +Style/MapToSet: + Enabled: true +Style/MinMaxComparison: + Enabled: true +Style/MultilineInPatternThen: + Enabled: true +Style/NegatedIfElseCondition: + Enabled: true +Style/NestedFileDirname: + Enabled: true +Style/NilLambda: + Enabled: true +Style/NumberedParameters: + Enabled: true +Style/NumberedParametersLimit: + Enabled: true +Style/ObjectThen: + Enabled: true +Style/OpenStructUse: + Enabled: true +Style/OperatorMethodCall: + Enabled: true +Style/QuotedSymbols: + Enabled: true +Style/RedundantArgument: + Enabled: true +Style/RedundantConstantBase: + Enabled: true +Style/RedundantDoubleSplatHashBraces: + Enabled: true +Style/RedundantEach: + Enabled: true +Style/RedundantHeredocDelimiterQuotes: + Enabled: true +Style/RedundantInitialize: + Enabled: true +Style/RedundantSelfAssignmentBranch: + Enabled: true +Style/RedundantStringEscape: + Enabled: true +Style/SelectByRegexp: + Enabled: true +Style/StringChars: + Enabled: true +Style/SwapValues: + Enabled: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml deleted file mode 100644 index d65d3e8..0000000 --- a/.rubocop_todo.yml +++ /dev/null @@ -1,44 +0,0 @@ -# This configuration was generated by -# `rubocop --auto-gen-config` -# on 2023-03-20 09:58:58 UTC using RuboCop version 1.48.1. -# The point is for the user to remove these configuration records -# one by one as the offenses are removed from the code base. -# Note that changes in the inspected code, or installation of new -# versions of RuboCop, may require this file to be generated again. - -# Offense count: 1 -# Configuration parameters: Severity, Include. -# Include: **/*.gemspec -Gemspec/RequiredRubyVersion: - Exclude: - - 'open-weather-ruby-client.gemspec' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowedMethods. -# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal? -Lint/RedundantSafeNavigation: - Exclude: - - 'lib/open_weather/endpoints/stations.rb' - -# Offense count: 1 -# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms. -# CheckDefinitionPathHierarchyRoots: lib, spec, test, src -# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS -Naming/FileName: - Exclude: - - 'lib/open-weather-ruby-client.rb' - -# Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/GlobalStdStream: - Exclude: - - 'lib/open_weather/logger.rb' - - 'spec/open_weather/client_spec.rb' - -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. -# URISchemes: http, https -Layout/LineLength: - Max: 181 diff --git a/CHANGELOG.md b/CHANGELOG.md index e7d9a85..0841bdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### 0.5.1 (Next) +* [#40](https://github.com/dblock/open-weather-ruby-client/pull/40): Fixing rubocop violations and improved .rubocop.yml - [@troya2](https://github.com/troya2). * Your contribution here. ### 0.5.0 (2024/07/03) diff --git a/lib/open_weather/endpoints/stations.rb b/lib/open_weather/endpoints/stations.rb index b3ba880..366086f 100644 --- a/lib/open_weather/endpoints/stations.rb +++ b/lib/open_weather/endpoints/stations.rb @@ -46,7 +46,7 @@ def get_measurements(options) private def validate_id(id) - raise ArgumentError, 'Invalid ID' unless id&.is_a?(String) + raise ArgumentError, 'Invalid ID' unless id.is_a?(String) end end end diff --git a/lib/open_weather/logger.rb b/lib/open_weather/logger.rb index 6ec5a6f..8673f48 100644 --- a/lib/open_weather/logger.rb +++ b/lib/open_weather/logger.rb @@ -6,7 +6,7 @@ module OpenWeather class Logger < ::Logger def self.logger @logger ||= begin - logger = new STDOUT + logger = new $stdout logger.level = Logger::WARN logger end diff --git a/lib/open_weather/models/forecast/forecast.rb b/lib/open_weather/models/forecast/forecast.rb index 53745dc..bf4f7c1 100644 --- a/lib/open_weather/models/forecast/forecast.rb +++ b/lib/open_weather/models/forecast/forecast.rb @@ -13,7 +13,7 @@ class Forecast < Model property 'rain' property 'snow' property 'visibility' # Average visibility, metres. The maximum value of the visibility is 10km - property 'pop' # Probability of precipitation. The values of the parameter vary between 0 and 1, where 0 is equal to 0%, 1 is equal to 100% + property 'pop' # Probability of precipitation. Varies from 0 and 1, where 0 is equal to 0%, 1 is equal to 100% property 'sys' def initialize(args = nil, options = {}) diff --git a/lib/open_weather/models/mixins/temp.rb b/lib/open_weather/models/mixins/temp.rb index fb648b6..8369ec7 100644 --- a/lib/open_weather/models/mixins/temp.rb +++ b/lib/open_weather/models/mixins/temp.rb @@ -31,7 +31,7 @@ def to_kelvin(value) when :metric (value.to_f + 273.15).round(2) when :imperial - ((value.to_f - 32) * 5 / 9 + 273.15).round(2) + (((value.to_f - 32) * 5 / 9) + 273.15).round(2) else value end @@ -55,7 +55,7 @@ def to_farenheit(value) when :imperial value else - ((value.to_f - 273.15) * 9 / 5 + 32).round(2) + (((value.to_f - 273.15) * 9 / 5) + 32).round(2) end end end diff --git a/lib/open_weather/models/one_call/current_weather.rb b/lib/open_weather/models/one_call/current_weather.rb index d66cf25..bd8285b 100644 --- a/lib/open_weather/models/one_call/current_weather.rb +++ b/lib/open_weather/models/one_call/current_weather.rb @@ -11,7 +11,9 @@ class CurrentWeather < Model temperature_property 'feels_like' # temperature, accounts for the human perception of weather property 'pressure' # atmospheric pressure on the sea level, hPa property 'humidity' # humidity, % - temperature_property 'dew_point' # atmospheric temperature (varying according to pressure and humidity) below which water droplets begin to condense and dew can form + # atmospheric temperature (varying according to pressure and humidity) + # below which water droplets begin to condense and dew can form + temperature_property 'dew_point' property 'clouds' # cloudiness, % property 'uvi' # UV index property 'visibility' # average visibility, meters diff --git a/lib/open_weather/models/one_call/daily_weather.rb b/lib/open_weather/models/one_call/daily_weather.rb index a3b0652..1c4b1a3 100644 --- a/lib/open_weather/models/one_call/daily_weather.rb +++ b/lib/open_weather/models/one_call/daily_weather.rb @@ -11,7 +11,9 @@ class DailyWeather < Model property 'feels_like' property 'pressure' # atmospheric pressure on the sea level, hPa property 'humidity' # humidity, % - temperature_property 'dew_point' # atmospheric temperature (varying according to pressure and humidity) below which water droplets begin to condense and dew can form + # atmospheric temperature (varying according to pressure and humidity) + # below which water droplets begin to condense and dew can form + temperature_property 'dew_point' speed_property 'wind_speed' # wind speed speed_property 'wind_gust' # wind gust property 'wind_deg' # wind direction, degrees (meteorological) diff --git a/lib/open_weather/models/one_call/hourly_weather.rb b/lib/open_weather/models/one_call/hourly_weather.rb index e0ba4f2..b76534c 100644 --- a/lib/open_weather/models/one_call/hourly_weather.rb +++ b/lib/open_weather/models/one_call/hourly_weather.rb @@ -9,7 +9,9 @@ class HourlyWeather < Model temperature_property 'feels_like' property 'pressure' # atmospheric pressure on the sea level, hPa property 'humidity' # humidity, % - temperature_property 'dew_point' # atmospheric temperature (varying according to pressure and humidity) below which water droplets begin to condense and dew can form + # atmospheric temperature (varying according to pressure and humidity) + # below which water droplets begin to condense and dew can form + temperature_property 'dew_point' property 'clouds' # cloudiness, % property 'visibility' # average visibility, meters speed_property 'wind_speed' # wind speed. diff --git a/lib/open_weather/models/stations/measurement.rb b/lib/open_weather/models/stations/measurement.rb index 2761fe0..fa36ec1 100644 --- a/lib/open_weather/models/stations/measurement.rb +++ b/lib/open_weather/models/stations/measurement.rb @@ -5,7 +5,7 @@ module Models module Stations class Measurement < Model property 'station_id' # The internal ID of the station - property 'type' # Type of the aggregated data - minute, hour or day. Specifies the letters m, h or d respectively + property 'type' # Type of the aggregated data - minute, hour or day - the letters m, h or d respectively property 'date' # Time of measurement property 'temp' property 'humidity' diff --git a/spec/open_weather/client_spec.rb b/spec/open_weather/client_spec.rb index f83d73b..00d795f 100644 --- a/spec/open_weather/client_spec.rb +++ b/spec/open_weather/client_spec.rb @@ -99,7 +99,7 @@ end end context 'logger option' do - let(:logger) { Logger.new(STDOUT) } + let(:logger) { Logger.new($stdout) } before do OpenWeather::Client.configure do |config| config.logger = logger @@ -110,7 +110,7 @@ expect(client.logger).to eq logger end it 'creates a connection with a logger' do - expect(client.send(:connection).builder.handlers).to include ::Faraday::Response::Logger + expect(client.send(:connection).builder.handlers).to include Faraday::Response::Logger end end end diff --git a/spec/open_weather/current/cities_box_spec.rb b/spec/open_weather/current/cities_box_spec.rb index 8923a03..a043b43 100644 --- a/spec/open_weather/current/cities_box_spec.rb +++ b/spec/open_weather/current/cities_box_spec.rb @@ -28,7 +28,9 @@ expect(data.cnt).to eq 15 end it 'returns cities in a box weather with coordinates' do - data = client.current_cities_geo_box(lon_left: 12, lat_bottom: 32, lon_right: 15, lat_top: 37, zoom: 10, cluster: true) + data = client.current_cities_geo_box( + lon_left: 12, lat_bottom: 32, lon_right: 15, lat_top: 37, zoom: 10, cluster: true + ) expect(data).to be_a OpenWeather::Models::List expect(data.cnt).to eq 15 end diff --git a/spec/open_weather/endpoints/stations_spec.rb b/spec/open_weather/endpoints/stations_spec.rb index f25fb22..a3de01f 100644 --- a/spec/open_weather/endpoints/stations_spec.rb +++ b/spec/open_weather/endpoints/stations_spec.rb @@ -98,17 +98,17 @@ describe '#create_measurements' do it 'creates measurements', vcr: { cassette_name: 'stations/create_measurement_success' } do create_params = { - "station_id": '5ed21a12cca8ce0001f1aef1', - "dt": 1479817340, - "temperature": 18.7, - "wind_speed": 1.2, - "wind_gust": 3.4, - "pressure": 1021, - "humidity": 87, - "rain_1h": 2, - "clouds": [ + station_id: '5ed21a12cca8ce0001f1aef1', + dt: 1479817340, + temperature: 18.7, + wind_speed: 1.2, + wind_gust: 3.4, + pressure: 1021, + humidity: 87, + rain_1h: 2, + clouds: [ { - "condition": 'NSC' + condition: 'NSC' } ] } @@ -124,17 +124,17 @@ context 'when station does not exist' do it 'raises error', vcr: { cassette_name: 'stations/create_measurement_failed_with_invalid_station' } do create_params = { - "station_id": 'abcde', - "dt": 1479817340, - "temperature": 18.7, - "wind_speed": 1.2, - "wind_gust": 3.4, - "pressure": 1021, - "humidity": 87, - "rain_1h": 2, - "clouds": [ + station_id: 'abcde', + dt: 1479817340, + temperature: 18.7, + wind_speed: 1.2, + wind_gust: 3.4, + pressure: 1021, + humidity: 87, + rain_1h: 2, + clouds: [ { - "condition": 'NSC' + condition: 'NSC' } ] } @@ -187,7 +187,8 @@ context 'without required params' do it 'raises error' do - expect { client.get_measurements(something: 'something') }.to raise_error(ArgumentError, /station_id, type, limit, from, to/) + expect { client.get_measurements(something: 'something') } + .to raise_error(ArgumentError, /station_id, type, limit, from, to/) end end end diff --git a/spec/open_weather/errors/access_denied_spec.rb b/spec/open_weather/errors/access_denied_spec.rb index 7a6fe42..adac277 100644 --- a/spec/open_weather/errors/access_denied_spec.rb +++ b/spec/open_weather/errors/access_denied_spec.rb @@ -6,6 +6,8 @@ include_context 'API client' it 'raises error', vcr: { cassette_name: 'errors/access_denied' } do - expect { client.current_weather(city: 'London') }.to raise_error(OpenWeather::Errors::Fault, 'Invalid API key. Please see http://openweathermap.org/faq#error401 for more info.') + expect { client.current_weather(city: 'London') } + .to raise_error(OpenWeather::Errors::Fault, + 'Invalid API key. Please see http://openweathermap.org/faq#error401 for more info.') end end