Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'spec/runner/formatter/base_text_formatter'
- module Spec
- module Runner
- module Formatter
- class LatexIdiopidaeFormatter < BaseTextFormatter
- END_EXAMPLE_GROUP_CONTENT = "\\end{itemize}\n### @end\n\n"
- ESCAPE_CHARACTERS = %w{ # _ $ % }
- def escape(string)
- ESCAPE_CHARACTERS.each do |c|
- string.gsub!(c, "\\#{c}")
- end
- string
- end
- def initialize(options, output)
- super
- @current_example_group_number = 0
- end
- def add_example_group(example_group)
- super
- @current_example_group_number += 1
- unless @current_example_group_number == 1
- output.puts END_EXAMPLE_GROUP_CONTENT
- end
- output.puts "### @export \"#{escape(example_group.description)}\""
- output.puts escape(example_group.description)
- output.puts "\\begin{itemize}"
- output.flush
- end
- # This content gets printed at end. Close any open lists.
- def start_dump
- output.puts END_EXAMPLE_GROUP_CONTENT
- end
- def example_failed(example, counter, failure)
- message = if failure.expectation_not_met?
- "\\item #{escape(example.description)} (FAILED - #{counter})"
- else
- "\\item #{escape(example.description)} (ERROR - #{counter})"
- end
- output.puts(failure.expectation_not_met? ? red(message) : magenta(message))
- output.flush
- end
- def example_passed(example)
- message = "\\item #{escape(example.description)}"
- output.puts green(message)
- output.flush
- end
- def example_pending(example_group_description, example, message)
- super
- output.puts yellow("\\item #{escape(example.description)} (PENDING: #{message})")
- output.flush
- end
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment