Skip to content

Commit

Permalink
Because we're using the formatters, we no longer have to manually upd…
Browse files Browse the repository at this point in the history
…ate the counts after each increment

Conflicts:
	spec/fuubar_spec.rb
  • Loading branch information
jfelchner committed Aug 4, 2012
1 parent 299ab01 commit 1ef8175
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
5 changes: 1 addition & 4 deletions lib/fuubar.rb
Expand Up @@ -4,18 +4,15 @@

class Fuubar < RSpec::Core::Formatters::BaseTextFormatter

attr_reader :example_count, :finished_count
attr_reader :example_count

def start(example_count)
@example_count = example_count
@finished_count = 0
@progress_bar = ProgressBar.create(:format => ' %c/%C |%w>%i| %e ', :total => example_count, :output => output)
end

def increment
with_color do
@finished_count += 1
@progress_bar.title = " #{finished_count}/#{example_count}"
@progress_bar.increment
end
end
Expand Down
13 changes: 2 additions & 11 deletions spec/fuubar_spec.rb
Expand Up @@ -37,10 +37,6 @@
formatter.instance_variable_get(:@example_count).should == 2
end

it 'should set the finished_count to 0' do
formatter.instance_variable_get(:@finished_count).should == 0
end

it 'should set the bar mark to =' do
progress_bar.instance_variable_get(:@bar).progress_mark.should == '='
end
Expand Down Expand Up @@ -114,20 +110,15 @@
formatter.increment
end

it 'should change the progress bar title' do
pending 'should change the progress bar title' do
formatter.stub!(:finished_count).and_return(1)
formatter.stub!(:example_count).and_return(2)
formatter.increment
progress_bar.instance_variable_get(:@title).should == ' 1/2'
end

it 'should increment the finished_count' do
lambda { formatter.increment }.should change(formatter, :finished_count).by(1)
end

it 'should increment the progress bar before updating the title' do
progress_bar.should_receive(:title=).ordered
progress_bar.should_receive(:increment).ordered
progress_bar.should_receive(:increment)
formatter.increment
end

Expand Down

0 comments on commit 1ef8175

Please sign in to comment.