Class: RSpec3
- Inherits:
-
RSpec::Core::Formatters::BaseTextFormatter
- Object
- RSpec::Core::Formatters::BaseTextFormatter
- RSpec3
- Defined in:
- lib/rainbow_formatter/rspec3.rb
Constant Summary collapse
- PI_3 =
Math::PI / 3
Instance Method Summary collapse
- #example_passed(_notification) ⇒ Object
-
#initialize(options) ⇒ RSpec3
constructor
A new instance of RSpec3.
- #rainbow ⇒ Object
Constructor Details
#initialize(options) ⇒ RSpec3
Returns a new instance of RSpec3.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rainbow_formatter/rspec3.rb', line 8 def initialize() # colors calculation stolen from Minitest's Pride Plugin # https://github.com/seattlerb/minitest @colors = (0...(6 * 7)).map do |n| n *= 1.0 / 6 r = (3 * Math.sin(n) + 3).to_i g = (3 * Math.sin(n + 2 * PI_3) + 3).to_i b = (3 * Math.sin(n + 4 * PI_3) + 3).to_i 36 * r + 6 * g + b + 16 end @color_index = 0 super() end |
Instance Method Details
#example_passed(_notification) ⇒ Object
23 24 25 |
# File 'lib/rainbow_formatter/rspec3.rb', line 23 def example_passed(_notification) output.print "\e[38;5;#{rainbow}m.\e[0m" end |
#rainbow ⇒ Object
27 28 29 30 |
# File 'lib/rainbow_formatter/rspec3.rb', line 27 def rainbow @color_index == (@colors.size - 1) ? @color_index = 0 : @color_index += 1 @colors[@color_index] end |