0
votes

I have both Capybara JS specs and Rack Test specs. I want to have a before :each block only for the Capybara specs. All Capybara specs are JS.

I tried using before :each, js: :true, but the specs are not marked as JS. I am setting the default driver to webkit, so I don't have to mark each spec as JS.

So, how to run a before :each on Capybara specs and exclude Rack Test specs?

1
How are the capybara specs identified ?Frederick Cheung
Currently using :js. However, I could put them in a separate directory (like features). Or use a separate tag, like :jasmine.B Seven

1 Answers

0
votes

Something like this in your spec_helper should work:

Capybara.configure do |config|
  config.before(:suite) do
    # do before whole test suite
  end

  config.before(:each) do
    # do before each test
  end
end

Also, definitely is a good idea to separate out your features, so your spec folder looks like this:

/spec
  /controllers
  /features
  /models