[rspec-users] controller_name with dynamic controllers

David Chelimsky dchelimsky at gmail.com
Mon Mar 19 07:10:59 EDT 2007


On 3/19/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
>
> I'm writing a controller which should only be inherited from,
> something like the generic crud controller seen here: http://
> geekonomics.blogspot.com/2006/07/crud-and-shared-controllers.html
>
> Now, in my spec, I would like to create a controller which inherits
> from the generic CRUDController, without actually creating the
> controller.  This controller is *only* for testing.
>
> How can I do this?  I can't do something like this:
>
> Object.const_set("MyCrudController", Class.new(CRUDController))

unless defined?(TestingCrudController)
  TestingCrudController = Class.new(CRUDController)
end

>
> because the method "controller_name" will complain of setting the
> constant twice.
>
> Any ideas?
>
> Best,
>
> Scott Taylor
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list