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.34 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.33 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.32 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.31 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.30 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.29 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.28 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.27 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.26 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.25 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.24 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.23 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.22 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.21 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.20 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.19 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.18 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.17 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.16 spec/roqua/core_ext/fixnum/clamp_spec.rb
roqua-support-0.1.15 spec/roqua/core_ext/fixnum/clamp_spec.rb