Class: Minitest::Example

Inherits:
Test
  • Object
show all
Defined in:
lib/minitest/example.rb

Class Method Summary collapse

Class Method Details

.capture_stdoutObject



24
25
26
27
28
29
30
31
32
# File 'lib/minitest/example.rb', line 24

def capture_stdout
  original_out = $stdout
  out = StringIO.new
  $stdout = out
  yield
  out.string
ensure
  $stdout = original_out
end

.run_one_method(klass, method_name, reporter) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/minitest/example.rb', line 12

def run_one_method klass, method_name, reporter
  code = klass.instance_method(method_name).source
  parser = Rgot::ExampleParser.new(code)
  parser.parse
  example = parser.examples.first

  reporter.prerecord klass, method_name
  out = capture_stdout { reporter.record Minitest.run_one_method(klass, method_name) }

  klass.new(method_name).assert_equal example.output.strip, out.strip
end

.runnable_methodsObject



8
9
10
# File 'lib/minitest/example.rb', line 8

def runnable_methods
  methods_matching(/^example_/)
end