2016-01-21 64 views
-1

我收到此錯誤信息時,我添加了最後一次測試在Ruby中的代碼on Rails的教程,從上市6.11和6.12,然後運行包的exec耙測試清單6.13我運行Linux XubuntuNameError:未初始化不斷ApplicationHelperTest :: FILL_IN

1) Error: ApplicationHelperTest#test_full_title_helper: NameError: uninitialized constant ApplicationHelperTest::FILL_IN test/helpers/application_helper_test.rb:5:in `block in '

當我刪除電子郵件驗證測試通過。

測試/模型/ user_test.rb

require 'test_helper' 

class UserTest < ActiveSupport::TestCase 
    def setup 
    @user = User.new(name: "Example User", email: "[email protected]") 
    end 

    test "should be valid" do 
    assert @user.valid? 
    end 

    test "name should be present" do 
    @user.name = "" 
    assert_not @user.valid? 
    end 

    test "email should be present" do 
    @user.email = "  " 
    assert_not @user.valid? 
    end 
end 

應用程序/模型/ user.rb

class User < ActiveRecord::Base 
    validates :name, presence: true 
    validates :email, presence: true 
end 

我認爲,必須有一些做的應用助手。這是助手代碼:

require 'test_helper' 

class ApplicationHelperTest < ActionView::TestCase 

    test "full title helper" do 
    assert_equal full_title,   FILL_IN 
    assert_equal full_title("Help"), FILL_IN 
    end 
end 

回答

3

這是因爲測試正試圖尋找一個名爲FILL_IN常數,它不存在。本教程要求你用正確的價值觀,以取代FILL_IN

+0

此代碼只給了我一個錯誤。我想我需要定義一個方法,但不知道是什麼方法。 需要 'test_helper' 類ApplicationHelperTest <::的ActionView TestCase的 測試 「全稱幫手」 做 assert_equal full_title(名稱: 「示例用戶」) assert_equal full_title(電子郵件: 「[email protected]」) 結束 結束 –

+0

這是錯誤,以及如何來我不能格式的這些意見。 –

+0

1)錯誤: ApplicationHelperTest#test_full_title_helper: NoMethodError:未定義的方法'+ '爲{:名稱=> 「示例用戶」}:哈希 應用程序/助手/ application_helper.rb:9:在'full_title' 測試/助手/application_helper_test.rb:6:in ' 10個運行,18個斷言,0個失敗,1個錯誤,0個跳過 –

相關問題