运行 在所有水豚测试之前阻止一次
Run block once before all capybara tests
我将 Capybara 与 Rspec 一起用于集成测试 rails 应用程序。有没有什么方法可以在第一次水豚测试 运行 之前 运行 之前阻止一次,而没有它 运行 在每个功能规范之前?在我的 RSpec.configure 块中放置一个块会导致它在每个功能规范之前 运行:
RSpec.configure do |config|
config.before(:all, type: :feature) do
# do some stuff
end
end
我认为您对任务进行了过度设计。既然你要运行它一次,就运行它:
cb = lambda { puts 'I am run once' }
RSpec.configure do |config|
cb.call
end
RSpec.configure do |config|
config.before(:suite) do
# do some stuff
end
end
我将 Capybara 与 Rspec 一起用于集成测试 rails 应用程序。有没有什么方法可以在第一次水豚测试 运行 之前 运行 之前阻止一次,而没有它 运行 在每个功能规范之前?在我的 RSpec.configure 块中放置一个块会导致它在每个功能规范之前 运行:
RSpec.configure do |config|
config.before(:all, type: :feature) do
# do some stuff
end
end
我认为您对任务进行了过度设计。既然你要运行它一次,就运行它:
cb = lambda { puts 'I am run once' }
RSpec.configure do |config|
cb.call
end
RSpec.configure do |config|
config.before(:suite) do
# do some stuff
end
end