0

我在我的 Ruby on Rails 开发中做 TDD。我的代码如下所示:

require "spec_helper"

describe "Schedule routing" do

  it "by default should redirect /schedule to 'schedule/dateview'" do
    visit("/schedule")
    current_path.should == "/schedule/dateview"                                                                                      
  end

end

这是检查路由的更简洁的方法吗?

编辑:添加我的 routes.rb 以获得更多上下文:

 get "schedule/dateview", to: "events#dateview"
 get "schedule/courseview", to: "events#courseview"
 match "/schedule" => redirect("/schedule/dateview"), via: :get
4

1 回答 1

0

如果你在一个控制器规范中,这样的东西应该可以工作

it "by default should redirect /schedule to schedule/dateview'" do
  visit schedule_path
  response.should redirect_to schedule_dateview_path
end
于 2013-04-24T13:17:07.497 回答