-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1037 from mame/coverage-for-eval
Support coverage for eval
- Loading branch information
Showing
7 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require "helper" | ||
|
||
RSpec.describe "coverage for eval" do | ||
if SimpleCov.coverage_for_eval_supported? | ||
around do |test| | ||
Dir.chdir(File.join(File.dirname(__FILE__), "fixtures", "eval_test")) do | ||
FileUtils.rm_rf("./coverage") | ||
test.call | ||
end | ||
end | ||
|
||
before do | ||
@stdout, @stderr, @status = Open3.capture3(command) | ||
end | ||
|
||
context "foo" do | ||
let(:command) { "ruby eval_test.rb" } | ||
|
||
it "records coverage for erb" do | ||
expect(@stdout).to include(" 2 / 3 LOC") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<% if 1 + 1 == 2 %> | ||
covered | ||
<% else %> | ||
not covered | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require "simplecov" | ||
SimpleCov.enable_coverage_for_eval | ||
SimpleCov.start "rails" | ||
|
||
file = File.join(__dir__, "eval_test.erb") | ||
erb = ERB.new(File.read(file)) | ||
erb.filename = file | ||
erb.run |