Can I use multiple exception filters in rspec?

In the _spec.rb file, I configure an exception filter, for example:

RSpec.configure do |config| # we need determine this once at the very front # and the result be available in the instance server_success = server1_available? config.exclusion_filter = { :svr1 => lambda {|what| case what when :available !server_success end } } end 

and then in the file that I am doing

 describe :get_items_by_client, :svr1 => :available do 

to prevent the test from running if the server is unavailable.

Everything works fine if I only run the spec file. However, I have similar code in another file that controls the tests that access the other server, and when I run them all, only I see that each server check is performed (do I have the code "serverX_available?"), But only one test suite is excluded (although no server is available).

I'm starting to think that you can have only one exception filter, but I can find any documents anywhere that talk about it. Is this possible for every file? I can have one complex filter in the support file, but how can I enable it when I execute only one specification file?

Ideally, I would like to find a form that works for each file, but let me do the accessibility check once, as this is a somewhat expensive test, and I have a few examples in the test that are controlled by this.

+3
source share
1 answer
 config.filter_run_excluding :cost => true config.filter_run_excluding :slow => true 

Try it and it will work.

0
source

All Articles