Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

with_block_device does not yield on windows and freebsd.

  • Loading branch information...
commit a0d2e462a19947c27b0987a617590f42efd5d239 1 parent 7b31bcd
@voxik voxik authored
Showing with 24 additions and 10 deletions.
  1. +6 −2 lib/mspec/guards/block_device.rb
  2. +18 −8 spec/guards/block_device_spec.rb
View
8 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
View
26 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
Please sign in to comment.
Something went wrong with that request. Please try again.