I'd like to modify some things in the controller and test them using rspec. I want to create new
action for Spree::ProductsController
. This is what I've tried
routes.rb
resources :products
prodcuts_controller_decorator.rb
Spree::ProductsController.class_eval do
before_filter :authenticate_spree_user!, :except => [:show, :index]
def new
@product = current_user.products.build
end
end
products_controller_spec.rb
require 'spec_helper'
describe Spree::ProductsController do
let(:user) {create(:user)}
before(:each) do
Spree::Core::Engine.routes
BigPlanet::Application.routes
controller.stub :spree_current_user => user
end
it "render new template" do
get :new
response.should render_template(:new)
end
end
end
But its using original Spree::Controller
and gives
Failure/Error: get :new
ActionController::RoutingError:
No route matches {:controller=>"spree/products", :action=>"new"}
If anyone can shove me in the right direction then it'd great.
Spree::ProductsController
, corrected, but the error persists – Greenfinch