You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
A reply is given for the [RSpec
issue](rspec/rspec-expectations#1117), I've
reviewed the proposed solution and found that I'd take a different
approach instead in order to fix the `at_exit` spec.
First off, this commit extracts out the core logic for `behaves_like`
into a `private` method. This is important for a couple of reason.
By extracting it out, `behaves_like` now only consists of the `at_exit`
logic, and because I can't test `at_exit` due to the nature of it, I've
decided to test directly on the newly extracted `private` method.
While it is generally frowned upon to test private methods (you should
be testing the public interfaces only!!), and I do agree on that on a
general case, I think that this is an exceptional situation that calls
for a break of rules.
Guidelines should be all that is, guides, it should not be rules that
prevent innovation. Thus I've decided to break the rule this time.
Fixes#2
Problem
Currently
behaves
usesat_exit
to run checks forbehaves_like
. The problem with this is that this screws withrspecs
'sraise_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 yourbehaves_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.The text was updated successfully, but these errors were encountered: