Rails rspec expects Admin::PostsController, which is there.

Posted by berkes on Stack Overflow See other posts from Stack Overflow or by berkes
Published on 2011-01-08T16:20:49Z Indexed on 2011/01/09 20:53 UTC
Read the original article Hit count: 324

Filed under:
|
|
|

I have a file app/controllers/admin/posts_controller.rb

class Admin::PostsController < ApplicationController
  layout 'admin'

  # GET /admin/posts
  def index
     @pposts = Post.paginate :page => params[:page], :order => 'created_at DESC'
  end
  # ...Many more standard CRUD/REST methods...
end

And an rspec test spec/controllers/admin/posts_controller_spec.rb

require 'spec_helper'

describe Admin::PostsController do

  describe "GET 'index'" do
    it "should be successful" do
      get 'index'
      response.should be_success
    end
  end
  #...many more test for all CRUD/REST methods
end

However, running that spec throws an error. I have no idea what that error means, nor how to start solving it.

/home/...../active_support/dependencies.rb:492:in `load_missing_constant': Expected /home/...../app/controllers/admin/posts_controller.rb to define Admin::PostsController (LoadError)

I may have it all set up wrong, or may be doing something really silly, but all I want is my CRUD actions on /admin, with separate before filters and a separate layout. And to test these controllers.

EDIT ZOMG, made a terrible copy-paste error into this SO posting. The controller was PostsController, not the PagesController that I pasted into there. Problem still stands, as my code is correct, just the SO post, here was wrong.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about error