Transpec 3.1.0 missed converting some tests
mcbsys opened this issue · 2 comments
I used Transpec 3.1.0 a few months back to convert to RSpec 2.99 and subsequently 3.1.0. The overall experience was very good but recently I have noticed that Transpec seems to have missed a few tests and unfortunately, RSpec silently passes these tests, so I only discover the issues by chance.
I'm reporting the RSpec false positive issue separately (rspec/rspec-dev#129). As for Transpec, it looks like the issue has to do with tests in the form of it { value1 == value2 }
or specify { value1 == value2 }
. In a few cases, Transpec did not insert the "expect" verb and change ==
to eq
. At first I thought this was only when the statement was split across multiple lines, but today I searched my tests for ==
and found the following tests still present:
it { @user.notifications_pending == 0 }
specify { new_user.notification_interval_secs == 3600 }
Currently RSpec passes those tests regardless of what value is suppliedThe . If I manually re-write them:
it { expect(@user.notifications_pending).to eq(0) }
specify { expect(new_user.notification_interval_secs).to eq(3600) }
they only pass when correct values are supplied.
I left a lengthy response on rspec/rspec-dev#129. The TL;DR is that I don't think there's a transpec bug here because you weren't using an expectation before, so there's no reason for transpec to insert one during the upgrade process. it { @user.notifications_pending == 0 }
behaves exactly the same on 2.x and 3.x: it asserts nothing explicitly but will fail if the ==
method raises an error.
@myronmarston is right: some of my old tests were missing the should
, so Transpec was not the issue! Closing this.