markbates / markbates/cover_me

Can't recognize lines in block

Open
#53 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
203
Forks
17
PR merge metrics
No merged PRs in 30d

Description

Especially for sinatra applications. Here's a minimal example demonstrating the problem:

app.rb

require "sinatra"

class App < Sinatra::Base
  get '/' do
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    i = 1
    'hi'
  end
end

test.rb

require "test/unit"
require "rack/test"
require "cover_me"
require_relative "app"

CoverMe.config do |c|
  c.project.root = File.expand_path File.dirname(__FILE__)
  c.file_pattern = /app\.rb/
end
at_exit &(CoverMe.method :complete!)

class TestApp < Test::Unit::TestCase
  include Rack::Test::Methods

  def app
    App
  end

  def test_1
    get '/'
    assert_equal 'hi', last_response.body
  end
end

The result shows only 3 lines are covered, all lines in the block are not covered.

Environment:

  • ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.1]
  • sinatra (1.2.6)
  • rack-test (0.6.0)
  • cover_me (1.0.0)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the app.rb and test.rb examples, using the listed Sinatra, rack-test, and CoverMe versions. Start by tracing how CoverMe processes the Sinatra route block and compare its reported coverage with the repeated assignments. Done means the lines inside the block are recognized and reported with the expected coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.