开发者

How do you test for a routing error in Rails 3?

开发者 https://www.devze.com 2023-03-28 09:00 出处:网络
After searching, can\'t find the answer to this simple question. Yes, I read the Guides many times. Here\'s what I got so far.

After searching, can't find the answer to this simple question. Yes, I read the Guides many times.

Here's what I got so far.

test "there开发者_如何转开发 is no route for this request" do
  assert_raise(Exception) {
    post :the_route
  }
end

The browser shows

Are there any resources that explain the basics of testing (besides the Guides)?

Thanks.


Have you looked into the routing assertions at all? They could be what you're looking for. Most app's I've worked on have at least one "routes_test". check them out here:

http://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html

0

精彩评论

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