Sha256: c33e1c1d7db78e8a73ec61997a81bea36ed750caf7d0dab2388a53e1eaa77140

Contents?: true

Size: 1.55 KB

Versions: 6

Compression:

Stored size: 1.55 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

describe Hash do
  it "limit_to_keys should limit keys in hash" do
    h = {:bro1=>'me',:bro2=>'rob',:bro3=>'eric'}
    h.limit_to_keys([:bro1,:bro2]).should == {:bro1=>'me',:bro2=>'rob'}
    h.should == {:bro1=>'me',:bro2=>'rob',:bro3=>'eric'}
  end

  it "limit_to_keys! should destructively limit keys in hash" do
    h = {:bro1=>'me',:bro2=>'rob',:bro3=>'eric'}
    h.limit_to_keys!([:bro1,:bro2]).should == {:bro1=>'me',:bro2=>'rob'}
    h.should == {:bro1=>'me',:bro2=>'rob'}
  end

  it "soft deletes" do
    h = {:dan=>1,:eric=>2}
    h.soft_delete(:dan).should == {:eric=>2}
  end
end

describe Integer do
  it "should return the number divided by 100 as a float" do
    i = 1000043
    i.as_cost.should == 10000.43
  end

  it "should return the number in hundredths" do
    i = 10343
    i.in_hundredths.should == 172.38
  end
end

describe Float do
  it "should return the number divided by 100" do
    i = 1000043.0
    i.as_cost.should == 10000.430
  end

  it "should return the number in hundredths" do
    i = 10343.56
    i.in_hundredths.should == 172.39
  end
end

describe Range do
  it "method split_by_step creates ranges out of original range by step" do
    range = 0..30
    range.split_by_step(10).should == [0..10,11..21,22..30]
    range = 1..101
    range.split_by_step(25).should == [1..26,27..52,53..78,79..101]
    range = 0..20
    range.split_by_step(20).should == [0..20]
    range = 1..2
    range.split_by_step(3).should == [1..2]
    range = 1..1
    range.split_by_step(10).should == [1..1]
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fossil-0.5.32 spec/core_extensions_spec.rb
fossil-0.5.31 spec/core_extensions_spec.rb
fossil-0.5.30 spec/core_extensions_spec.rb
fossil-0.5.29 spec/core_extensions_spec.rb
fossil-0.5.28 spec/core_extensions_spec.rb
fossil-0.5.27 spec/core_extensions_spec.rb