2
votes

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
2

2 Answers

1
votes
RSpec.configure do |config|
    config.before(:suite) do
      # do some stuff
    end
end
0
votes

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