summaryrefslogtreecommitdiff
path: root/spec/mspec/lib/mspec/guards/block_device.rb
blob: 327f6e564eca5f2763db5d99d06273d84d79054f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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

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