spec/arguments_spec.rb in progress_bar-1.3.1 vs spec/arguments_spec.rb in progress_bar-1.3.2

- old
+ new

@@ -1,40 +1,37 @@ -require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) +# frozen_string_literal: true -describe 'ProgressBar arguments' do - before do - @default_max = 100 - @default_meters = [:bar, :counter, :percentage, :elapsed, :eta, :rate] - end +require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper")) +describe "ProgressBar arguments" do + let(:default_max) { 100 } + let(:default_meters) { [:bar, :counter, :percentage, :elapsed, :eta, :rate] } + it "should set appropriate defaults without any arguments" do bar = ProgressBar.new - bar.max.should == @default_max - bar.meters.should == @default_meters + expect(bar.max).to eq default_max + expect(bar.meters).to eq 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 + expect(bar.max).to eq 123 + expect(bar.meters).to eq 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] + expect(bar.max).to eq default_max + expect(bar.meters).to eq [: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] + expect(bar.max).to eq 123 + expect(bar.meters).to eq [:bar, :eta] end it "should raise an error when initial max is nonsense" do - lambda { - bar = ProgressBar.new(-1) - }.should raise_error(ProgressBar::ArgumentError) + expect { ProgressBar.new(-1) } + .to raise_error(ProgressBar::ArgumentError) end - end -