Sha256: 16c4c96779a0688b4168c661910f9798d3b4f567683bd3783c7ea9a8489af535

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

require 'spec_helper'

describe Throttle::Bandwidth do
  before do
    class Bandwidth
      extend Throttle::Bandwidth
    end  
  end  
  
  it "should return nil on invalid string" do
    Bandwidth.parse_bandwidth('notabandwidthstring').must_be_nil
  end
  
  it "should return correct bandwidth on properly formed string" do
    Bandwidth.parse_bandwidth('400 Kbps').must_equal('400Kbp/s')
  end  
  
  it "should cap at 268MBp/s" do
    Bandwidth.parse_bandwidth('10000 MBps').must_equal('268MBp/s')
    Bandwidth.parse_bandwidth('9999999 KBps').must_equal('268MBp/s')
  end  
  
  it "should properly format a messy string" do
    Bandwidth.parse_bandwidth('5  Kbp').must_equal('5Kbp/s')
  end  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
throttle-0.0.2 spec/throttle/bandwidth_spec.rb