Sha256: 46138d12a8a31f6e41a4e76406cae81e3031a3ed99bea51d298b54c819d4881d

Contents?: true

Size: 899 Bytes

Versions: 55

Compression:

Stored size: 899 Bytes

Contents

require 'mspec/guards/guard'

class PlatformGuard < SpecGuard
  def self.windows?
    PlatformGuard.new(:os => :windows).match?
  end

  def initialize(*args)
    if args.last.is_a?(Hash)
      @options, @platforms = args.last, args[0..-2]
    else
      @options, @platforms = {}, args
    end
    self.parameters = args
  end

  def match?
    match = @platforms.empty? ? true : platform?(*@platforms)
    @options.each do |key, value|
      case key
      when :os
        match &&= os?(*value)
      when :wordsize
        match &&= wordsize? value
      end
    end
    match
  end
end

class Object
  def platform_is(*args)
    g = PlatformGuard.new(*args)
    g.name = :platform_is
    yield if g.yield?
  ensure
    g.unregister
  end

  def platform_is_not(*args)
    g = PlatformGuard.new(*args)
    g.name = :platform_is_not
    yield if g.yield? true
  ensure
    g.unregister
  end
end

Version data entries

55 entries across 55 versions & 3 rubygems

Version Path
rhodes-5.5.18 lib/extensions/mspec/mspec/guards/platform.rb
rhodes-5.5.17 lib/extensions/mspec/mspec/guards/platform.rb
rhodes-5.5.15 lib/extensions/mspec/mspec/guards/platform.rb
rhodes-5.5.0.22 lib/extensions/mspec/mspec/guards/platform.rb
rhodes-5.5.2 lib/extensions/mspec/mspec/guards/platform.rb
rhodes-5.5.0.7 lib/extensions/mspec/mspec/guards/platform.rb
rhodes-5.5.0.3 lib/extensions/mspec/mspec/guards/platform.rb
rhodes-5.5.0 lib/extensions/mspec/mspec/guards/platform.rb
tauplatform-1.0.3 lib/extensions/mspec/mspec/guards/platform.rb
tauplatform-1.0.2 lib/extensions/mspec/mspec/guards/platform.rb
tauplatform-1.0.1 lib/extensions/mspec/mspec/guards/platform.rb
mspec-1.7.0 lib/mspec/guards/platform.rb
mspec-1.6.0 lib/mspec/guards/platform.rb
mspec-1.5.21 lib/mspec/guards/platform.rb
mspec-1.5.20 lib/mspec/guards/platform.rb
mspec-1.5.19 lib/mspec/guards/platform.rb
mspec-1.5.18 lib/mspec/guards/platform.rb
rhodes-3.5.1.12 lib/extensions/mspec/mspec/guards/platform.rb
rhodes-3.3.5 lib/extensions/mspec/mspec/guards/platform.rb
rhodes-3.4.2 lib/extensions/mspec/mspec/guards/platform.rb