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

#initialize, #multiple_examples, #multiple_files, #single_file

Constructor Details

This class inherits a constructor from TestLauncher::Frameworks::Base::Runner

Instance Method Details

#by_line_number(test_case) ⇒ Object



100
101
102
103
104
105
106
# File 'lib/test_launcher/frameworks/minitest.rb', line 100

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



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

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



133
134
135
# File 'lib/test_launcher/frameworks/minitest.rb', line 133

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



137
138
139
140
141
142
143
# File 'lib/test_launcher/frameworks/minitest.rb', line 137

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



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/test_launcher/frameworks/minitest.rb', line 108

def single_example(test_case, name: test_case.example, exact_match: false)
  name_arg =
    if exact_match && name.match(/[^\w]/)
      Shellwords.escape(name)
    elsif !exact_match
      "'/#{name}/'"
    else
      name
    end

  file =
    if test_case.spring_enabled?
      test_case.relative_file
    else
      test_case.file
    end

  %{cd #{test_case.app_root} && #{test_case.example_runner} #{file} --name=#{name_arg}}
end