edisonywh/behaves

Re-enable tests for `raise_error`

edisonywh opened this issue · 0 comments

Problem

Currently behaves uses at_exit to run checks for behaves_like. The problem with this is that this screws with rspecs's raise_error.

I've opened up an issue over at rspec/rspec-expectations#1117

I'm trying to look for an alternative if there's one, feel free to make a PR if you know of any.

Rationale

The reason for using at_exit is as follow:

The point of at_exit is so that you can put your behaves_like at the top of the file.

Because code is evaluated from top to bottom, there's no way for behaves_like to know what method the class has implemented, unless you put it all the way down at the bottom, after the declaration of all methods, which is ugly and unconventional.