Browse files

Import Bacon color extension.

  • Loading branch information...
1 parent 69de5e8 commit 02a5210151dffc47dea45e24ceb5090c1904afb5 @alloy alloy committed Mar 27, 2012
Showing with 55 additions and 7 deletions.
  1. +1 −1 .kick
  2. +11 −6 spec/spec_helper.rb
  3. +43 −0 spec/spec_helper/color_output.rb
View
2 .kick
@@ -6,7 +6,7 @@ process do |files|
specs = files.take_and_map do |file|
case file
when %r{lib/cocoapods/installer.+\.rb$}
- 'spec/unit/installer_spec.rb'
+ ['spec/unit/installer_spec.rb', 'spec/unit/target_installer_spec.rb']
when %r{lib/cocoapods/(.+?)\.rb$}
s = Dir.glob("spec/**/#{$1}_spec.rb")
s unless s.empty?
View
17 spec/spec_helper.rb
@@ -12,18 +12,23 @@
require 'cocoapods'
$:.unshift((ROOT + 'spec').to_s)
+require 'spec_helper/color_output'
require 'spec_helper/fixture'
require 'spec_helper/git'
require 'spec_helper/temporary_directory'
-context_class = defined?(BaconContext) ? BaconContext : Bacon::Context
-context_class.class_eval do
- include Pod::Config::Mixin
+module Bacon
+ extend ColorOutput
+ summary_at_exit
- include SpecHelper::Fixture
+ class Context
+ include Pod::Config::Mixin
- def argv(*argv)
- Pod::Command::ARGV.new(argv)
+ include SpecHelper::Fixture
+
+ def argv(*argv)
+ Pod::Command::ARGV.new(argv)
+ end
end
end
View
43 spec/spec_helper/color_output.rb
@@ -0,0 +1,43 @@
+# Graciously yanked from https://github.com/zen-cms/Zen-Core
+# MIT License
+# Thanks, YorickPeterse!
+
+#:nodoc:
+module Bacon
+ #:nodoc:
+ module ColorOutput
+ #:nodoc:
+ def handle_specification(name)
+ puts spaces + name
+ yield
+ puts if Counter[:context_depth] == 1
+ end
+
+ #:nodoc:
+ def handle_requirement(description)
+ error = yield
+
+ if !error.empty?
+ puts "#{spaces} \e[31m- #{description} [FAILED]\e[0m"
+ else
+ puts "#{spaces} \e[32m- #{description}\e[0m"
+ end
+ end
+
+ #:nodoc:
+ def handle_summary
+ print ErrorLog if Backtraces
+ puts "%d specifications (%d requirements), %d failures, %d errors" %
+ Counter.values_at(:specifications, :requirements, :failed, :errors)
+ end
+
+ #:nodoc:
+ def spaces
+ if Counter[:context_depth] == 0
+ Counter[:context_depth] = 1
+ end
+
+ return ' ' * (Counter[:context_depth] - 1)
+ end
+ end # ColorOutput
+end # Bacon

0 comments on commit 02a5210

Please sign in to comment.