Skip to content

Commit f7ce7af

Browse files
committed
Write as error handler because File.file? is mocked sometimes
1 parent 567ecba commit f7ce7af

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

spec/octocatalog-diff/tests/spec_helper.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ def initialize
4747
end
4848

4949
def string
50+
# Written as an exception handler, rather than File.file?, because in some tests File.file? is mocked.
5051
@content ||= begin
51-
if File.file?(@tf.path)
52-
content = File.read(@tf.path)
53-
content.sub(/\A# Logfile created .+\n/, '')
54-
end
52+
content = File.read(@tf.path)
53+
content.sub(/\A# Logfile created .+\n/, '')
54+
rescue Errno::ENOENT
55+
''
5556
end
5657
end
5758
end

0 commit comments

Comments
 (0)