grasp icon indicating copy to clipboard operation
grasp copied to clipboard

Bad equery replacement case

Open ksheedlo opened this issue 9 years ago • 0 comments

I have a minimal case that's causing a bad replacement. I have a series of test suites using Jasmine and I'd like to make sure that we are always using .toBe for strings and never .toEqual. The replacement is not giving me good results.

Here's my minimal case.

expect(foo('wow')).toEqual('bar');

Here's what I expect the replacement to produce:

expect(foo('wow')).toBe('bar');

Here's the actual output:

┌─[ken][Kens-MacBook-Pro][±][use-to-be-with-strings ✗][2.1.2][~/racker/sage]
└─▪ grasp -r -e '$e.toEqual(_str$s)' -R '{{e}}.toBe({{_str$s}})' replace-bug.js
expect(foo('wow')).toBe('wow');

As you can see, Grasp grabs the string nested down in the $e expression and assigns it to _str$s during the replacement. This is giving me incorrect results.

ksheedlo avatar Apr 28 '15 21:04 ksheedlo