Sha256: fb1ef0ef49ba625290d32c14a100fb5e825f12ede8c3efe746145b7d5c44e559

Contents?: true

Size: 935 Bytes

Versions: 1

Compression:

Stored size: 935 Bytes

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 the value to bytes" do
      g.to_b.should == 3489660928
    end
  end

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

  context "#to_m" do
    it "should convert the value to mega bytes" do
      g.to_m.should == 3328
    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-0.0.1 spec/humanize_bytes/gbyte_spec.rb