Closed moonglum closed 10 years ago
Great! The new RegExp @madziaf proposed on HipChat works now. I found one additional problem that needs to be solved, then it all works fine!!!! And actually finds a bug in the README of anima :dancers:
This here:
{ hey: 'ho' } # => { hey: 'ho' }
Will be translated into that:
assert_equal { hey: 'ho' }, { hey: 'ho' }
This looks right at first, but it is actually a bug.
Ataru will report the following:
1) Error:
#<Class:0x007f8c82988698>#test_bla_0:
SyntaxError: bla.md:4: syntax error, unexpected ':', expecting '}'
assert_equal { hey: 'ho' }, { hey: 'ho' }
^
bla.md:4: syntax error, unexpected ',', expecting end-of-input
assert_equal { hey: 'ho' }, { hey: 'ho' }
^
/Users/moonglum/Code/ataru/lib/ataru/code_sample.rb:23:in `eval'
/Users/moonglum/Code/ataru/lib/ataru/code_sample.rb:23:in `run'
/Users/moonglum/Code/ataru/lib/ataru/test_class_builder.rb:24:in `block (3 levels) in build_test_class'
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
Only read this if you are stuck and want the solution :wink:
The replacement string has to be assert_equal(\2, \1)
. The parenthesis are needed here, because otherwise the hash will be interpreted as a block and Ruby gets sad. This is an ugly thing in Ruby, but with the parentheses everything is alright.
Thanks for digging into possible bugs @moonglum ! Seems like ataru is getting into shape it's validation powers:) You know, I know that 'assert_equal' is a method and still I got used to writing it without parenthesis to the point I needed to read your solution. Thanks again:)
solved with #64
Confirmed – works now :+1: Great work! And don't forget to report the bug in the README of anima to the author :smile:
@madziaf You're welcome :smile: It's weird how some methods in Ruby don't really seem to be methods and it is weird to write them with parentheses (but also makes it quite beautiful :smile:). Can totally understand that!
Ok, found some tiny bugs when running Ataru against Anima. I think all of them can be solved by tweaking the RegEx :+1: I extracted the smallest possible examples:
Bug 1
will be converted to:
Bug 2
will be converted to: