[rspec-users] Spec Naming (was: Rspec Brown Bag)

s.ross cwdinfo at gmail.com
Tue Nov 21 14:35:21 EST 2006


I agree with Luke. If you say something "may" happen, you haven't  
asserted any constraints on your program behavior. Unless I  
misunderstand how this was intended. Consider this artificial example:

context "the weather" do
   specify "it should be a gray day (or is that a grey day)" do
     the_sky.should_be :cloudy
     the_ground.may_be :wet
     the_ground.may_be :snowy
   end
end

What do the last two test tell us? Will the specs be demonstrably  
implemented or not as a result of them? As I said, I'm a newbie at  
this, but it makes more sense to me to state this:

context "the weather" do
   specify "it should be a gray day (or is that a grey day)" do
     the_sky.should_be :cloudy
   end

   specify "it should be raining" do
     the_ground.should_be :wet
   end

   specify "it should be snowing" do
     the_ground.may_be :snowy
   end
end

Is that too verbose?

Steve

On Nov 21, 2006, at 9:06 AM, Luke Redpath wrote:

> I'm not sure if that would really work with RSpec - the way I see  
> it, when you say a behaviour is *optional*, what you really  mean  
> is that that behaviour only happens under certain circumstances  
> (i.e. a particular context). Of course this is already handled by  
> setting specifications under certain contexts. Within a particular  
> context a behaviour either happens or it doesn't, I don't think  
> there should be any middle ground. Ultimately we are only concerned  
> with what WILL happen under certain contexts, not things that may  
> or may not happen (which is an observation at a level higher than  
> we are working on).
>
> Cheers
> Luke
>
>> object.must == value # => required; produces error
>> object.should == value # => recommended; produces warning
>> object.may == value # => informational message that an optional  
>> feature is not provided
>>
>> Of course, the utility of this is questionable for RSpec.  It  
>> might be interesting for a tool (not RSpec, but something like it)  
>> that's essentially a portable specification language that can be  
>> applied to more than one implementation.  But now we're not really  
>> talking about BDD, so forgive me for straying OT.
>>
>> Cheers,
>> /Nick
>>
>> [1]: http://tools.ietf.org/html/rfc2119
>> _______________________________________________
>> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20061121/fcb245e0/attachment.html 


More information about the rspec-users mailing list