[rspec-users] Testing controller plugin

Matt Wynne matt at mattwynne.net
Mon Feb 8 04:12:24 EST 2010

On 8 Feb 2010, at 02:34, Phillip Koebbe wrote:

> Matt Wynne wrote:
>> On 1 Feb 2010, at 15:14, Phillip Koebbe wrote:
>>> I have just recently started creating some plugins, mainly of the  
>>> controller variety. I have been looking for a tutorial or other  
>>> documentation detailing how to go about testing these plugins with  
>>> RSpec, but have not yet found anything helpful. Can anyone point  
>>> me toward such a thing?
>> Create a controller in your specs which uses the plugin in an  
>> exemplary way, then asserts the behaviour of that controller.
> Thanks, Matt. I have some parts of it working now, but am stumped  
> when trying to call an action. I need to do a post :create, but post  
> is not a known method. Do you happen to know of a controller plugin  
> that used RSpec that I could peruse?

Yeah, you need to convince RSpec that the describe blocks you're using  
are describing an ExampleGroup that's about a Rails Controller, then  
it will mix in the right methods for you. I think you can do something  

describe MySpecialTestController, :type => :controller do

That's the general idea. I think someone else on the list will be able  
to help more than me with the specifics.

As for a plug-in, I don't know any off-hand... try a few popular ones  
out on github and look for a spec directory in the root I guess.

> Thanks,
> Phillip
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users


+447974 430184

More information about the rspec-users mailing list