[rspec-users] Shoulda

Nathan Sutton nathan.sutton at gmail.com
Thu Jan 10 20:19:51 EST 2008


That too :)

Nathan Sutton
fowlduck at gmail.com
rspec 1.1
rspec_on_rails 1.1
rails 2.0.2

On Jan 10, 2008, at 6:59 PM, David Chelimsky wrote:

> On Jan 10, 2008 6:48 PM, Nathan Sutton <nathan.sutton at gmail.com>  
> wrote:
>> You should browse over how shoulda does it here:
>> http://thoughtbot.com/projects/shoulda/tutorial/controllers
>
> Or how others are supplying plugins for rspec:
>
> http://weblog.techno-weenie.net/2007/12/26/controller-specs-are-a-drag
> http://git.caboo.se/?p=altered_beast.git;a=tree;f=vendor/plugins/rspec_on_rails_on_crack/lib;h=62b5fe1ccad8186a989f5d72dd218f3678fae518;hb=HEAD
>
>>
>> and here:
>> http://dev.thoughtbot.com/shoulda/classes/ThoughtBot/Shoulda/Controller/ClassMethods.html
>>
>> Nathan Sutton
>> fowlduck at gmail.com
>> rspec 1.1
>> rspec_on_rails 1.1
>> rails 2.0.2
>>
>>
>> On Jan 10, 2008, at 6:29 PM, Jonathan Leighton wrote:
>>
>>> On Thu, 2008-01-10 at 18:47 -0500, Josh Knowles wrote:
>>>> On 1/10/08, Nathan Sutton <nathan.sutton at gmail.com> wrote:
>>>>> Hmm, that includes a good number of them, but there's still the
>>>>> restful resource to think about, which is in my opinion the most
>>>>> valuable one.  Would you consider the addition of a restful  
>>>>> resource
>>>>> matcher similar to shoulda's?
>>>>
>>>> Yes.  If you work something up I'd happily add it.  Unfortunately I
>>>> don't have the need/time/desire to do it myself right now though.
>>>
>>> My reservation with the idea of "should be restful" is that you have
>>> to
>>> assume an awful lot about how the controller is implemented. That's
>>> fine
>>> if you use scaffolding excessively but if you actually write your  
>>> own
>>> code (!!) things quickly start to deviate from the trodden path.
>>>
>>> Recently I have been writing my controller specs a bit like this (I
>>> have
>>> some support code to enable it):
>>>
>>> describe PostsController do
>>> controller_name :posts
>>> stub_resource
>>>
>>> describe "when a post is viewed and the current user is an admin" do
>>>   log_in :as => :admin
>>>   get :show, :id => 42
>>>
>>>   it_should_find
>>>   it_should_load_awesome_admin_stuff
>>> end
>>>
>>> describe "when a post is edited by a normal user" do
>>>   log_in :as => :prole
>>>   get :edit, :id => 23
>>>
>>>   it_should_find
>>>   it_should_warn
>>>   it_should_redirect_to "the post's page", :at => "post_path(@post)"
>>> end
>>> end
>>>
>>> Some of the above is me using my creative license but you get the
>>> idea.
>>> Just thought it might spark some ideas/opinions... it's certainly
>>> not a
>>> perfect implementation/API but I've found the general idea quite
>>> useful.
>>> I personally think this is the right level at which to make the
>>> abstraction - you are still specifying the behaviour explicitly,  
>>> just
>>> writing less code when doing it.
>>>
>>> Jon
>>>
>>> --
>>> Jonathan Leighton
>>> http://jonathanleighton.com/
>>>
>>> _______________________________________________
>>> rspec-users mailing list
>>> rspec-users at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list