Sha256: 220da8cfb7654e7671e9712a7dfb77c201700c10a98e7797abe0b0d93c607a0a

Contents?: true

Size: 1.2 KB

Versions: 10

Compression:

Stored size: 1.2 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'fog'))
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'fog', 'bin'))

if ENV["FOG_MOCK"] == "true"
  Fog.mock!
end

def has_error(error, &block)
  begin
    yield
    @formatador.display_line("[red]did not raise #{error}[/]")
    false
  rescue error
    true
  end
end

def has_format(original_data, original_format)
  valid = true
  data = original_data.dup
  format = original_format.dup
  for key, value in format
    valid &&= data.has_key?(key)
    datum = data.delete(key)
    format.delete(key)
    case value
    when Array
      valid &&= datum.is_a?(Array)
      for element in datum
        type = value.first
        if type.is_a?(Hash)
          valid &&= has_format({:element => element}, {:element => type})
        else
          valid &&= element.is_a?(type)
        end
      end
    when Hash
      valid &&= datum.is_a?(Hash)
      valid &&= has_format(datum, value)
    else
      valid &&= datum.is_a?(value)
    end
  end
  valid &&= data.empty? && format.empty?
  unless valid
    @formatador.display_line("[red]#{original_data.inspect} does not match #{original_format.inspect}[/]")
  end
  valid
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fog-0.1.0 tests/helper.rb
fog-0.0.100 tests/helper.rb
fog-0.0.99 tests/helper.rb
fog-0.0.98 tests/helper.rb
fog-0.0.97 tests/helper.rb
fog-0.0.96 tests/helper.rb
fog-0.0.95 tests/helper.rb
fog-0.0.94 tests/helper.rb
fog-0.0.93 tests/helper.rb
fog-0.0.92 tests/helper.rb