Class: Neospec::Logger::Basic
- Inherits:
-
Object
- Object
- Neospec::Logger::Basic
- Defined in:
- lib/neospec/logger/basic.rb
Instance Method Summary collapse
-
#initialize(color: true, output: $stdout) ⇒ Basic
constructor
A new instance of Basic.
- #log(message, context: nil, result: nil) ⇒ Object
Constructor Details
#initialize(color: true, output: $stdout) ⇒ Basic
Returns a new instance of Basic.
4 5 6 7 |
# File 'lib/neospec/logger/basic.rb', line 4 def initialize(color: true, output: $stdout) @color = color @output = output end |
Instance Method Details
#log(message, context: nil, result: nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/neospec/logger/basic.rb', line 9 def log(, context: nil, result: nil) case context when :describe if @color @output.puts "#{Neospec::Color::BLUE}#{message}#{Neospec::Color::RESET}" else @output.puts end when :expect if @color str = " " str << (result.successful? ? "#{Neospec::Color::GREEN}✓" : "#{Neospec::Color::RED}✗") str << " #{context} #{message}#{Neospec::Color::RESET}" @output.puts str else @output.puts " #{result.successful? ? "✓" : "✗"} #{context} #{message}" end else @output.puts " #{context} #{message}" end end |