Class: Luna::RSpec::Formatters::Documentation
- Inherits:
-
Base
- Object
- RSpec::Core::Formatters::BaseTextFormatter
- Base
- Luna::RSpec::Formatters::Documentation
show all
- Defined in:
- lib/luna/rspec/formatters/documentation.rb
Instance Method Summary
collapse
Methods inherited from Base
#dump_summary, #start, #start_dump
Instance Method Details
#example_failed ⇒ Object
15
16
17
18
19
|
# File 'lib/luna/rspec/formatters/documentation.rb', line 15
def example_failed
super(e)
blank_line?
failure_color(print_description(e))
end
|
#example_passed ⇒ Object
9
10
11
12
13
|
# File 'lib/luna/rspec/formatters/documentation.rb', line 9
def example_passed
super(e)
blank_line?
success_color(print_description(e))
end
|
#example_pending ⇒ Object
21
22
23
24
25
|
# File 'lib/luna/rspec/formatters/documentation.rb', line 21
def example_pending
super(e)
blank_line?
pending_color(print_description(e))
end
|
#highlight_graves(text) ⇒ Object
29
30
31
|
# File 'lib/luna/rspec/formatters/documentation.rb', line 29
def highlight_graves(text)
text.gsub(/`([^`]+)`/) { syntax_highlight($1) }
end
|
#highlight_methods(text) ⇒ Object
38
39
40
|
# File 'lib/luna/rspec/formatters/documentation.rb', line 38
def highlight_methods(text)
text.gsub(/(#|\.)([a-z0-9_]+)/) { $1.white + $2.magenta }
end
|
#print_description(example) ⇒ Object
44
45
46
47
48
|
# File 'lib/luna/rspec/formatters/documentation.rb', line 44
def print_description(example)
constant = example.full_description.chomp(example.description)
output.print " " + highlight_methods(syntax_highlight(constant))
output.print highlight_graves(example.description) + ":"
end
|
#syntax_highlight(text) ⇒ Object
33
34
35
|
# File 'lib/luna/rspec/formatters/documentation.rb', line 33
def syntax_highlight(text)
CodeRay.scan(text, :ruby).term
end
|