I'm using Capybara with Rspec for integration testing a rails app. Is there any way to run a before block once before the first Capybara test runs without it running before every feature spec? Putting a block in my RSpec.configure block as such causes it to run before each feature spec:
RSpec.configure do |config|
config.before(:all, type: :feature) do
# do some stuff
end
end
RSpec.configure do |config|
config.before(:suite) do
# do some stuff
end
end
I think you are overengineering the task. Since you are to run it once , just run it:
cb = lambda { puts 'I am run once' }
RSpec.configure do |config|
cb.call
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.