Sha256: 100661a0c2e8f33a53d70cf12c13c3d3b23bea1adfd749369d740d30b8a2f07c

Contents?: true

Size: 561 Bytes

Versions: 1

Compression:

Stored size: 561 Bytes

Contents

require 'date'

def coerce_value(value)
  # what is this, PHP?
  if value.nil?
    nil
  elsif value == 'true'
    true
  elsif value == 'false'
    false
  elsif value =~ /\d+\.\d+/
    value.to_f
  elsif value =~ /^\d+$/
    value.to_i
  else
    value
  end
end

def compare_values(a, b)
  if b.nil?
    a.should be_nil
  elsif a.is_a? Date or a.is_a? Time
    b = Date.parse b
    a.should == b
  elsif b =~ /\d+\.\d+/
    b = b.to_f
    a.should be_close(b, 0.00001)
  elsif b =~ /^\d+$/
    b = b.to_i
    a.should == b
  else
    a.should == b
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sniff-0.1.2 lib/test_support/cucumber/support/values.rb