Sha256: d1c08f70bad4aecb243304c1f1c52412a225a253590d7d297175c61399825bea

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))

describe 'ProgressBar arguments' do
  before do
    @default_max = 100
    @default_meters = [:bar, :counter, :percentage, :elapsed, :eta, :rate]
  end

  it "should set appropriate defaults without any arguments" do
    bar = ProgressBar.new
    bar.max.should == @default_max
    bar.meters.should == @default_meters
  end

  it "should allow a single argument specifying the max" do
    bar = ProgressBar.new(123)
    bar.max.should == 123
    bar.meters.should == @default_meters
  end

  it "should allow specifying just the meters" do
    bar = ProgressBar.new(:bar, :eta)
    bar.max.should == @default_max
    bar.meters.should == [:bar, :eta]
  end

  it "should allow specyfing the max and meters" do
    bar = ProgressBar.new(123, :bar, :eta)
    bar.max.should == 123
    bar.meters.should == [:bar, :eta]
  end

  it "should raise an error when initial max is nonsense" do
    lambda {
      bar = ProgressBar.new(-1)
    }.should raise_error(ProgressBar::ArgumentError)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
progress_bar-1.3.1 spec/arguments_spec.rb
progress_bar-1.3.0 spec/arguments_spec.rb
progress_bar-1.2.0 spec/arguments_spec.rb
progress_bar-1.1.0 spec/arguments_spec.rb