-
-
Notifications
You must be signed in to change notification settings - Fork 762
Feature request: shortcut for pending-block within it #1208
Comments
I think I like this idea. I've wanted the same thing at various points. Currently For now I think you can get this on your own pretty simply: module RunPending
def pending(*args, &block)
it(*args) { pending(&block) }
end
end
RSpec.configure do |c|
c.extend RunPending
end If we're going to make this change, 3.0 is the time to do it as it's a breaking change. We'll need to issue a deprecation warning in 2.99. |
Let's do it, @grddev do you fancy taking a stab at this? |
I could probably take a stab at it, but from my point of view it seems a bit surprising to have a
I think it would be beneficial to distinguish the two concepts through naming throughout (although I'm uncertain that About the deprecation warning, it is unclear to me how that could be done in a forward-compatible manner (without also introducing a new name for the "new" pending concept). That is, the warning would have to be produced as soon as pending is used (as an existing test suite might rely on the pending tests not being executed), but there is no way of acknowledging that you actually want the 3.0 behaviour. Instead you have to resort to the old style Thus, my previous suggestion was to introduce |
Hmm...this split doesn't describe how I use or think of uses of
I'm reaallly not a fan of describe MyClass do
pending "does something" do
do_something
end
end ...looks so similar to: describe MyClass do
it "does something" do
pending "waiting on an upstream fix" do
do_something
end
end
end I think the only way to introduce this "properly" would be a config option but I don't think I want to add that complexity. Instead, I think it's legit to simply change the semantics of
It's not perfect, but I'd be OK with that option. I don't want us to wind up with a non-ideal API simply because of upgrade concerns. |
why not give it a different name? In cucumber land this is "wip"... |
Hmm, I use pending also for "this test is pending a fix or removal". I would use this for instance for an integration test which suddenly fails randomly on the ci environment. I really dislike the suggested warning. That way there is no easy way to ensure you're actually compatible. If I have to wade through dozens of false warnings to find what I do need to fix, I might as well just upgrade and see what fails. |
@markijbema we only need to show the warning once on first usage - we already have code that does this. |
@markijbema and also you can just replace them all with |
succeed. This is a backwards incompatible change that makes the behaviour of a top-level `pending` call the sames as one used within an `it` block. The old "never run this example" behaviour is still available via the `xit` method or the `:skip` metadata option. Implements #1208.
succeed. This is a backwards incompatible change that makes the behaviour of a top-level `pending` call the sames as one used within an `it` block. The old "never run this example" behaviour is still available via the `xit` method or the `:skip` metadata option. Implements #1208.
succeed. This is a backwards incompatible change that makes the behaviour of a top-level `pending` call the sames as one used within an `it` block. The old "never run this example" behaviour is still available via the `xit` method or the `:skip` metadata option. Implements #1208.
succeed. This is a backwards incompatible change that makes the behaviour of a top-level `pending` call the sames as one used within an `it` block. The old "never run this example" behaviour is still available via the `xit` method or the `:skip` metadata option. Implements #1208.
For 2.99, I still think it would be important to have a forward-compatible (warning-free) solution. That is, there should be something I could write in 2.99 that would have the 3.0 pending behaviour, but without rendering any deprecation-warnings. The obvious way to do this would be to introduce a new alias for the concept, but this is really suboptimal if pending is the preferred name. Perhaps the best solution would be to provide a (temporary) configuration-flag for 2.99 to turn on the new behaviour (whereas 3.0 makes it the default)? |
If you warn on pending blocks (always) you would have forward-compatible behaviour. All 2.* pending blocks should be xit blocks, and switching from pending inline to pending blocks is optional. When upgraded to 3, you can convert inline pendings to block pendings. |
Excellent. That in combination with the |
succeed. This is a backwards incompatible change that makes the behaviour of a top-level `pending` call the sames as one used within an `it` block. The old "never run this example" behaviour is still available via the `xit` method or the `:skip` metadata option. Implements #1208.
This is a backwards incompatible change that makes the behaviour of pending consisent with the current behaviour for when it is called inside an example with a block. The old "never run this example" behaviour is still available via the "x" family of methods, the `:skip` metadata option, or the new `skip` method. Implements #1208.
This is a backwards incompatible change that makes the behaviour of pending consisent with the current behaviour for when it is called inside an example with a block. The old "never run this example" behaviour is still available via the "x" family of methods, the `:skip` metadata option, or the new `skip` method. Implements #1208.
This is a backwards incompatible change that makes the behaviour of pending consisent with the current behaviour for when it is called inside an example with a block. The old "never run this example" behaviour is still available via the "x" family of methods, the `:skip` metadata option, or the new `skip` method. Implements #1208.
* Execute pending examples and mark as failed if they succeed. * Removed pending with a block. * Introduce `skip` method and metadata for old pending behaviour. This is a backwards-incompatible change. Implements #1208.
I think this issue has been resolved by @xaviershay 's pull request, right? At least 2.99.beta2 gave me warnings about this exact feature. |
It has indeed. Thanks for the reminder to close this! |
Using
pending
inside anit
block is a useful feature for ensuring that tests fail before touching the code, but there seems to be no shortcut for that kind of pending. That is, I would like to have an alternative toor
that works exactly like:
The difference being that in the latter case, the code is executed and a failure is reported unless the inner test actually fails. Perhaps the name
pending!
could be used in both of the above cases to signify the case where the tests should still be executed.The main motivation would to allow a work flow where a forced "red before green" workflow can be enforced by separating the commits, while not having to fiddle with indentation in the subsequent commit test cases.
The text was updated successfully, but these errors were encountered: