Class: RGBLED::RSpecFormatter
- Inherits:
-
Object
- Object
- RGBLED::RSpecFormatter
- Defined in:
- lib/rgb_led/rspec_formatter.rb
Class Attribute Summary collapse
-
.path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #close(notification) ⇒ Object
- #example_failed(notification) ⇒ Object
- #example_pending(notification) ⇒ Object
-
#initialize(output) ⇒ RSpecFormatter
constructor
A new instance of RSpecFormatter.
- #start(notification) ⇒ Object
Constructor Details
#initialize(output) ⇒ RSpecFormatter
Returns a new instance of RSpecFormatter.
21 22 23 24 |
# File 'lib/rgb_led/rspec_formatter.rb', line 21 def initialize(output) @output = output || StringIO.new @state = :green end |
Class Attribute Details
.path ⇒ Object
Returns the value of attribute path.
9 10 11 |
# File 'lib/rgb_led/rspec_formatter.rb', line 9 def path @path end |
Instance Method Details
#close(notification) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/rgb_led/rspec_formatter.rb', line 41 def close(notification) return if @controller.nil? case @state when :green then @controller.green when :yellow then @controller.update(1, 0.1, 0) when :red then @controller.red end end |
#example_failed(notification) ⇒ Object
37 38 39 |
# File 'lib/rgb_led/rspec_formatter.rb', line 37 def example_failed(notification) @state = :red end |
#example_pending(notification) ⇒ Object
33 34 35 |
# File 'lib/rgb_led/rspec_formatter.rb', line 33 def example_pending(notification) @state = :yellow if @state == :green end |
#start(notification) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/rgb_led/rspec_formatter.rb', line 26 def start(notification) path = RSpec.configuration.rgb_led_path @controller = RGBLED::Controller.open(path) unless path.nil? @controller.off end |