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 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/dejalu-217-84541c10-9259-45e6-bc21-140b6642fe57%40jonrowe.co.uk.
