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)>'
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_thatblocks.Here's a little example:
In the above, calling
#inspecton the block passed toarg_thatwill raise the following: