Sha256: 37ef68648338731cab61a9a6798f755f54867c06abb60aade1d093d463fe36f5

Contents?: true

Size: 1.47 KB

Versions: 12

Compression:

Stored size: 1.47 KB

Contents

# encoding: utf-8
module WatirSpec
  module Guards

    class << self
      def guards
        @guards ||= Hash.new { |hash, key| hash[key] = [] }
      end

      def record(guard_name, impls, data)
        impls.each do |impl|
          guards[impl] << [guard_name, data]
        end
      end

      def report
        gs = guards[WatirSpec.implementation]
        print "\n\nWatirSpec guards for this implementation: "

        if gs.empty?
         puts "none."
        else
          puts
          gs.each do |guard_name, data|
            puts "\t#{guard_name.to_s.ljust(20)}: #{data.inspect}"
          end
        end
      end
    end

    def deviates_on(*impls)
      Guards.record :deviates, impls, :file => caller.first
      return yield if WatirSpec.unguarded?
      yield if impls.include? WatirSpec.implementation
    end

    def not_compliant_on(*impls)
      Guards.record :not_compliant, impls, :file => caller.first
      return yield if WatirSpec.unguarded?
      yield unless impls.include? WatirSpec.implementation
    end

    def compliant_on(*impls)
      Guards.record :compliant, impls, :file => caller.first
      return yield if WatirSpec.unguarded?
      yield if impls.include? WatirSpec.implementation
    end

    def bug(key, *impls)
      Guards.record :bug, impls, :file => caller.first, :key => key
      return yield if WatirSpec.unguarded?
      yield unless impls.include? WatirSpec.implementation
    end
  end
end

class Object
  include WatirSpec::Guards
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
watir-webdriver-0.0.6 spec/watirspec/lib/guards.rb
watir-webdriver-0.0.5 spec/watirspec/lib/guards.rb
watir-webdriver-0.0.4 spec/watirspec/lib/guards.rb
watir-webdriver-0.0.3 spec/watirspec/lib/guards.rb
watir-webdriver-0.0.2 spec/watirspec/lib/guards.rb
watir-webdriver-0.0.1 spec/watirspec/lib/guards.rb
watir-webdriver-0.0.1.dev7 spec/watirspec/lib/guards.rb
watir-webdriver-0.0.1.dev5 spec/watirspec/lib/guards.rb
watir-webdriver-0.0.1.dev4 spec/watirspec/lib/guards.rb
watir-webdriver-0.0.1.dev3 spec/watirspec/lib/guards.rb
watir-webdriver-0.0.1.dev2 spec/watirspec/lib/guards.rb
watir-webdriver-0.0.1.dev spec/watirspec/lib/guards.rb