Sha256: 9f539a855bf04085be7063221df49529b70a3816138124ce7bb98c728e3eb28b

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(0)
    }.should raise_error(ProgressBar::ArgumentError)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
progress_bar-1.0.5 spec/arguments_spec.rb
progress_bar-1.0.4 spec/arguments_spec.rb
progress_bar-1.0.3 spec/arguments_spec.rb
progress_bar-1.0.2 spec/arguments_spec.rb