banister / method_source

return the sourcecode for a method
MIT License
361 stars 43 forks source link

Blocks defined amid larger expressions will return the entire line #23

Open searls opened 11 years ago

searls commented 11 years ago

Given a line like this:

Then { expect(:foo).to eqish arg_that {|arg| arg.kind_of?(String) } }

Asking the block passed to arg_that its source will return a string of the entire line, not only what was passed to the block.

I imagine this is just a limitation of what #source_location tells you (e.g. no column information). Is there any other way to get at this? Would an AST approach perhaps work?