Sha256: 8c1bb7b67a5b7f89437fb2bc6651182f77a268eca8b3e766d27e648c58cc5784

Contents?: true

Size: 513 Bytes

Versions: 37

Compression:

Stored size: 513 Bytes

Contents

require 'roqua/core_ext/fixnum/clamp'

describe Fixnum do
  describe '#clamp' do
    it "returns self if within bounds" do
      5.clamp(1,10).should == 5
    end

    it "returns the lower bound if self < low" do
      5.clamp(8,10).should == 8
    end

    it "returns the upper bound if self > high" do
      5.clamp(1,3).should == 3
    end

    it "should raise an exception if the lower bound is greater than the upper bound" do
      expect {
        5.clamp(10,1)
      }.to raise_error
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
roqua-support-0.1.14 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.13 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.12 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.11 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.10 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.9 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.8 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.7 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.6 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.5 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.4 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.3 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.2.2 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.2.1 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.2 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.1 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.0 spec/roqua/core_ext/fixnum/clamp_spec.rb