Method: Onceover::Runner#run_spec!

Defined in:
lib/onceover/runner.rb

#run_spec!Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/onceover/runner.rb', line 78

def run_spec!
  Dir.chdir(@repo.tempdir) do
    # Disable warnings unless we are running in debug mode
    unless logger.level.zero?
      previous_rubyopt = ENV['RUBYOPT']
      ENV['RUBYOPT']   = ENV['RUBYOPT'].to_s + ' -W0'
    end

    #`bundle install --binstubs`
    #`bin/rake spec_standalone`
    if @config.opts[:parallel]
      logger.debug "Running #{@command_prefix}rake parallel_spec from #{@repo.tempdir}"
      result = run_command(@command_prefix.strip.split, 'rake', 'parallel_spec')
    else
      require 'io/console'
      logger.debug "Running #{@command_prefix}rake spec_standalone from #{@repo.tempdir}"
      result = run_command(@command_prefix.strip.split, 'rake', 'spec_standalone')
    end

    # Reset env to previous state if we modified it
    unless logger.level.zero?
      ENV['RUBYOPT'] = previous_rubyopt
    end

    # Print a summary if we were running in parallel
    if @config.formatters.include? 'OnceoverFormatterParallel'
      require 'onceover/rspec/formatters'
      formatter = OnceoverFormatterParallel.new(STDOUT)
      formatter.output_results("#{repo.tempdir}/parallel")
    end

    # Finally exit and preserve the exit code
    exit result.status.exitstatus
  end
end