开发者

RSpec seems to break when the route 'match' statement has a subdirectory (or nested route) listed

it "should match login for existing account" do
  { :get =>开发者_JS百科 'http://www.' + @business.subdomain + '.lvh.me:3000/login' }.should route_to({:controller => "go", :action => "index"})
end

match '/login' => 'admin/calendars#index' # this one should actually work, but fails:

The recognized options <{"controller"=>"errors", "action"=>"handle404", "a"=>"login"}> did not match <{"controller"=>"go", "action"=>"index"}>, difference: <{"controller"=>"go", "action"=>"index", "a"=>"login"}>.

The specific controller#route here does exist, but the directory/nested route ('admin/') seems to cause a failure. Even if the route didn't exist it should fail in the same way the next one does, considering that the specified route there ('calendars#index') does not exist. The existence of the resulting routes doesn't matter -- as this is only supposed to test that the mapping works. Any idea how to get around this?

  match '/login' => 'calendars#index' #this one fails as expected:

The recognized options <{"controller"=>"calendars", "action"=>"index"}> did not match <{"controller"=>"go", "action"=>"index"}>, difference: <{"controller"=>"go"}>


Your building of your test route is wrong:

it "should match login for existing account" do
  { :get => 'http://www.' + @business.subdomain + '.lvh.me:3000/login' }.should route_to({:controller => "go", :action => "index"})
end

should probably read:

it "should match login for existing account" do
  { :get => 'http://' + @business.subdomain + '.lvh.me:3000/login' }.should route_to({:controller => "go", :action => "index"})
end

as presumably you want to test http://foo.lvh.me/etc not http://www.foo.lvh.me etc

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜