Created
November 10, 2009 23:55
-
-
Save DEfusion/231408 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | |
describe Foo::BarsController do | |
before(:each) do | |
@request.host = 'foo.test.host' | |
end | |
it "should route" do | |
params_from(:get, "/bars/1").should == {:controller => "foo/bars", :action => "show", :id => '1'} | |
# FAILS | |
# ActionController::RoutingError in 'Foo::BarsController should route' | |
# No route matches "/bars/1" with {:method=>:get} | |
end | |
end | |
describe Foo::SubBarsController do | |
before(:each) do | |
@request.host = 'foo.test.host' | |
end | |
it "should route" do | |
params_from(:get, "/bars/1/sub_bars/1").should == {:controller => "foo/sub_bars", :action => "show", :bar_id => '1', :id => '1'} | |
# Passes | |
end | |
end | |
describe Foo::MonkeysController do | |
before(:each) do | |
@request.host = 'foo.test.host' | |
end | |
it "should route" do | |
params_from(:get, "/monkeys/1").should == {:controller => "foo/monkeys", :action => "show", :id => '1'} | |
# FAILS | |
# ActionController::RoutingError in 'Foo::MonkeysController should route' | |
# No route matches "/monkeys/1" with {:method=>:get} | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rake routes output | |
foo_bar_sub_bar GET /bars/:bar_id/sub_bars/:id(.:format) {:controller=>"foo/sub_bars", :action=>"show"} | |
foo_bar GET /bars/:id(.:format) {:controller=>"foo/bars", :action=>"show"} | |
foo_monkey GET /monkeys/:id(.:format) {:controller=>"foo/monkeys", :action=>"show"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map.namespace :foo, :path_prefix => '', :conditions => { :subdomain => 'foo' } do |foo| | |
foo.resources :bars, :only => :show do |bars| | |
bars.resources :sub_bars, :only => :show | |
end | |
foo.resources :monkeys, :only => :show | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment