summaryrefslogtreecommitdiff
path: root/spec/mspec/lib/mspec/guards/block_device.rb
blob: ae736a2d4ebd103fb4e5b5664dde209f65498f14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require 'mspec/guards/guard'

class BlockDeviceGuard < SpecGuard
  def match?
    platform_is_not :freebsd, :windows, :opal do
      block = `find /dev /devices -type b 2> /dev/null`
      return !(block.nil? || block.empty?)
    end

    false
  end
end

def with_block_device(&block)
  BlockDeviceGuard.new.run_if(:with_block_device, &block)
end