Class: HwCheker::HomeWorkChecker::TestRun::RubyTestRun

Inherits:
Object
  • Object
show all
Includes:
HwCheker::HomeWorkChecker::TestRun
Defined in:
lib/hw_cheker/ruby_test_run.rb

Instance Method Summary collapse

Methods included from HwCheker::HomeWorkChecker::TestRun

detect_language, #generate_xml

Constructor Details

#initialize(work_path, tmp_path, dirname) ⇒ RubyTestRun

Returns a new instance of RubyTestRun.



7
8
9
10
# File 'lib/hw_cheker/ruby_test_run.rb', line 7

def initialize(work_path, tmp_path, dirname)
  @work_path, @tmp_path = work_path, tmp_path
  @dirname, @passed, @failed = dirname, 0, 0
end

Instance Method Details

#performObject



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

def perform
  Dir::foreach("#{@tmp_path}/#{@dirname}/test") do |p|
    next unless File::file?("#{@tmp_path}/#{@dirname}/test/#{p}") && File::extname(p) == '.rb'
    `rspec #{@tmp_path}/#{@dirname}/test/#{p} > #{@tmp_path}/report.txt`
    count_passed_failed(File.open("#{@tmp_path}/report.txt").first.chomp)
  end
  generate_xml("#{@work_path}/#{@dirname}", {
    :test_passing => calc_percent_passed,
    :code_quality => '???'
  })
end