Sha256: 0f8d7f77532b847459ceab8143b6aaf8dc1043b54d5a4ee085a77f3d7084f2a6

Contents?: true

Size: 979 Bytes

Versions: 11

Compression:

Stored size: 979 Bytes

Contents

require 'spec_helper'

class ProgressableClass
  include ProgressBar::Components::Progressable
end

describe ProgressBar::Components::Progressable do
  subject { ProgressableClass.new }

  describe '#running_average' do
    it 'is always reset when the progressable is started' do
      subject.running_average = 10
      subject.start :at => 0
      subject.running_average.should be_zero

      subject.start :at => 40
      subject.running_average.should eql 36.0
    end
  end

  describe '#smoothing' do
    it 'can be passed in as an option to the initializer' do
      ProgressableClass.new(:smoothing => 0.3).smoothing.should eql 0.3
    end

    it 'does not have to be passed in as an option to the initializer' do
      ProgressableClass.new.smoothing.should eql 0.1
    end
  end

  describe '#percentage_completed' do
    it 'returns the default total if total is zero' do
      subject.total = 0

      subject.percentage_completed.should eql 100
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
ruby-progressbar-1.4.2 spec/lib/ruby-progressbar/components/progressable_spec.rb
ruby-progressbar-1.4.1 spec/lib/ruby-progressbar/components/progressable_spec.rb
ruby-progressbar-1.4.0 spec/lib/ruby-progressbar/components/progressable_spec.rb
ruby-progressbar-1.3.2 spec/lib/ruby-progressbar/components/progressable_spec.rb
ruby-progressbar-1.3.1 spec/lib/ruby-progressbar/components/progressable_spec.rb
ruby-progressbar-1.3.0 spec/lib/ruby-progressbar/components/progressable_spec.rb
ruby-progressbar-1.2.0 spec/lib/ruby-progressbar/components/progressable_spec.rb
ruby-progressbar-1.1.1 spec/progress_bar/components/progressable_spec.rb
ruby-progressbar-1.1.0 spec/progress_bar/components/progressable_spec.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/ruby-progressbar-1.0.2/spec/progress_bar/components/progressable_spec.rb
ruby-progressbar-1.0.2 spec/progress_bar/components/progressable_spec.rb