加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Ruby on Rails:更详细的测试

发布时间:2020-12-17 03:05:24 所属栏目:百科 来源:网络整理
导读:这个测试不断失败,我不知道为什么: test "correctly formatted profile_name2" do user = User.new(first_name: 'Jim',last_name: 'Johnson',email: 'jim@teamtreehouse.com',password: 'awfawwf',profile_name: "jimmy") puts user.errors.inspect assert
这个测试不断失败,我不知道为什么:

test "correctly formatted profile_name2" do
    user = User.new(first_name: 'Jim',last_name: 'Johnson',email: 'jim@teamtreehouse.com',password: 'awfawwf',profile_name: "jimmy")
    puts user.errors.inspect
    assert user.valid?
  end

我试图通过put来发现user.errors.inspect语句,但是我得到了一个数组(我认为),它只是简单地列出数据库输入,而不是确切地说是失败了.

为了澄清:

<ActiveModel::Errors:0x00000103c8ad30 @base=#<User id: nil,first_name: "Jim",last_name: "Johnson",profile_name: "jimmy",email: "jim@teamtreehouse.com",encrypted_password: "$2a$04$LTOb5O.gG0DEITsb/HDOb.fPLP83LaXzKlEerwCDE1og...",reset_password_token: nil,reset_password_sent_at: nil,remember_created_at: nil,sign_in_count: 0,current_sign_in_at: nil,last_sign_in_at: nil,current_sign_in_ip: nil,last_sign_in_ip: nil,confirmation_token: nil,confirmed_at: nil,confirmation_sent_at: nil,unconfirmed_email: nil,failed_attempts: 0,unlock_token: nil,locked_at: nil,authentication_token: nil,created_at: nil,updated_at: nil>,@messages={}>

在将来的测试中,在测试中使用哪些语句进行打印以明确显示出现了什么问题?

解决方法

而不是在测试中输出更详细的信息,也可能有助于设置TESTOPTS参数以在运行测试时获得详细输出.

例如,您可以这样设置:

rake test TESTOPTS="-v"

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读