Sha256: 0247fb40f9189fda0e6589262057e0b340c4818370db649fbf37258aa2e2f428

Contents?: true

Size: 1.23 KB

Versions: 5

Compression:

Stored size: 1.23 KB

Contents

require 'rspectacular'

class ProgressableClass
  include ProgressBar::Components::Progressable
end

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

  describe '#running_average' do
    it 'is properly calculated when progress has been made' do
      subject.running_average = 10
      subject.start :at => 0
      expect(subject.running_average).to be_zero

      subject.progress += 40
      expect(subject.running_average).to eql 36.0
    end

    it 'is always reset when the progressable is started' do
      subject.running_average = 10
      subject.start :at => 0
      expect(subject.running_average).to be_zero

      subject.start :at => 40
      expect(subject.running_average).to eql 0.0
    end
  end

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

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

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

      expect(subject.percentage_completed).to eql 100
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/ruby-progressbar-1.5.1/spec/lib/ruby-progressbar/components/progressable_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/ruby-progressbar-1.5.1/spec/lib/ruby-progressbar/components/progressable_spec.rb
ruby-progressbar-1.6.0 spec/lib/ruby-progressbar/components/progressable_spec.rb
ruby-progressbar-1.5.1 spec/lib/ruby-progressbar/components/progressable_spec.rb
ruby-progressbar-1.5.0 spec/lib/ruby-progressbar/components/progressable_spec.rb