wrong icon indicating copy to clipboard operation
wrong copied to clipboard

NameError on otherwise un-referenced block arg in failing example

Open dchelimsky opened this issue 12 years ago • 1 comments

Given the following failing example in failing_example.rb

require 'wrong/adapters/rspec'

describe "a block arg in a failing assertion" do
  it "raises a NameError :(" do
    assert { [].each {|v|} != [] }
  end
end

When I run rspec failing_example.rb

Then I get this error:

F

Failures:

  1) a block arg in a failing assertion raises a NameError :(
     Failure/Error: assert { [].each {|v|} != [] }
       Expected [].each { |v| }.!=([]), but
           (v) raises NameError: undefined local variable or method `v' for #<RSpec::Core::ExampleGroup::Nested_1:0x007f938a0d1ef0>
     # ./failing_example.rb:5:in `block (2 levels) in <top (required)>'

The example should fail, that's not the problem. The problem is the failure message should indicate that the values were not equal, not a NameError on v

dchelimsky avatar Aug 12 '13 09:08 dchelimsky

That's funny. My guess is that the parser doesn't distinguish between "v" in a block parameter list and "v" as a standalone statement. Should be fixable; thanks for pointing it out.

alexch avatar Aug 12 '13 13:08 alexch