searls / jasmine-given

Like rspec-given, but for jasmine
testdouble.com
MIT License
178 stars 26 forks source link

Bug: strings are missing quotations in detected comparisons #37

Open Wizek opened 10 years ago

Wizek commented 10 years ago

Situation

Strings are missing quotations in detected comparisons.

This is especially frustrating if they contain digits and/or spaces.

Example

Then clause #7 `visibleText($('<a><a style="display:none">x</a> y</a>')) === ' y'` failed by returning false

This comparison was detected:
  visibleText($('<a><a style="display:none">x</a> y</a>')) === ' y'
  y ===  y

Proposed simple solution:

Just put a "'" + left + "'" somewhere in here: https://github.com/searls/jasmine-given/blob/master/app/js/jasmine-given.coffee#L179

Proposed nice solution:

Do it a little more human+machine friendly way like this: https://github.com/Wizek/Tree/blob/master/src/tree.js#L163-L179

(Example of this in action: https://github.com/Wizek/Tree/blob/master/test/test.js#L123-L128)

This way the result is always valid (copy-pastable) JavaScript.