Sha256: 16c3f06088510f5b97b2cb3b341c93fc5764c6524ebe2d85cb95a0b0109b1637

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe Humanize::Bytes::Giga do
  let(:g) { Humanize::Bytes::Giga.new(3.25) }

  context "#value" do
    it "should return the value" do
      g.value.should == 3.25
    end
  end

  context "#to_b" do
    it "should convert to Bytes" do
      g.to_b.class.should be Byte
    end 
    it "should convert the value to Byte" do
      g.to_b.value.should == 3489660928
    end
  end

  context "#to_k" do
    it "should convert to Kilo bytes" do
      g.to_k.class.should be Kilo
    end 
    it "should convert the value to Kilo bytes" do
      g.to_k.value.should == 3407872
    end
  end

  context "#to_m" do
    it "should convert to Mega bytes" do
      g.to_m.class.should be Mega
    end
    it "should convert the value to Mega bytes" do
      g.to_m.value.should == 3328
    end
  end

  context "#to_g" do
    it "should return self" do
      g.to_g.should be g
    end
  end

  context "#to_s" do
    context "when value is a decimal" do
      it "should print a humanized version of the value" do
        g.to_s.should == '3.25 giga bytes'
      end
    end

    context "when value is an integer" do
      it "should print a humanized version of the value" do
        Humanize::Bytes::Giga.new(4).to_s.should == '4 giga bytes'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
humanize-bytes-1.0.0 spec/humanize_bytes/gbyte_spec.rb