[rspec-users] Un-recognised routes that do exist, using namespaces & subdomain checking

evanclosson closson.evan at gmail.com
Wed Nov 25 20:11:51 EST 2009


Was able to get past this testing issue for the moment.  In the
interest of time I dropped some example code on my site pending a more
permanent solution. Hope it helps...

http://www.evanclosson.com/devlog/testingrouteswithrspecandsubdomainfu

On Nov 11, 7:55 am, David Chelimsky <dchelim... at gmail.com> wrote:
> On Wed, Nov 11, 2009 at 4:54 AM, David Chelimsky <dchelim... at gmail.com>wrote:
>
>
>
> > On Wed, Nov 11, 2009 at 3:12 AM, DEfusion <david.sp... at gmail.com> wrote:
>
> >> Hi David,
>
> >> Yeah I had used the new style in the past and got the same issue, I
> >> just accidentally reverted to the old style.
>
> >> Anyway changing to the new style using route_to as suggested doesn't
> >> resolve the issue, the same 2 routes give the same error, but the
> >> telling thing is the failure message shows that the subdomain wasn't
> >> passed, or at least received by the routing:
>
> >> ActionController::RoutingError in 'Foo::MonkeysController should
> >> route'
> >> No route matches "/monkeys/1" with
> >> {:port=>80, :method=>:get, :host_with_port=>"test.host", :subdomain=>nil,
> >> :domain=>"test.host", :host=>"test.host"}
> >> If you're expecting this failure, we suggest { :get => "/monkeys/
> >> 1" }.should_not be_routable
>
> >> Even if I specifically set @request.host = 'foo.some.com' before the
> >> test it still errors saying host_with_port=>'test.host'
>
> > OK. I haven't used subdomain-fu before, but I'm guessing that it's either
> > getting loaded or invoked after rspec, or the two are monkey patching the
> > same things and creating a conflict.
>
> > Would you do me a favor and slap together a small demo app with the
> > specific version of rspec and subdomain-fu that you are using bundled
> > (vendor/gems preferable), zip it up and submit it in a ticket to
> >http://rspec.lighthouseapp.com?
>
> Of course, the app should demonstrate the failure :) Forgot that little
> tidbit.
>
>
>
> > Thx,
> > David
>
> >> -D
>
> >> On Nov 11, 12:54 am, David Chelimsky <dchelim... at gmail.com> wrote:
> >> > On Tue, Nov 10, 2009 at 4:10 PM, DEfusion <david.sp... at gmail.com>
> >> wrote:
> >> > > Removing the :sub domain conditions from the namespace does fix the
> >> > > issue, and moving the sub domain conditions to the individual route
> >> > > definitions causes them all to fail.
>
> >> > > On Nov 10, 11:59 pm, DEfusion <david.sp... at gmail.com> wrote:
> >> > > > Okay I've managed to re-create my original problem by trying to use
> >> > > > params_from to verify the routing (which was another area I was
> >> > > > experiencing problems with before).
>
> >> > > > Note each one of the routes I'm defining here all return fine in the
> >> > > > browser, they hit the appropriate controller and run the show
> >> action,
> >> > > > however as you can see by the comments 2 of the specs fail to find
> >> the
> >> > > > routes defined.
>
> >> > > >http://gist.github.com/231408
>
> >> > Can you try using route_to instead of params_from().should ==?
>
> >> > Seehttp://github.com/dchelimsky/rspec-rails/blob/master/Upgrade.rdoc
>
> >> > Let me know if that works better.
>
> >> > David
>
> >> > > > -D
>
> >> > > > On Nov 10, 11:25 pm, DEfusion <david.sp... at gmail.com> wrote:
>
> >> > > > > Now that is weird. I tried to make an isolated example for you and
> >> > > > > that worked fine. So I put un-commented my spec bit by bit and it
> >> > > > > works fine.
>
> >> > > > > I'm sure I've had this problem before. If I do re-create it I'll
> >> post
> >> > > > > more details here.
>
> >> > > > > =D
>
> >> > > > > On Nov 10, 10:48 pm, David Chelimsky <dchelim... at gmail.com>
> >> wrote:
>
> >> > > > > > On Tue, Nov 10, 2009 at 2:25 PM, DEfusion <
> >> david.sp... at gmail.com>
> >> > > wrote:
> >> > > > > > > I'm getting really cheesed off with RSpec not matching some of
> >> my
> >> > > > > > > routes when controller testing when I have subdomain checking
> >> > > > > > > (courtesy of subdomain-fu) on namespaces. These routes appear
> >> in
> >> > > the
> >> > > > > > > rake routes output, and work fine via HTTP requests .
>
> >> > > > > > > The really annoying thing is it's working fine for routes that
> >> > > aren't
> >> > > > > > > at the root of the namespace.
>
> >> > > > > > > E.g.  say I have
>
> >> > > > > > > map.namespace :foo, :path_prefix => '', :conditions => {
> >> :subdomain
> >> > > =>
> >> > > > > > > 'foo' } do |foo|
>
> >> > > > > > >    foo.bars, :controller => 'bars', :only => [:show] do |bar|
> >> > > > > > >        bar.resources some_things ....
> >> > > > > > >    end
>
> >> > > > > > >    foo.resources :monkeys
> >> > > > > > > end
>
> >> > > > > > > My specs for bars/some_things all resolve the routes fine
> >> (e.g.
> >> > > doing
> >> > > > > > > get :index etc.)
>
> >> > > > > > > Any spec that tries to hit monkeys/ give me a no route matches
> >> even
> >> > > > > > > though these routes exist
>
> >> > > > > > >    No route matches {:controller=>"foo/monkeys",
> >> :action=>"update"}
>
> >> > > > > > > I've tried setting both @request.host and request.host to
> >> > > > > > > foo.test.host but that doesn't make a blind bit of difference.
>
> >> > > > > > > Maybe RSpec is doing something different with the request, as
> >> if I
> >> > > > > > > monkey patch the routing with the following I never get the
> >> dumps
> >> > > when
> >> > > > > > > using RSpec even though both these are called pretty early on
> >> in
> >> > > route
> >> > > > > > > recognition.
>
> >> > > > > > > module Foo
>
> >> > > > > > >  module RouteSetExtensions
> >> > > > > > >    def self.included(base)
> >> > > > > > >      base.alias_method_chain :extract_request_environment,
> >> :debug
> >> > > > > > >      base.alias_method_chain :recognize_path, :debug
> >> > > > > > >    end
>
> >> > > > > > >    def recognize_path_with_debug(path, environment={})
> >> > > > > > >      puts path
> >> > > > > > >      puts environment.to_yaml
> >> > > > > > >      recognize_path_without_debug(path, environment)
> >> > > > > > >    end
>
> >> > > > > > >    def extract_request_environment_with_debug(request)
> >> > > > > > >      env = extract_request_environment_without_debug(request)
> >> > > > > > >      puts env.to_yaml
> >> > > > > > >      env
> >> > > > > > >    end
> >> > > > > > >  end
>
> >> > > > > > > end
>
> >> > > > > > > ActionController::Routing::RouteSet.send :include,
> >> > > > > > > Foo::RouteSetExtensions
>
> >> > > > > > > So as you can probably tell, I'm out of ideas so I wondered if
> >> > > anyone
> >> > > > > > > had any thoughts.
>
> >> > > > > > Please post the failing spec and the exact failure message.
>
> >> > > > > > Thx,
> >> > > > > > David
>
> >> > > > > > _______________________________________________
> >> > > > > > rspec-users mailing list
> >> > > > > > rspec-us... at rubyforge.orghttp://
> >> > > rubyforge.org/mailman/listinfo/rspec-users
>
> >> > > > > _______________________________________________
> >> > > > > rspec-users mailing list
> >> > > > > rspec-us... at rubyforge.orghttp://
> >> > > rubyforge.org/mailman/listinfo/rspec-users
>
> >> > > > _______________________________________________
> >> > > > rspec-users mailing list
> >> > > > rspec-us... at rubyforge.orghttp://
> >> > > rubyforge.org/mailman/listinfo/rspec-users
> >> > > _______________________________________________
> >> > > rspec-users mailing list
> >> > > rspec-us... at rubyforge.org
> >> > >http://rubyforge.org/mailman/listinfo/rspec-users
>
> >> > _______________________________________________
> >> > rspec-users mailing list
> >> > rspec-us... at rubyforge.orghttp://
> >> rubyforge.org/mailman/listinfo/rspec-users
> >> _______________________________________________
> >> rspec-users mailing list
> >> rspec-us... at rubyforge.org
> >>http://rubyforge.org/mailman/listinfo/rspec-users
>
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users


More information about the rspec-users mailing list