學習如何測試很難!我只是試圖讓MiniTest跑步和男人,這是一個挫敗。我觀看了Ryan的RailsCasts並閱讀了關於這個主題的所有文檔。MiniTest行爲奇怪,跳過集成測試文件夾
我只對(或試圖做)測試幫助者,模型和請求。現在,我的模型和幫助程序測試只是被剔除而已。
但是,我有真正的身份驗證集成測試書面,他們甚至沒有運行!看看這個:
➜ myapp git:(master) rake
==============================================================================
SUITE test/factories,test/helpers,test,test/models,test/requests (SEED 41025)
==============================================================================
User
0001 must be a real test 0:00:00.005 FAIL
0:00:00.005 ERROR
==============================================================================
SUITE test/factories,test/helpers,test,test/models,test/requests (SEED 12794)
==============================================================================
SessionsHelper
0001 must be a real test 0:00:00.006 FAIL
0:00:00.006 ERROR
Errors running models, helpers!
那麼這只是超級,它沒有像它應該的那些。現在爲什麼不運行「測試/請求」目錄中的東西!
require 'minitest_helper'
describe "Login Integration" do
it "authenticates a user with a password" do
login_user
assert page.has_content?('Logged in')
end
it "fails to authenticate a user with a mismatched password" do
user = FactoryGirl.create(:user)
visit login_path
fill_in "Email", :with => user.email
fill_in "Password", :with => "bad password"
click_button "Log In"
assert page.has_content?('Invalid email or password')
end
it "logs out a user" do
login_user
click_link "Log Out"
assert page.has_content?('Logged out')
end
end
我可以在文件的中間鍵入「Joe Blow」,但我甚至沒有收到語法錯誤。無論如何這個文件沒有被拾起,沒有任何理由。查看名稱「登錄集成」?那麼,它必將在我的minitest_helper.rb像這樣:
class IntegrationTest < MiniTest::Spec
include Rails.application.routes.url_helpers
include Capybara::DSL
register_spec_type(/integration$/i, self)
end
它看起來確實只是一個稍微有點早應包括這個東西在鋼軌4代碼庫,如果這就是我們在用它。誰能告訴我我做錯了什麼?