[rspec-users] Speccing the creation of a singleton resource

Nick Hoffman nick at deadorange.com
Tue Apr 20 08:33:17 EDT 2010


Hey guys. I'm writing a Rails gem that's used by controllers. The gem
creates a singleton resource at run-time, along the lines of:


controller_name = ...dynamically generated...

ActionController::Routing::Routes.draw do |map|
    map.resource controller_name, :only => :show
end


I'm trying to figure out how to spec the creation of the singleton
resource. The best that I've come up with so far is checking that a
route exists:

ActionController::Routing::Routes.routes.last.defaults[:controller].should
== controller_name.to_s

However, that doesn't test whether or not it's a singleton resource.

Any suggestions? Thanks,
Nick


More information about the rspec-users mailing list