我正在使用capybara
with minitest
on Rails 2.3.14。与大多数应用程序一样,此应用程序也需要登录才能在站点内执行任何操作。我希望每个测试套件能够登录一次,并在所有运行的测试中使用该会话。我如何将其重构为minitest_helper
? 现在我的助手看起来像这样:
#!/usr/bin/env ruby
ENV['RAILS_ENV'] = 'test'
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
gem 'minitest'
gem 'capybara_minitest_spec'
require 'minitest/unit'
require 'minitest/spec'
require 'minitest/mock'
require 'minitest/autorun'
require 'capybara/rails'
require 'factory_girl'
FactoryGirl.find_definitions
class MiniTest::Spec
include FactoryGirl::Syntax::Methods
include Capybara::DSL
include ActionController::URLWriter
before(:each) do
# .. misc global setup stuff, db cleanup, etc.
end
after(:each) do
# .. more misc stuff
end
end
谢谢。