Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 Rails 3断言失败消息:";预期块将返回真值“;没有帮助;有什么好处?_Ruby On Rails 3_Testing_Tdd - Fatal编程技术网

Ruby on rails 3 Rails 3断言失败消息:";预期块将返回真值“;没有帮助;有什么好处?

Ruby on rails 3 Rails 3断言失败消息:";预期块将返回真值“;没有帮助;有什么好处?,ruby-on-rails-3,testing,tdd,Ruby On Rails 3,Testing,Tdd,这在我的控制器和路由测试中经常发生。例如,给定路线 match "/about", :to => "about#profile" 测试呢 test "/about goes to about/profile" do assert_generates "/about/", { :controller => "about", :action => "profile" } end 唯一的失败消息是“预期块返回真值”。这种情况也会发生在以下测试中: test "bills sh

这在我的控制器和路由测试中经常发生。例如,给定路线

match "/about", :to => "about#profile"
测试呢

test "/about goes to about/profile" do
  assert_generates "/about/", { :controller => "about", :action => "profile" }
end
唯一的失败消息是“预期块返回真值”。这种情况也会发生在以下测试中:

test "bills should redirect to /bills" do
  get :bills
  assert_redirected_to user_bills_path(@user)
end
如果我的控制器没有“重定向到
user\u bills\u path(@user)
,我会得到相同的错误:“预期块返回真值”

这对于测试驱动来说是非常烦人的,因为在编写生产代码之前,我无法轻松检查我的断言是否失败,或者因为我编写了错误的测试而失败

它似乎来自Rails的测试内容。有没有办法避免这种情况或获得更好的信息