Skip to content

Commit d7f590b

Browse files
committed
Lint: Fix Style/FileWrite
1 parent d102367 commit d7f590b

File tree

4 files changed

+5
-17
lines changed

4 files changed

+5
-17
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/money/bank/variable_exchange.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def export_rates(format, file = nil, _opts = {})
226226
s = FORMAT_SERIALIZERS[format].dump(rates)
227227

228228
unless file.nil?
229-
File.open(file, "w") { |f| f.write(s) }
229+
File.write(file, s)
230230
end
231231

232232
s

lib/money/currency/loader.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class Money
44
class Currency
55
module Loader
6-
DATA_PATH = File.expand_path("../../../../config", __FILE__)
6+
DATA_PATH = File.expand_path("../../../config", __dir__)
77

88
class << self
99
# Loads and returns the currencies stored in JSON files in the config directory.

spec/bank/variable_exchange_spec.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,11 @@
200200

201201
context "with :file provided" do
202202
it "writes rates to file" do
203-
f = double('IO')
204-
allow(File).to receive(:open).with('null', 'w').and_yield(f)
205-
allow(f).to receive(:write)
203+
allow(File).to receive(:write)
206204

207-
bank.export_rates(:json, 'null')
205+
bank.export_rates(:json, "null")
208206

209-
expect(f).to have_received(:write).with(JSON.dump(expected_rates))
207+
expect(File).to have_received(:write).with("null", JSON.dump(expected_rates))
210208
end
211209
end
212210

0 commit comments

Comments
 (0)