1.
config.when_first_matching_example_defined(type: :feature) do
require 'support/db'
end
type: :featurebundle exec rspec -t ~type:featurerequire 'support/db' is not run
require 'support/db' is run
:wave: It's when the example is defined, not when its run. You've loaded the example and filtered it out, which is defined, but skipped. This is thus working as designed and documented.
Without knowing the contents of your support/db I can't help with much advice, but you can then add something else to be run when the first example runs to setup the db etc.
Hey Slava 馃憢
I can suggest using a regular before hook with some trigger-once check:
before(:example, type: :feature) do
only_once { require 'support/db' }
end
Fun fact, require 'support/db' will only run once provided its the same path.
Agree, it's a bad example. A slightly better one:
before(:example, type: :feature) do
only_once { expensive_setup }
end
I knew had a clue that answer would be that, thanks anyway :)
Most helpful comment
I knew had a clue that answer would be that, thanks anyway :)