diff --git a/lib/mspec/guards/block_device.rb b/lib/mspec/guards/block_device.rb index 0dc252e3..f33333f7 100644 --- a/lib/mspec/guards/block_device.rb +++ b/lib/mspec/guards/block_device.rb @@ -2,8 +2,12 @@ class BlockDeviceGuard < SpecGuard def match? - block = `find /dev /devices -type b 2> /dev/null` - !(block.nil? || block.empty?) + platform_is_not :freebsd, :windows do + block = `find /dev /devices -type b 2> /dev/null` + return !(block.nil? || block.empty?) + end + + false end end diff --git a/spec/guards/block_device_spec.rb b/spec/guards/block_device_spec.rb index 44fb9fa3..2d748e9f 100644 --- a/spec/guards/block_device_spec.rb +++ b/spec/guards/block_device_spec.rb @@ -9,16 +9,26 @@ BlockDeviceGuard.stub!(:new).and_return(@guard) end - it "yields if block device is available" do - @guard.should_receive(:`).and_return("block devices") - with_block_device { ScratchPad.record :yield } - ScratchPad.recorded.should == :yield + platform_is_not :freebsd, :windows do + it "yields if block device is available" do + @guard.should_receive(:`).and_return("block devices") + with_block_device { ScratchPad.record :yield } + ScratchPad.recorded.should == :yield + end + + it "does not yield if block device is not available" do + @guard.should_receive(:`).and_return(nil) + with_block_device { ScratchPad.record :yield } + ScratchPad.recorded.should_not == :yield + end end - it "does not yield if block device is not available" do - @guard.should_receive(:`).and_return(nil) - with_block_device { ScratchPad.record :yield } - ScratchPad.recorded.should_not == :yield + platform_is :freebsd, :windows do + it "does not yield, since platform does not support block devices" do + @guard.should_not_receive(:`) + with_block_device { ScratchPad.record :yield } + ScratchPad.recorded.should_not == :yield + end end it "sets the name of the guard to :with_block_device" do