Sha256: b9e59ea3a832e3ea6fd811a49fce61d2f14158b266882251dbd6a4f935b35679

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

# encoding: utf-8
#
# This file is part of the cowtech-extensions gem. Copyright (C) 2011 and above Shogun <shogun_panda@me.com>.
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
#

require "spec_helper"

describe Cowtech::Extensions::Math do
  let(:first) { 1 }
  let(:second) { 2 }
  let(:third) { 0 }

  before(:all) do
    ::Cowtech::Extensions.load!
  end

  describe "::min" do
    it "should return the minimum argument" do
      ::Math.min(first).should == first
      ::Math.min(first, second).should == first
      ::Math.min([first, [second, third]]).should == third
    end

    it "should return nil for an empty array" do
      ::Math.min().should be_nil
    end
  end

  describe "::max" do
    it "should return the maximum argument" do
      ::Math.max(first).should == first
      ::Math.max(first, second).should == second
      ::Math.max([first, [second, third]]).should == second
    end

    it "should return nil for an empty array" do
      ::Math.max().should be_nil
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cowtech-extensions-2.7.1 spec/cowtech-extensions/math_spec.rb
cowtech-extensions-2.7.0 spec/cowtech-extensions/math_spec.rb
cowtech-extensions-2.6.0 spec/cowtech-extensions/math_spec.rb
cowtech-extensions-2.5.1 spec/cowtech-extensions/math_spec.rb
cowtech-extensions-2.5.0 spec/cowtech-extensions/math_spec.rb