Skip to content

Commit

Permalink
Add erb example of eval coverage issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Sep 6, 2023
1 parent 3b9b8da commit 96943b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/erb/template.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% if value %>
Hello <%= value %>
<% else %>
Hello <%= default %>
<% end %>
19 changes: 19 additions & 0 deletions examples/erb/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env ruby

require 'coverage'
require 'erb'

Coverage.start(lines: true, eval: true)

def test(value = nil, default: "World", path: 'template.erb')
template = ERB.new(File.read(path))
template.location = path

template.result(binding)
end

# The order changes coverage, previous results are discarded.
test("World")
test

puts Coverage.result

0 comments on commit 96943b6

Please sign in to comment.