Class: Erudite::Executable
- Inherits:
-
Object
- Object
- Erudite::Executable
- Defined in:
- lib/erudite/executable.rb
Overview
Parses, runs, and outputs examples.
Class Method Summary collapse
- .format_example(example) ⇒ Object
- .format_failing_example(example) ⇒ Object
- .format_passing_example(_example) ⇒ Object
- .run(io) ⇒ Object
Class Method Details
.format_example(example) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/erudite/executable.rb', line 20 def self.format_example(example) if example.pass? format_passing_example(example) else format_failing_example(example) end end |
.format_failing_example(example) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/erudite/executable.rb', line 32 def self.format_failing_example(example) "- FAIL\n Source: \#{example.source}\n Expected:\nOutput: \#{example.expected.output.inspect}\nResult: \#{example.expected.result.inspect}\n Actual:\nOutput: \#{example.actual.output.inspect}\nResult: \#{example.actual.result.inspect}\n TEXT\nend\n" |
.format_passing_example(_example) ⇒ Object
28 29 30 |
# File 'lib/erudite/executable.rb', line 28 def self.format_passing_example(_example) '- PASS' end |
.run(io) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/erudite/executable.rb', line 6 def self.run(io) source = io.read Extractor.extract(source).each do |group| binding = TOPLEVEL_BINDING.dup binding.eval(source) group.each do |example| example.binding = binding puts format_example(example) end end end |