在我达到6.17之前,我的测试一直在变绿。有人能帮我看看是怎么回事吗?
以下是错误和失败:
ERROR["test_layout_links", SiteLayoutTest, 0.011797307059168816]
test_layout_links#SiteLayoutTest (0.01s)
ArgumentError: ArgumentError: Range unspecified. Specify the :in,
:within, :maximum, :minimum, or :is option.
app/models/user.rb:3:in `<class:User>'
app/models/user.rb:1:in `<top (required)>'
FAIL["test_email_should_not_be_too_long", UserTest, 0.04466394800692797]
test_email_should_not_be_too_long#UserTest (0.04s)
Expected true to be nil or false
test/models/user_test.rb:29:in `block in <class:UserTest>'
12/12: [=============================================================] 100%
Time: 00:00:00, Time: 00:00:00
Finished in 0.62805s
12 tests, 15 assertions, 1 failures, 1 errors, 0 skips这是我的user.rb文件:
class User < ApplicationRecord
validates :name, presence: true, length: { maximum: 50 }
validates :email, presence: true, length: { maxmium: 255 }
end这是我的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
test "name should not be too long" do
@user.name = "a" * 51
assert_not @user.valid?
end
test "email should not be too long" do
@user.email = "a" * 244 + "@example.com"
assert_not @user.valid?
end
end这是我的site_layout_test.rb文件,因为它是以某种方式涉及到的:
require 'test_helper'
class SiteLayoutTest < ActionDispatch::IntegrationTest
test "layout links" do
get root_path
assert_template 'static_pages/home'
assert_select "a[href=?]", root_path, count: 2
assert_select "a[href=?]", help_path
assert_select "a[href=?]", about_path
assert_select "a[href=?]", contact_path
get contact_path
assert_select "title", full_title("Contact")
get signup_path
assert_select "title", full_title("Sign Up")
end
end我已经对这些文件进行了排印,似乎找不到正在发生的事情。谢谢你能提供的任何帮助。
发布于 2018-01-04 04:37:53
对user.rb文件进行拼写检查。您错选了maximum for for
代码应该是
class User < ApplicationRecord
validates :name, presence: true, length: { maximum: 50 }
validates :email, presence: true, length: { maximum: 255 }
endhttps://stackoverflow.com/questions/48087048
复制相似问题