Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Remove instafail dependency #33

Closed
wants to merge 14 commits into from

1 participant

Jeff Felchner
Jeff Felchner
Owner

@jeffkreeftmeijer I saw this referenced in issues #29 and #20 so I thought I'd give you a bonus. :)

I didn't do any extensive testing and I did leave the specs in a failing state (for shame!). I basically just wanted to see if I could get it to work.

Everything appears to work just as if instafail was installed although I didn't do extensive testing. I just thought I'd put this out there.

Also, this is based on update-ruby-progressbar-to-v1 so I'd either cherry pick these commits or merge that branch in first.

Jeff Felchner jfelchner referenced this pull request from a commit
Jeff Felchner jfelchner Merge branch 'feature/remove-rspec-instafail' into develop - Closes #36
…, #29, #20, #33

* feature/remove-rspec-instafail:
  Big refactoring to use the capabilities exposed by RSpec's formatters as well as replacing the specs with ones which are more representative
  Add .ruby-version file
  Use RSpec's helpers to output the failures at the proper time
  Remove all references to instafail
  Remove rspec-instafail from the project
14a7d93
Jeff Felchner jfelchner closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 4, 2012
  1. Jeff Felchner
  2. Jeff Felchner
  3. Jeff Felchner
  4. Jeff Felchner

    Use the new ruby-progressbar formatters for MOAR AWESOME!!!1!

    jfelchner authored
    Outputs a bar similar to: " 10/100 |=== 10 ==>                                   |  ETA: 10:10:10 "
  5. Jeff Felchner

    Because we're using the formatters, we no longer have to manually upd…

    jfelchner authored
    …ate the counts after each increment
    
    Conflicts:
    	spec/fuubar_spec.rb
  6. Jeff Felchner

    Now the the ProgressBar is in charge of keeping track of progress and…

    jfelchner authored
    … total, we don't need to cross boundaries to spec this
  7. Jeff Felchner

    ProgressBars finish themselves as soon as the progress equals the tot…

    jfelchner authored
    …al so we no longer need to explicitly finish the bar
  8. Jeff Felchner

    Whitespace

    jfelchner authored
  9. Jeff Felchner
  10. Jeff Felchner

    Setting the example_count is handled in the super class and has been …

    jfelchner authored
    …since v2.0 so we can just rely on calling `super`
  11. Jeff Felchner
  12. Jeff Felchner
  13. Jeff Felchner
  14. Jeff Felchner
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 77 deletions.
  1. +1 −2  fuubar.gemspec
  2. +6 −20 lib/fuubar.rb
  3. +14 −55 spec/fuubar_spec.rb
3  fuubar.gemspec
View
@@ -18,6 +18,5 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.add_dependency('rspec', ["~> 2.0"])
- s.add_dependency('ruby-progressbar', ["~> 0.0.10"])
- s.add_dependency('rspec-instafail', ["~> 0.2.0"])
+ s.add_dependency('ruby-progressbar', ["~> 1.0.0rc1"])
end
26 lib/fuubar.rb
View
@@ -1,23 +1,16 @@
require 'rspec/core/formatters/base_text_formatter'
-require 'progressbar'
-require 'rspec/instafail'
+require 'ruby-progressbar'
class Fuubar < RSpec::Core::Formatters::BaseTextFormatter
- attr_reader :example_count, :finished_count
-
def start(example_count)
- @example_count = example_count
- @finished_count = 0
- @progress_bar = ProgressBar.new(" #{example_count} examples", example_count, output)
- @progress_bar.bar_mark = '='
+ super
+ @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.instance_variable_set("@title", " #{finished_count}/#{example_count}")
- @progress_bar.inc
+ @progress_bar.increment
end
end
@@ -37,24 +30,17 @@ def example_failed(example)
@state = :red
output.print "\e[K"
- instafail.example_failed(example)
+ dump_failure(example, @failed_examples.count - 1)
+ dump_backtrace(example)
output.puts
increment
end
- def start_dump
- with_color { @progress_bar.finish }
- end
-
def dump_failures
# don't!
end
- def instafail
- @instafail ||= RSpec::Instafail.new(output)
- end
-
def with_color
output.print "\e[#{colors[state]}m" if color_enabled?
yield
69 spec/fuubar_spec.rb
View
@@ -18,31 +18,23 @@
describe 'start' do
it 'should create a new ProgressBar' do
- progress_bar.should be_instance_of ProgressBar
+ progress_bar.should be_instance_of ProgressBar::Base
end
- it 'should set the title' do
- progress_bar.instance_variable_get(:@title).should == ' 2 examples'
+ it 'should set the format of the bar' do
+ progress_bar.instance_variable_get(:@format_string).should == ' %c/%C |%w>%i| %e '
end
it 'should set the total amount of specs' do
- progress_bar.instance_variable_get(:@total).should == 2
+ progress_bar.total.should == 2
end
it 'should set the output' do
- progress_bar.instance_variable_get(:@out).should == formatter.output
- end
-
- it 'should set the example_count' do
- 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
+ progress_bar.send(:output).should == formatter.output
end
it 'should set the bar mark to =' do
- progress_bar.instance_variable_get(:@bar_mark).should == '='
+ progress_bar.instance_variable_get(:@bar).progress_mark.should == '='
end
end
@@ -84,17 +76,18 @@
describe 'example_failed' do
- before do
- formatter.instafail.stub!(:example_failed)
- end
-
it 'should call the increment method' do
formatter.should_receive :increment
formatter.example_failed(example)
end
- it 'should call instafail.example_failed' do
- formatter.instafail.should_receive(:example_failed).with(example)
+ it 'should dump the failure' do
+ formatter.should_receive :dump_failure
+ formatter.example_failed(example)
+ end
+
+ it 'should dump the backtrace' do
+ formatter.should_receive :dump_backtrace
formatter.example_failed(example)
end
@@ -110,44 +103,10 @@
describe 'increment' do
it 'should increment the progress bar' do
- progress_bar.should_receive(:inc)
+ progress_bar.should_receive(:increment)
formatter.increment
end
- it '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(:instance_variable_set).ordered
- progress_bar.should_receive(:inc).ordered
- formatter.increment
- end
-
- end
-
- describe 'instafail' do
-
- it 'should be an instance of RSpec::Instafail' do
- formatter.instafail.should be_instance_of(RSpec::Instafail)
- end
-
- end
-
- describe 'start_dump' do
-
- it 'should finish the progress bar' do
- progress_bar.should_receive(:finish)
- formatter.start_dump
- end
-
end
describe 'state' do
Something went wrong with that request. Please try again.