Class: SpecMate

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/mate/runner.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) project_directory (protected)



62
63
64
# File 'lib/rspec/mate/runner.rb', line 62

def project_directory
  File.expand_path(ENV['TM_PROJECT_DIRECTORY'])
end

- (Object) run(stdout, options)



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rspec/mate/runner.rb', line 43

def run(stdout, options)
  formatter = ENV['TM_RSPEC_FORMATTER'] || 'RSpec::Core::Formatter::WebKit'

  argv = []
  argv += ENV['TM_RSPEC_OPTS'].split(" ") if ENV['TM_RSPEC_OPTS']
  argv += options[:files].dup
  argv << '--format' << formatter
  argv << '--line' << options[:line] if options[:line]

  Dir.chdir(ENV['TM_PROJECT_DIRECTORY']) do
    ::RSpec::Core::CommandLine.run(RSpec::Core::OptionParser.parse(argv, STDERR, stdout))
  end
end

- (Object) run_file(stdout, options = {})



33
34
35
36
# File 'lib/rspec/mate/runner.rb', line 33

def run_file(stdout, options={})
  options.merge!({:files => [single_file]})
  run(stdout, options)
end

- (Object) run_files(stdout, options = {})



25
26
27
28
29
30
31
# File 'lib/rspec/mate/runner.rb', line 25

def run_files(stdout, options={})
  files = ENV['TM_SELECTED_FILES'].split(" ").map do |path|
    File.expand_path(path[1..-2])
  end
  options.merge!({:files => files})
  run(stdout, options)
end

- (Object) run_focussed(stdout, options = {})



38
39
40
41
# File 'lib/rspec/mate/runner.rb', line 38

def run_focussed(stdout, options={})
  options.merge!({:files => [single_file], :line => ENV['TM_LINE_NUMBER']})
  run(stdout, options)
end

- (Object) single_file (protected)



58
59
60
# File 'lib/rspec/mate/runner.rb', line 58

def single_file
  File.expand_path(ENV['TM_FILEPATH'])
end