Class: TestParser::Parser::MiniTest

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/test_parser/parser/minitest.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common

#build_test, #parser_type

Constructor Details

#initialize(klass, test_method) ⇒ MiniTest

Returns a new instance of MiniTest.



33
34
35
# File 'lib/test_parser/parser/minitest.rb', line 33

def initialize(klass, test_method)
  @klass, @test_method = klass, test_method
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



11
12
13
# File 'lib/test_parser/parser/minitest.rb', line 11

def klass
  @klass
end

#test_methodObject (readonly)

Returns the value of attribute test_method.



11
12
13
# File 'lib/test_parser/parser/minitest.rb', line 11

def test_method
  @test_method
end

Class Method Details

.find_tests(path, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/test_parser/parser/minitest.rb', line 17

def self.find_tests(path, options = {})
  glob = options[:glob] || 'test/**/*_test.rb'

  ::MiniTest::Unit.dont_install_at_exit!

  TestParser.require_all(path, glob)

  ::MiniTest::Unit::TestCase.test_suites.collect_concat do |klass|
    klass.test_methods.map do |test| 
      new(klass, test).build_test
    end
  end
end

.typeObject



13
14
15
# File 'lib/test_parser/parser/minitest.rb', line 13

def self.type
  :minitest
end

Instance Method Details

#file_nameObject



41
42
43
# File 'lib/test_parser/parser/minitest.rb', line 41

def file_name
  klass.instance_method(test_method).source_location.first
end

#identificationObject



37
38
39
# File 'lib/test_parser/parser/minitest.rb', line 37

def identification
  "#{klass.name}##{test_method}"
end

#snippet_sourceObject



45
46
47
# File 'lib/test_parser/parser/minitest.rb', line 45

def snippet_source
  @snippet_source ||= SnippetSource::Method.new(file_name, test_method)
end