On Sep 25, 2008, at 4:50 PM, Wincent Colaiuta wrote:

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

Just wrap your platform dependent specs in an "if". I used to have specs which would fail on ruby 1.8.5, and so I did something like the following:

unless on_ruby_1_8_5?
  it "should..." { }
end

Scott







_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to