【发布时间】:2017-06-27 02:16:57
【问题描述】:
require_relative File.expand_path '../../test_helper',__FILE__
FactoryGirl.define do
factory :task do
name "testinga again"
finished 0
end
end
class TaskTest < Test::Unit::TestCase
include FactoryGirl::Syntax::Methods
test "should not save tasks without title" do
task = Task.new
assert_equal false, task.save
end
test "should save tasks" do
task = FactoryGirl.create(:task)
assert_equal attributes_for(:task), task
end
end
我想对任务创建过程进行单元测试。在should save task 任务中,我已将值保存到数据库中,现在我想测试保存的值是否等于我真正发送到数据库的值。该怎么做,或者我做得对吗?
【问题讨论】:
标签: ruby unit-testing testunit