Rails测试抛出失败而没有错误

时间:2014-03-13 13:23:03

标签: ruby-on-rails ruby testing shoulda

我想了解更好的TDD。所以我在我的rails应用程序中使用shoulda,如此,

require 'test_helper'

class ProjectTest < ActiveSupport::TestCase

  should validate_presence_of(:description).with_message(/can.t be blank/)
end

我在运行测试时收到此消息。

1) Failure:
ProjectTest#test: Project should require description to be set.  [/home/.rvm/gems/ruby-2.0.0-p195/gems/shoulda-context-1.1.6/lib/shoulda/context/context.rb:344]:
Expected errors to include /can.t be blank/ when description is set to nil, got no errors

1 tests, 1 assertions, 1 failures, 0 errors, 0 skips

这是我的模特

with_options unless: :privatize do  |project|
    project.validates :title, presence: true, length: {maximum: 100}
    project.validates :description, presence: true
    ....
  end

这种失败意味着什么?我该如何解决?

0 个答案:

没有答案