yujinakayama/transpec

Incorrect conversion of "should have(n).foos"

jensb opened this issue · 2 comments

I am converting a spec which contains lots of tests like

@foo.should have(2).bars

These get converted to

expect(@foo.size).to eq(2)

which is incorrect. There is a warning during conversion about missing runtime information, but (to me) it is quite clear that the conversion should be

expect(@foo.bars.size).to eq(2)

Right? Or am I missing something?

Thanks!

If the @foo responds to #bars, it should be converted to expect(@foo.bars.size).to eq(2). However if it does not respond to #bars, it should be converted to expect(@foo.size).to eq(2) (in this case the bars is just a syntactic sugar for readability).

So,

but (to me) it is quite clear that the conversion should be ...

Unfortunatly it's not clear without runtime information.

I have now converted everything manually but is it possible to just ''assume'' (during conversion) that e.g. "bars" in @foo.bars is defined so that the information is kept? Or provide a blacklist (remove "items" and "things", but keep everything else)? Thanks!