Sha256: a96effc6aa666465130c37826ab3aab2e9c974915a7bc779da6eddcbf562bbef

Contents?: true

Size: 1.27 KB

Versions: 9

Compression:

Stored size: 1.27 KB

Contents

Spec::Runner.configure do |config| #:nodoc:
  config.include(WatirSplash::SpecHelper)

  config.before(:all) do
    open_browser_at "about:blank"
  end

  config.after(:all) do
    close
  end
end

module Spec #:nodoc:all
  class ExampleGroup
    subject {self}
  end

  module Example
    class ExampleGroupProxy
      attr_accessor :description
    end

    class ExampleProxy
      attr_accessor :description
    end
  end
end

# match_array is useful for matching arrays where some elements are regular expressions.
#    expected_array = ["1", "2", /\d+/, "3"]
#
#    ["1", "2", "66", "3"].should match_array(expected_array)
#    table(:id => "table_id").to_a.should match_array(expected_array)
Spec::Matchers.define :match_array do |array2|
  match do |array1|
    raise "match_array works only with Array objects!" unless array1.is_a?(Array) && array2.is_a?(Array)
    match?(array1, array2)
  end

  def match?(array1, array2)
    array2.each_with_index do |element, i|
      if element.is_a?(Array)
        return false unless match?(array1[i], element)
      elsif element.is_a?(Regexp)
        return false unless array1[i] =~ element
      else
        return false unless array1[i] == element
      end
    end

    true
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
watirsplash-0.2.14 lib/watirsplash/spec.rb
watirsplash-0.2.12 lib/watirsplash/spec.rb
watirsplash-0.2.11 lib/watirsplash/spec.rb
watirsplash-0.2.10 lib/watirsplash/spec.rb
watirsplash-0.2.9 lib/watirsplash/spec.rb
watirsplash-0.2.8 lib/watirsplash/spec.rb
watirsplash-0.2.7 lib/watirsplash/spec.rb
watirsplash-0.2.6 lib/watirsplash/spec.rb
watirsplash-0.2.5 lib/watirsplash/spec.rb