我在我的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
是否有更简洁的方法来检查路由?
编辑:添加我的路由。Rb查看更多上下文: get "schedule/dateview", to: "events#dateview"
get "schedule/courseview", to: "events#courseview"
match "/schedule" => redirect("/schedule/dateview"), via: :get
如果你在控制器规范中,像这样的东西应该可以工作
it "by default should redirect /schedule to schedule/dateview'" do
visit schedule_path
response.should redirect_to schedule_dateview_path
end