Skip to content

Instantly share code, notes, and snippets.

@radar
Created October 14, 2014 08:49
Show Gist options
  • Select an option

  • Save radar/fb4ffad6a8bf08834505 to your computer and use it in GitHub Desktop.

Select an option

Save radar/fb4ffad6a8bf08834505 to your computer and use it in GitHub Desktop.
--color
--require spec_helper
--require ./spec/support/lifx
-f LIFXFormatter
require 'open4'
class LIFXFormatter < RSpec::Core::Formatters::ProgressFormatter
attr_accessor :lifx
RSpec::Core::Formatters.register self, :example_failed, :dump_summary
def initialize(stdout)
super
pid, stdin, stdout, stderr = Open4::popen4("lifx")
@lifx = stdin
end
def example_passed(example)
super
end
def example_failed(example)
super
lifx.puts "fade on Test 0s"
lifx.puts "setcolor Test red brightness:10"
end
def dump_summary(summary)
if summary.failed_examples.empty?
lifx.puts "setcolor Test green brightness:10"
end
super
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment