Skip to content

Conditionally skipping coverage (use case: multiple ruby versions support) #634

Open
@HoneyryderChuck

Description

@HoneyryderChuck

I've running into this situation in a lib where I want to support new ruby syntax, but I want to had a backwards-compatibility layer. This leads me to define methods in such a way:

...
if RUBY_VERSION < "2.3"
  def foo(n)
    bar.bang(n, oldoption)
  end
else
  def foo(n)
     bar.bang(n, oldoption)
  end
end

Depending of which ruby I run, I'll have one of those chunks marked as red. I could just :nocov: the whole block, but I also want to ensure those bits. Can I write a :nocov if RUBY_VERSION < "2.3" rule for my use-case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions