Class: NanDoc::SpecDoc::TestCaseAgent
- Inherits:
-
Object
- Object
- NanDoc::SpecDoc::TestCaseAgent
- Includes:
- AgentInstanceMethods, ParseTrace, Treebis::Capture3
- Defined in:
- lib/nandoc/spec-doc/test-case-agent.rb
Instance Method Summary collapse
-
#initialize(test_case) ⇒ TestCaseAgent
constructor
A new instance of TestCaseAgent.
- #inspect(mixed, exp_str = nil) ⇒ Object
-
#out(exp, &block) ⇒ Object
if it passes (or fails?) one of the strings is written to an :out node in the recording raises something if $stderr is written to.
- #record_ruby ⇒ Object
- #record_ruby_stop ⇒ Object
Methods included from ParseTrace
#parse_trace, #parse_trace_assert
Methods included from AgentInstanceMethods
#method_name_to_record, #story
Constructor Details
#initialize(test_case) ⇒ TestCaseAgent
Returns a new instance of TestCaseAgent.
4 5 6 |
# File 'lib/nandoc/spec-doc/test-case-agent.rb', line 4 def initialize test_case @test_case = test_case end |
Instance Method Details
#inspect(mixed, exp_str = nil) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/nandoc/spec-doc/test-case-agent.rb', line 28 def inspect mixed, exp_str = nil act_str = mixed.inspect line = caller.first trace = parse_trace_assert(line) if exp_str @test_case.assert_no_diff(exp_str, act_str, "at #{line}") end recordings.add(:inspect, act_str, trace) end |
#out(exp, &block) ⇒ Object
if it passes (or fails?) one of the strings is written to an :out node in the recording raises something if $stderr is written to.
warning - blah blah @todo
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/nandoc/spec-doc/test-case-agent.rb', line 18 def out exp, &block trace = parse_trace_assert(caller.first) out, err = capture3(&block) fail("no: #{err.inspect}") unless err == "" @test_case.assert_no_diff(exp, out) if out == exp recordings.add(:out, out, trace) end nil end |
#record_ruby ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/nandoc/spec-doc/test-case-agent.rb', line 37 def record_ruby md = parse_trace_assert(caller.first) snip = CodeSnippet.new(md) recordings.add(:method, snip.method) recordings.add(:record_ruby, snip) @last_snip = snip nil end |
#record_ruby_stop ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/nandoc/spec-doc/test-case-agent.rb', line 45 def record_ruby_stop line = caller.first md = parse_trace_assert(caller.first) @last_snip or fail("no record_start in method before "<< "record_stop at #{line}") @last_snip.stop_at md end |