Class: LearnLab::Test::Strategies::Mocha

Inherits:
LearnLab::Test::Strategy show all
Defined in:
lib/learn_lab/test/strategies/mocha.rb

Overview

Test strategy for Mocha.

Instance Attribute Summary

Attributes inherited from LearnLab::Test::Strategy

#fs, #options, #out, #runner

Instance Method Summary collapse

Methods inherited from LearnLab::Test::Strategy

#cleanup, #initialize, #output, #result_filename, #results

Constructor Details

This class inherits a constructor from LearnLab::Test::Strategy

Instance Method Details

#check_dependenciesObject

[View source]

9
10
11
12
# File 'lib/learn_lab/test/strategies/mocha.rb', line 9

def check_dependencies
  msg = 'Please install NodeJS: https://nodejs.org/en/download'
  raise MissingDependencyError.new(msg) if `which node`.empty?
end

#detectObject

[View source]

14
15
16
# File 'lib/learn_lab/test/strategies/mocha.rb', line 14

def detect
  js_dependency?(:mocha) || js_dependency?(:'learn-browser')
end

#parserObject

[View source]

28
29
30
# File 'lib/learn_lab/test/strategies/mocha.rb', line 28

def parser
  @parser ||= LearnLab::Test::Parsers::Mocha.new(output)
end

#runObject

[View source]

18
19
20
21
22
23
24
25
26
# File 'lib/learn_lab/test/strategies/mocha.rb', line 18

def run
  command = if js_dependency?(:'learn-browser') || js_test_script?
              'npm test'
            else
              'node_modules/.bin/mocha -R mocha-multi ' \
                "--reporter-options spec=-,json=#{result_filename}"
            end
  system(command)
end