Skip to content

Commit b72d0bb

Browse files
committed
Use File.write instead of File.open block to write index.html
Closes #69.
1 parent 9762881 commit b72d0bb

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

.rubocop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Metrics/ClassLength:
2727
CountAsOne:
2828
- array
2929
- hash
30+
Exclude:
31+
- "test/**/*"
3032

3133
Metrics/ModuleLength:
3234
CountAsOne:

lib/simplecov-html.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ def format(result)
3838
end
3939
end
4040

41-
File.open(File.join(output_path, "index.html"), "wb") do |file|
42-
file.puts template("layout").result(binding)
43-
end
41+
File.write(File.join(output_path, "index.html"), template("layout").result(binding), mode: "wb")
4442
puts output_message(result) unless @silent
4543
end
4644

test/test_simple_cov-html.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ def bad_template.result(_binding)
9191

9292
def test_silenced_output
9393
result = SimpleCov::Result.new({fixtures_path.join("sample.rb").to_s => CoverageFixtures::SAMPLE_RB})
94-
formatter = SimpleCov::Formatter::HTMLFormatter.new(silent: true)
95-
stdout, = capture_io { formatter.format(result) }
94+
stdout, = capture_io { SimpleCov::Formatter::HTMLFormatter.new(silent: true).format(result) }
9695

9796
assert_empty stdout
9897
end

0 commit comments

Comments
 (0)