I completely understand why you should use before(:each) and make all expectations independent of each other, but I'm just interested into why this would happen:
before(:each) { visit "/" } # Selenium visits the root path of my app
before(:all) { visit "/" } # Selenium doesn't even open firefox.
Nothing happens with the background(:all)
, but if I raise an exception in the same context, Selenium does open firefox and visits this weird empty file.
file:///home/starkers/.rvm/gems/ruby-2.0.0-p247/gems/capybara-2.2.0/lib/capybara/empty.html
So does anyone know if Capybara actively ignores code in a before block(:all), and if so, how can I get it to not ignore code in a before(:all)?
This isn't really serious project, but I was thinking about benchmarking with Capybara, so it would be nice if someone showed me a way to get Capybara working with a before(:all).
There is a distinct difference in these two before
blocks.
before(:each)
is evaluated before every test.
before(:all)
is evaluated before running your tests. Once.
You should probably be using before(:each)
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.