开发者

Rails 3 assertions failure message: "Expected block to return true value" not helpful; what gives?

开发者 https://www.devze.com 2023-03-31 07:58 出处:网络
This occurs frequently in my controller and route tests.Example, given the route match \"/about\", :to => \"about#profile\"

This occurs frequently in my controller and route tests. Example, given the route

match "/about", :to => "about#profile"

And the test

test "/about goes to about/profile" do
  assert_generates "/about/", { :controller => "about", :action => "profile" }
end

The only failure message is "Expected block to return true value". This happens also with tests like:

test "bills should redirect to /bills" do
  get :bills
  assert_redirected_to user_bills_path(@user)
end

If my controller doesn't' redirect to user_bills_path(@user), I get the same error: "Expected block to return true value"

This is very annoying for test-driving, as I cannot easily check that my assertion is failing before writing production code or failing because I've written the incorrect test.

It seems to be coming from Rails testing stuff. Any way to avoid this or get better me开发者_如何学JAVAssages?

0

精彩评论

暂无评论...
验证码 换一张
取 消