Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SourceNotFoundError on blocks defined in larger expressions #22

Open
searls opened this issue Jul 20, 2013 · 0 comments
Open

SourceNotFoundError on blocks defined in larger expressions #22

searls opened this issue Jul 20, 2013 · 0 comments

Comments

@searls
Copy link

searls commented Jul 20, 2013

I had low expectations of method_source helping me, so I might be way out of bounds here.

I'm writing a little gem called arg-that which provides a method that takes a block. To give better test messages, I was hoping to use method_source (or similar) to print the content of the arg_that blocks.

Here's a little example:

    expect(
      :a => 1,
      :b => 99
    ).to eqish(
      :a => 1,
      :b => arg_that {|arg| arg > 98 && arg < 100 }
    )

In the above, calling #inspect on the block passed to arg_that will raise the following:

Failure/Error: Unable to find matching line from backtrace
     MethodSource::SourceNotFoundError:
       Could not parse source for #<Proc:0x007ffc8bc73898@/Volumes/Macintosh HD/Users/justin/code/vagrants/oss/projects/ruby/arg_that/spec/arg_that_spec.rb:42>: (eval):2: syntax error, unexpected tASSOC, expecting $end
                 :b => arg_that {|arg| arg > 98 && arg < 100 }
                      ^
     # ./lib/arg_that/that_arg.rb:13:in `inspect'
     # ./lib/arg_that/eqish.rb:19:in `block (2 levels) in <top (required)>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant