[rspec-users] [OT] Object Mother vs Test Data Builder (was Jay Fields' blog on developer testing)

s.ross cwdinfo at gmail.com
Sat Feb 7 14:33:08 EST 2009


Hi--

On Feb 7, 2009, at 7:59 AM, Nick Hoffman wrote:

> On 06/02/2009, at 10:00 PM, s.ross wrote:
>> I did stop writing new controller specs, but we were discussing the  
>> use-case for controller specs in the new Cukified world. Supposing  
>> you write scenarios that pretty much describe your app, what could  
>> possibly go wrong that a controller spec would catch but a cucumber  
>> story pass? My environment is not using Selenium or Watir, so any  
>> action that is Ajaxey potentially needs a controller spec example.  
>> I'm less clear that routing needs to be in the specs, but shoulda  
>> makes that stupid-simple, so it's a way to make sure I don't break  
>> something embarrassing when I'm goofing around in routes.
>>
>> I'm starting to think that Cucumber can do 90+% of the heavy  
>> lifting, but for describing what kind of response a controller will  
>> ship back (json or html), based on the request, user-agent specific  
>> stuff. All that would probably have to happen in controller specs.
>>
>> In response to Jay's post, I test what I'm afraid might fail. I  
>> test it to clarify my thinking as I build it. So if it's important  
>> that a controller return json in response to an XmlHttp request,  
>> then that's part of the spec.
>>
>> Does this sound reasonable?
>
> When writing Cucumber stories and features for controllers, should  
> you cover every edge case? For example, should you write stories  
> that feed bad or missing data to your controllers, or should that be  
> left to RSpec?
> -Nick

Why wouldn't you cover the negative scenario. E.g.:

Feature: Projects dashboard
   Scenario: A user who has not set up any projects yet should be sent  
to the "set up new project now!" page
     Given a user, "Emil" has no projects
     When "Emil" clicks on the "dashboard" link
     Then he sees the "new project" page
     And he sees the greeting "set up new project now!"

   Scenario: A user who has one or more projects should be able to  
examine the list of projects
     Given a user, "Gary" has 1 project
     When "Gary" clicks on the "dashboard" link
     Then he sees the "project list" page

Wouldn't that make sense?


More information about the rspec-users mailing list