diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 85977f4316..be3de79249 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -84,16 +84,6 @@ Style/EmptyMethod: Exclude: - 'lib/money/bank/base.rb' -# This cop supports safe autocorrection (--autocorrect). -Style/ExpandPathArguments: - Exclude: - - 'lib/money/currency/loader.rb' - -# This cop supports safe autocorrection (--autocorrect). -Style/FileWrite: - Exclude: - - 'lib/money/bank/variable_exchange.rb' - # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys diff --git a/lib/money/bank/variable_exchange.rb b/lib/money/bank/variable_exchange.rb index e42e46fc26..5453c0825e 100644 --- a/lib/money/bank/variable_exchange.rb +++ b/lib/money/bank/variable_exchange.rb @@ -226,7 +226,7 @@ def export_rates(format, file = nil, _opts = {}) s = FORMAT_SERIALIZERS[format].dump(rates) unless file.nil? - File.open(file, "w") { |f| f.write(s) } + File.write(file, s) end s diff --git a/lib/money/currency/loader.rb b/lib/money/currency/loader.rb index 633ce17dc3..34ef242d88 100644 --- a/lib/money/currency/loader.rb +++ b/lib/money/currency/loader.rb @@ -3,7 +3,7 @@ class Money class Currency module Loader - DATA_PATH = File.expand_path("../../../../config", __FILE__) + DATA_PATH = File.expand_path("../../../config", __dir__) class << self # Loads and returns the currencies stored in JSON files in the config directory. diff --git a/spec/bank/variable_exchange_spec.rb b/spec/bank/variable_exchange_spec.rb index ddb5995616..daa965c8aa 100644 --- a/spec/bank/variable_exchange_spec.rb +++ b/spec/bank/variable_exchange_spec.rb @@ -200,13 +200,11 @@ context "with :file provided" do it "writes rates to file" do - f = instance_double(IO) - allow(File).to receive(:open).with('null', 'w').and_yield(f) - allow(f).to receive(:write) + allow(File).to receive(:write) - bank.export_rates(:json, 'null') + bank.export_rates(:json, "null") - expect(f).to have_received(:write).with(JSON.dump(expected_rates)) + expect(File).to have_received(:write).with("null", JSON.dump(expected_rates)) end end