[rspec-users] Conditionally turning some specs on and off depending on runtime platform

Wincent Colaiuta win at wincent.com
Thu Sep 25 16:50:23 EDT 2008


Hi folks,

Wondering what the best (that is, neatest and most supported) way to  
conditionally turn off some specs depending on the runtime platform.

Background: some of my specs call out to some third-party tools that  
may or may not be installed on the system. I'd like to check for the  
presence of those tools and gracefully skip those specs rather than  
just bombing out.

The following trick, calling "pending" from inside the before block,  
effectively does what I want. But I'm wondering if I can count on this  
behaviour going forward? What do you think?

   describe 'Something' do
     before do
       if required_tools_not_installed
         pending 'not running on this platform'
       end
     end

     it 'should do something' do
       1.should == 1
     end
   end

Cheers,
Wincent





More information about the rspec-users mailing list