Module: Specrun

Defined in:
lib/specrun.rb

Constant Summary collapse

VERSION =
'0.0.5'
MODE =
:debug

Instance Method Summary collapse

Instance Method Details

#build_indexObject



12
13
14
# File 'lib/specrun.rb', line 12

def build_index
  Dir['**/*_spec.rb']
end

#build_results(result, path) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/specrun.rb', line 50

def build_results(result,path)
  if aFile = File.new("specdoc/#{path.gsub('.rb','.html')}", 'w')
    aFile.puts result
    aFile.close
    puts "DEBUG - sucessfully created file 'specdoc/#{path.gsub('.rb','.html')}" if MODE == :debug
  else
    puts "DEBUG - unable to create file 'specdoc/#{path.gsub('.rb','.html')}" if MODE == :debug
  end
end

#build_structure(paths) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/specrun.rb', line 19

def build_structure(paths)
  unless File::exists?('specdoc')
    Dir.mkdir('specdoc')
    puts "DEBUG - Created Directory 'specdoc'" if MODE == :debug
  end
  paths.each do |path|
    if FileUtils.makedirs("specdoc/#{strip_file(path)}")
      puts "DEBUG - successfully created directory specdoc/#{strip_file(path)}" if MODE == :debug
    else
      puts "DEBUG - unable to create directory specdoc/#{strip_file(path)}" if MODE == :debug
    end
  end
end

#run_specs(paths) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/specrun.rb', line 36

def run_specs(paths)
  paths.each do |path|
    if result = `spec -f html #{path}`
      puts "DEBUG - successfully ran spec #{path}." if MODE == :debug
    else
      puts "DEBUG - Unable to run spec #{path}." if MODE == :debug
    end
    build_results(result,path)
  end
end

#strip_file(path) ⇒ Object



69
70
71
72
73
# File 'lib/specrun.rb', line 69

def strip_file(path)
  path = path.split('/')
  path.pop
  return path.join('/')
end

#write_outputObject



63
64
# File 'lib/specrun.rb', line 63

def write_output
end