Sha256: 9daba5b4b98166a3aa976b6973c08137f918cf4f4f8499eaf5bfffc3c0578a4d

Contents?: true

Size: 310 Bytes

Versions: 17

Compression:

Stored size: 310 Bytes

Contents

RSpecCandy::Switcher.define_matcher :be_same_number_as do |expected|

  match do |actual|
    actual.is_a?(Numeric) && expected.is_a?(Numeric) && normalize(expected) == normalize(actual)
  end

  def normalize(number)
    number.to_s.tap do |str|
      str << ".0" unless str.include?('.')
    end
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rspec_candy-0.5.1 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.5.0 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.4.1 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.4.0 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.3.1 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.3.0 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.2.10 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.2.9 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.2.8 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.2.7 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.2.6 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.2.5 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.2.4 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.2.3 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.2.2 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.2.1 lib/rspec_candy/matchers/be_same_number_as.rb
rspec_candy-0.2.0 lib/rspec_candy/matchers/be_same_number_as.rb