Class: TestLauncher::Frameworks::Minitest::Runner

Inherits:
Base::Runner
  • Object
show all
Defined in:
lib/test_launcher/frameworks/minitest.rb

Instance Method Summary collapse

Methods inherited from Base::Runner

#multiple_examples, #multiple_files, #single_file

Instance Method Details

#by_line_number(test_case) ⇒ Object



94
95
96
97
98
99
100
# File 'lib/test_launcher/frameworks/minitest.rb', line 94

def (test_case)
  if test_case.example
    single_example(test_case, exact_match: true)
  else
    single_file(test_case)
  end
end

#multiple_examples_same_file(test_cases) ⇒ Object



117
118
119
120
# File 'lib/test_launcher/frameworks/minitest.rb', line 117

def multiple_examples_same_file(test_cases)
  test_case = test_cases.first
  single_example(test_cases.first)
end

#multiple_examples_same_root(test_cases) ⇒ Object



122
123
124
# File 'lib/test_launcher/frameworks/minitest.rb', line 122

def multiple_examples_same_root(test_cases)
  %{cd #{test_cases.first.app_root} && bundle exec ruby -I test -r bundler/setup -e "ARGV.push('--name=/#{test_cases.first.example}/')" #{test_cases.map {|tc| "-r #{tc.file}"}.uniq.join(" ")}}
end

#one_or_more_files(test_cases) ⇒ Object



126
127
128
129
130
131
132
# File 'lib/test_launcher/frameworks/minitest.rb', line 126

def one_or_more_files(test_cases)
  if test_cases.first.spring_enabled?
    %{cd #{test_cases.first.app_root} && #{test_cases.first.file_runner} #{test_cases.map(&:relative_file).uniq.join(" ")}}
  else
    %{cd #{test_cases.first.app_root} && #{test_cases.first.file_runner} #{test_cases.map(&:file).uniq.join(" ")}}
  end
end

#single_example(test_case, name: test_case.example, exact_match: false) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/test_launcher/frameworks/minitest.rb', line 102

def single_example(test_case, name: test_case.example, exact_match: false)
  name_arg =
    if exact_match
      name
    else
      "/#{name}/"
    end

  if test_case.spring_enabled?
    %{cd #{test_case.app_root} && #{test_case.example_runner} #{test_case.relative_file} --name='#{name_arg}'}
  else
    %{cd #{test_case.app_root} && #{test_case.example_runner} #{test_case.file} --name='#{name_arg}'}
  end
end