【发布时间】:2009-01-31 00:23:53
【问题描述】:
我想实现方法User.calculate_hashed_password。我正在尝试使用与 Rails 的内置测试工具配合使用的 Shoulda 测试库,因此与 Test::Unit 相关的答案与与 Shoulda 相关的答案一样好(我认为)。
我正试图弄清楚我需要测试什么以及如何测试它。我最初的想法是做类似...
class UserTest < ActiveSupport::TestCase
should 'Return a hashed password'
assert_not_nil User.calculate_hashed_password
end
end
这是正确的做法吗?
【问题讨论】:
-
“calculate_hashed_password”有什么作用?生成“密码”属性的散列版本?
标签: ruby-on-rails ruby unit-testing testing shoulda