Sha256: 070d997af7fc6df8b54dd7be89a307f3e805380e4366f4fc4eedd949002235c2

Contents?: true

Size: 580 Bytes

Versions: 15

Compression:

Stored size: 580 Bytes

Contents

class InfinityMatcher
  def initialize(expected_sign)
    @expected_sign = expected_sign
  end

  def matches?(actual)
    @actual = actual
    @actual.kind_of?(Float) && @actual.infinite? == @expected_sign
  end

  def failure_message
    ["Expected #{@actual}", "to be #{"-" if @expected_sign == -1}Infinity"]
  end

  def negative_failure_message
    ["Expected #{@actual}", "not to be #{"-" if @expected_sign == -1}Infinity"]
  end
end

class Object
  def be_positive_infinity
    InfinityMatcher.new(1)
  end

  def be_negative_infinity
    InfinityMatcher.new(-1)
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
rhodes-7.6.0 lib/extensions/mspec/mspec/matchers/infinity.rb
rhodes-7.5.1 lib/extensions/mspec/mspec/matchers/infinity.rb
rhodes-7.4.1 lib/extensions/mspec/mspec/matchers/infinity.rb
rhodes-7.1.17 lib/extensions/mspec/mspec/matchers/infinity.rb
rhodes-6.2.0 lib/extensions/mspec/mspec/matchers/infinity.rb
rhodes-6.0.11 lib/extensions/mspec/mspec/matchers/infinity.rb
mspec-1.9.1 lib/mspec/matchers/infinity.rb
mspec-1.9.0 lib/mspec/matchers/infinity.rb
mspec-1.8.0 lib/mspec/matchers/infinity.rb
mspec-1.7.0 lib/mspec/matchers/infinity.rb
mspec-1.6.0 lib/mspec/matchers/infinity.rb
mspec-1.5.21 lib/mspec/matchers/infinity.rb
mspec-1.5.20 lib/mspec/matchers/infinity.rb
mspec-1.5.19 lib/mspec/matchers/infinity.rb
mspec-1.5.18 lib/mspec/matchers/infinity.rb