Sha256: 34449e4323076aaf040f962432a6e13635d67a10ec7790d14cd9b7ace2710f5c
Contents?: true
Size: 952 Bytes
Versions: 3
Compression:
Stored size: 952 Bytes
Contents
require 'mspec/guards/guard' class PlatformGuard < SpecGuard def self.windows? PlatformGuard.new(:os => :windows).match? end def self.opal? PlatformGuard.new(:opal) 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mspec-1.9.1 | lib/mspec/guards/platform.rb |
mspec-1.9.0 | lib/mspec/guards/platform.rb |
mspec-1.8.0 | lib/mspec/guards/platform.rb |