Properly suppressing output and testing progress bar

dev
Andy Meneely 2014-08-05 22:51:43 -04:00
parent 6c31320411
commit f9c572116d
4 changed files with 7 additions and 4 deletions

View File

@ -6,7 +6,9 @@ module Squib
# @api private # @api private
class DoNothing class DoNothing
def increment def increment
#do nothing! end
def finish
end end
end end
@ -22,7 +24,7 @@ module Squib
end end
def start(title="", total=100, &block) def start(title="", total=100, &block)
if @enabled && !(ENV['IN_TEST'].eql? "true") if @enabled
@bar = ProgressBar.create(title: title, total: total, format: '%t <%B> %p%% %a') @bar = ProgressBar.create(title: title, total: total, format: '%t <%B> %p%% %a')
yield(@bar) yield(@bar)
@bar.finish @bar.finish

View File

@ -6,6 +6,8 @@ describe Squib do
context "all samples run without error" do context "all samples run without error" do
it "should execute with no errors" do it "should execute with no errors" do
p = double("ProgressBar")
allow(ProgressBar).to receive(:create).and_return(Squib::DoNothing.new)
samples = File.expand_path('../samples', File.dirname(__FILE__)) samples = File.expand_path('../samples', File.dirname(__FILE__))
Dir["#{samples}/**/*.rb"].each do |sample| Dir["#{samples}/**/*.rb"].each do |sample|
Dir.chdir(samples) do #to save to _output Dir.chdir(samples) do #to save to _output

View File

@ -1,8 +1,6 @@
require 'simplecov' require 'simplecov'
require 'coveralls' require 'coveralls'
ENV['IN_TEST']="true"
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter Coveralls::SimpleCov::Formatter

View File

@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.6" spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "rake" spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 3.0" spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rspec-mocks", "~> 3.0"
spec.add_development_dependency "redcarpet", '~> 3.1.2' spec.add_development_dependency "redcarpet", '~> 3.1.2'
spec.add_development_dependency "github-markup", '~> 1.2.1' spec.add_development_dependency "github-markup", '~> 1.2.1'
spec.add_development_dependency "yard" spec.add_development_dependency "yard"