Class: RspecYahFormatter
- Inherits:
-
RSpec::Core::Formatters::BaseFormatter
- Object
- RSpec::Core::Formatters::BaseFormatter
- RspecYahFormatter
- Defined in:
- lib/rspec_yah_formatter.rb
Instance Method Summary collapse
- #close(notification) ⇒ Object
- #example_failed(notification) ⇒ Object
- #example_passed(notification) ⇒ Object
- #example_pending(notification) ⇒ Object
-
#initialize(io_standard_output) ⇒ RspecYahFormatter
constructor
A new instance of RspecYahFormatter.
Constructor Details
#initialize(io_standard_output) ⇒ RspecYahFormatter
Returns a new instance of RspecYahFormatter.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rspec_yah_formatter.rb', line 17 def initialize(io_standard_output) @examples = [] @passed = 0 @failed = 0 @pending = 0 unless io_standard_output.is_a?(File) raise 'You should specify a file with the --out option, STDOUT cannot be used with this formatter' end @io_standard_output = io_standard_output copy_resources end |
Instance Method Details
#close(notification) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/rspec_yah_formatter.rb', line 44 def close(notification) calculate_durations File.open(@io_standard_output, 'w') do |f| template_file = File.read(File.dirname(__FILE__) + '/../templates/report.erb') f.puts ERB.new(template_file).result(binding) end end |
#example_failed(notification) ⇒ Object
34 35 36 37 |
# File 'lib/rspec_yah_formatter.rb', line 34 def example_failed(notification) @failed += 1 @examples << Example.new(notification.example) end |
#example_passed(notification) ⇒ Object
29 30 31 32 |
# File 'lib/rspec_yah_formatter.rb', line 29 def example_passed(notification) @passed += 1 @examples << Example.new(notification.example) end |
#example_pending(notification) ⇒ Object
39 40 41 42 |
# File 'lib/rspec_yah_formatter.rb', line 39 def example_pending(notification) @pending += 1 @examples << Example.new(notification.example) end |