[rspec-users] Helper methods starting with should_ get picked up as examples?

Peter Marklund peter_marklund at fastmail.fm
Wed Nov 7 04:33:58 EST 2007


Hi!
I recently updated my rspec and rspec_on_rails plugins to the tip of  
the trunk and ran into an issue with helper methods with names  
starting with should_ in my describe blocks. Fictive example to show  
what I'm talking about:

describe Order do
    it "Can be paid for" do
     ...
     should_have_paid(user)
   end

   def should_have_paid(user)

   end
end

I know in some places I should (ah, there is that word again...) be  
using custom matchers when I'm being lazy and instead just defining  
methods. Anyway, it seems RSpec picks up methods starting with  
should_ as examples. Here is some debug output that I generated for a  
method called should_have_emailed:

#<Spec::DSL::ExampleDefinition:0x3383bfc @example_block=#<Proc: 
0x003f0250@/Users/peter/src/gear/specialist/vendor/plugins/rspec/lib/ 
spec/dsl/example.rb:27>, @from="/Users/peter/src/gear/specialist/ 
vendor/plugins/rspec/lib/spec/dsl/example.rb:22:in `each'",  
@description="should_have_emailed", @options={}>

Is this itentional behaviour by RSpec or some weird side effect?

Cheers

Peter

----------------------------
Peter Marklund
Garvar Lundins Gränd 7
11220 Stockholm
Sweden

Mobile Phone: +46-(0)70-4164857
Home Phone: +46-(0)8-50091315
Skype: peter_marklund

IM: AIM - petermarklund, MSN - peter_marklund at hotmail.com, Yahoo -  
peter_marklund2002

http://marklunds.com
----------------------------





More information about the rspec-users mailing list