John, that's exactly what I am looking for, the `skip "Reason"` part, thank
you. Just one more question, is there a way I can have it marked in the
output as something other than pending? Perhaps something like "Skipped"?
The "Reason" is shown, but sort of buried below all the pending statements.

On Thu, Sep 5, 2019 at 3:46 AM Jon Rowe <[email protected]> wrote:

> Hi
>
> You can skip specs using metadata, which might be appropriate if you can
> access `some_condition?` outside of your hook.
>
> e.g.
>
> RSpec.describe “Something”, skip: some_condition? do
>   it “will not run” do
>     fail
>   end
> end
>
> Or you can use the skip method.
>
> RSpec.configure do |config|
>   config.before(:each) do
>      if some_condition?
>         skip "Reason"
>      end
>   end
> end
>
> The method on the passed in example you are attempting to use, is actually
> just a reader for the metadata value, and doesn’t skip.
>
> See:
>
> https://relishapp.com/rspec/rspec-core/v/3-8/docs/pending-and-skipped-examples/skip-examples
>
> Cheers
> Jon Rowe
> ---------------------------
> [email protected]
> jonrowe.co.uk
>
> On 5 September 2019 at 02:18, Wael wrote:
>
> Hi,
>
> I am working on an idea and I was curious if there is a way I can skip a
> spec in a before block? I am thinking something like this:
>
> RSpec.configure do |config|
>   config.before(:each) do |spec|
>      if some_condition?
>         spec.skip
>      end
>   end
> end
>
> Ideally, I want to skip the spec and mark it as so visually, perhaps using
> something other like "*", but for now, I just want to have it working. The
> above actually does not achieve it, the tests still run.
>
> Any ideas?
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "rspec" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/rspec/NDAgImEWdrE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rspec/dejalu-217-84541c10-9259-45e6-bc21-140b6642fe57%40jonrowe.co.uk
> <https://groups.google.com/d/msgid/rspec/dejalu-217-84541c10-9259-45e6-bc21-140b6642fe57%40jonrowe.co.uk?utm_medium=email&utm_source=footer>
> .
>


-- 
Wael Khobalatte

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/CAEtiScmGaMEnSOr%2BW%3D6gZEVeK6k9%3D4sH6zepGEBHqKsx3WrwpA%40mail.gmail.com.

Reply via email to