FAQ
Hi guys,

My route file is as below.
==========================
Spree::Core::Engine.routes.prepend do
   namespace :admin do
     resources :question_categories
     resources :questions
   end
   match :faq, to: 'faqs#index', as: 'faq'
end

===========================

I'm testing against routes and i have created a file under
spec/routing/extension_route_spec.rb having this code.
==========================
require 'spec_helper'

describe Spree::FaqsController do
   it "routes to #index" do
     expect(:get=>'/faq').to route_to(:controller => "spree/faqs",:action =>
"index")
   end
end
=============================

But when i run my spec it gives me error "No Route matches"

Error:

1) Spree::FaqsController routes to #index
      Failure/Error: expect(:get=>'/faq').to route_to(:controller =>
"spree/faqs",:action => "index")
        No route matches "/faq"
      # ./spec/routing/spree_faq_route_spec.rb:5:in `block (2 levels) in
<top (required)>'

Why my extension routes are not accessible by rspec. I'm new to Spree. any
help?

Thanks.

Search Discussions

  • Ryan Bigg at Jul 25, 2013 at 6:20 am
    I don't know what arguments in particular route_to takes, but with certain
    other testing methods (get, post, put and delete in controller specs), we
    need to pass a `:use_route` option.

    So try this:

    expect(:get=>'/faq').to route_to(:controller => "spree/faqs",:action =>
    "index", :use_route => :spree)

    Personally, I don't like to have tests for the routes. That kind of thing
    is typically tested by the controller or integration tests already.

    On Thu, Jul 25, 2013 at 3:26 AM, wrote:

    Hi guys,

    My route file is as below.
    ==========================
    Spree::Core::Engine.routes.prepend do
    namespace :admin do
    resources :question_categories
    resources :questions
    end
    match :faq, to: 'faqs#index', as: 'faq'
    end

    ===========================

    I'm testing against routes and i have created a file under
    spec/routing/extension_route_spec.rb having this code.
    ==========================
    require 'spec_helper'

    describe Spree::FaqsController do
    it "routes to #index" do
    expect(:get=>'/faq').to route_to(:controller => "spree/faqs",:action
    => "index")
    end
    end
    =============================

    But when i run my spec it gives me error "No Route matches"

    Error:

    1) Spree::FaqsController routes to #index
    Failure/Error: expect(:get=>'/faq').to route_to(:controller =>
    "spree/faqs",:action => "index")
    No route matches "/faq"
    # ./spec/routing/spree_faq_route_spec.rb:5:in `block (2 levels) in
    <top (required)>'

    Why my extension routes are not accessible by rspec. I'm new to Spree. any
    help?

    Thanks.




    --

    Ryan Bigg
    Community Manager
    Spree Commerce, Inc.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupspree-user @
categoriesrubyonrails
postedJul 24, '13 at 5:26p
activeJul 25, '13 at 6:20a
posts2
users2
websitespreecommerce.com
irc#RubyOnRails

2 users in discussion

Ryan Bigg: 1 post Jasonrao991: 1 post

People

Translate

site design / logo © 2022 Grokbase