Filtering rspec based on various platforms

12 views
Skip to first unread message

SJ

unread,
Jul 31, 2015, 2:40:12 PM7/31/15
to rspec
I am trying to figure out how does the metadata tags works if I have same metadata is included in both inclusion and exclusion criterion.


Rspec.configure do |config|

  config.filter_run_excluding { platform_1: true, platform_2: true }
  config.filter_run_including  { platform_1: true }
end


it 'should do something', platform_1: true do
  # spec to be implemented
end

Thanks,
- SJ



Aaron Kromer

unread,
Aug 1, 2015, 1:08:31 AM8/1/15
to rs...@googlegroups.com

If any part of the metadata matches an exclusion it will not be run:

RSpec.configure do |config|
  config.filter_run_excluding :meta_a, meta_b: true, meta_c: :value
  config.filter_run_including meta_a: true
end

RSpec.describe "working with metadata" do

  it "excludes fully matching metadata (:meta, meta_b: true, meta_c: :value)",
     :meta_a, meta_b: true, meta_c: :value do
    raise "This should not run!"
  end

  it "excludes partially matching metadata (:meta)", meta_a: true do
    raise "This should not run!"
  end

  it "excludes partially matching metadata (meta_b: true)", :meta_b do
    raise "This should not run!"
  end

  it "excludes partially matching metadata (meta_c: :value)", meta_c: :value do
    raise "This should not run!"
  end

  it "excludes partially matching metadata (:other, :meta_a)",
     :other, :meta_a do
    expect(:run).to be :run
  end

  it "runs fully non-matching metadata values (meta_a: false)", meta_a: false do
    expect(:run).to be :run
  end

  it "runs fully non-matching metadata values (meta_c: :other)", meta_c: :other do
    expect(:run).to be :run
  end

  it "runs other metadata", other: true do
    expect(:run).to be :run
  end

end

# =>
# Run options:
#   include {:focus=>true}
#   exclude {:meta_b=>true, :meta_c=>:value, :meta_a=>true, :ruby=>#<Proc:./spec/spec_helper.rb:106>}
#
# All examples were filtered out; ignoring {:focus=>true}
#
# Randomized with seed 56839
#
# working with metadata
#   runs other metadata
#   runs fully non-matching metadata values (meta_c: :other)
#   runs fully non-matching metadata values (meta_a: false)
#
# Finished in 0.0037 seconds (files took 0.26485 seconds to load)
# 3 examples, 0 failures

--
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 rspec+un...@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/6a3b0b0b-6adb-4e09-b91a-2eba408fcaea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages