Detect nesting it and pending at run-time#7297
Conversation
asterite
left a comment
There was a problem hiding this comment.
Looks good! I just left a question.
| end | ||
|
|
||
| # `NestingSpecError` is also treated. | ||
| if ex.is_a?(Spec::NestingSpecError) && klass != Spec::NestingSpecError |
There was a problem hiding this comment.
See full code:
def expect_raises(klass : T.class, message = nil, file = __FILE__, line = __LINE__) forall T
yield
rescue ex : T
# We usually bubble Spec::AssertaionFailed, unless this is the expected exception
if ex.is_a?(Spec::AssertionFailed) && klass != Spec::AssertionFailed
raise ex
end
# `NestingSpecError` is treated as the same above.
if ex.is_a?(Spec::NestingSpecError) && klass != Spec::NestingSpecError
raise ex
end
# ...
endPlease tell me more correct sentence which means this if you know.
|
Just asking: Is this really worth the added complexity? |
|
@straight-shoota At least we have an issue #7192 and this is the simplest way to fix it. |
Currently nesting `it`/`pending` doesn't break `crystal spec -v` output.
|
Now, nesting Example: require "spec"
it "foo" do
it "bar" do
end
end
it "baz" do
pending
endOld (broken) output: New (fixed) output: |
| false | ||
| end | ||
|
|
||
| @@spec_nesting = false |
There was a problem hiding this comment.
If we were to ever get to parallel test execution, would this class variable cause a problem?
There was a problem hiding this comment.
Oh, actually, I was replying generically that class variables are to be used carefully in a parallel context. Not sure about this case, though


Fix #7192
Close #7207