thoughtbot / shoulda-context

Shoulda Context makes it easy to write understandable and maintainable tests under Minitest and Test::Unit within Rails projects or plain Ruby projects.
MIT License
239 stars 58 forks source link

Handle deprecation of assert_block safely #24

Closed rsl closed 11 years ago

rsl commented 11 years ago

MiniTest 4.6.0 and higher no longer has assert_block as a method [opting for assert(yield, message)] https://github.com/seattlerb/minitest/blob/master/History.txt#L134-L140

This enables users with older MiniTest to still use assert_block if it's there and the newer format if it's not.

Not sure how to write a test for this as it is a dependency-based issue.

rsl commented 11 years ago

super fast. thanks.

rmm5t commented 11 years ago

Thanks! I merged this in to give you credit for bringing it to our attention, but what's stopping us from just avoiding the assert_block method altogether? Is there a reason we can't just use assert and avoid the safe_assert_block?

rsl commented 11 years ago

hrm. i actually didn't think to do that at all. i think in the back of my head assert was modified to take assert_block's place. makes sense that assert out of the box would do that. feel stupid for not having thought of it. ;)

rsl commented 11 years ago

i assumed no one used plain assert because it used to not work. so i wanted to make sure those users were supported but yeah... yeah. ;)

rmm5t commented 11 years ago

I tried a quick transition to just using assert but the test suite fails because it expects a different format of failed test output for that assertion. If it's something you're interested in investigating, much appreciated. Otherwise, I'll come back to it at some later date, probably.

rsl commented 11 years ago

poking it now.

rsl commented 11 years ago

there's a lot of places that can/do define assert there. stdlib's test/unit. rubygem test-unit. minitest. all of which have some differences in versions. looks like it might be bugger trying to unify that in a single call to assert.