NameError: uninitialized constant ApplicationHelperTest::Fill_IN
NameError: uninitialized constant ApplicationHelperTest::Fill_IN
当我在 Rails 教程的 Ruby 添加最后一个测试时收到此错误消息,来自清单 6.11 和 6.12 然后 运行 bundle exec rake 测试清单 6.13 我是 运行ning Linux Xubuntu
1) Error:
ApplicationHelperTest#test_full_title_helper:
NameError: uninitialized constant ApplicationHelperTest::FILL_IN
test/helpers/application_helper_test.rb:5:in `block in '
当我删除电子邮件验证时,测试通过。
test/models/user_test.rb
require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@user = User.new(name: "Example User", email: "user@example.com")
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
app/models/user.rb
class User < ActiveRecord::Base
validates :name, presence: true
validates :email, presence: true
end
我想一定是和Application Helper有关。这是助手中的代码:
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
这是因为测试试图寻找一个名为 FILL_IN
的常量,它不存在。本教程要求您将 FILL_IN
替换为正确的值。
当我在 Rails 教程的 Ruby 添加最后一个测试时收到此错误消息,来自清单 6.11 和 6.12 然后 运行 bundle exec rake 测试清单 6.13 我是 运行ning Linux Xubuntu
1) Error: ApplicationHelperTest#test_full_title_helper: NameError: uninitialized constant ApplicationHelperTest::FILL_IN test/helpers/application_helper_test.rb:5:in `block in '
当我删除电子邮件验证时,测试通过。
test/models/user_test.rb
require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@user = User.new(name: "Example User", email: "user@example.com")
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
app/models/user.rb
class User < ActiveRecord::Base
validates :name, presence: true
validates :email, presence: true
end
我想一定是和Application Helper有关。这是助手中的代码:
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
这是因为测试试图寻找一个名为 FILL_IN
的常量,它不存在。本教程要求您将 FILL_IN
替换为正确的值。