Nick Hoffman
2010-Apr-20 12:33 UTC
[rspec-users] Speccing the creation of a singleton resource
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