Class: LearnTest::Strategies::Mocha

Inherits:
LearnTest::Strategy show all
Includes:
JsStrategy
Defined in:
lib/learn_test/strategies/mocha.rb

Instance Attribute Summary

Attributes inherited from LearnTest::Strategy

#options, #runner

Instance Method Summary collapse

Methods included from JsStrategy

#has_js_dependency?, #js_package, #missing_dependencies?, #npm_install

Methods inherited from LearnTest::Strategy

#argv, #configure, #die, #initialize, #learn_oauth_token, #run_install, #user_id, #username

Constructor Details

This class inherits a constructor from LearnTest::Strategy

Instance Method Details

#check_dependenciesObject



16
17
18
# File 'lib/learn_test/strategies/mocha.rb', line 16

def check_dependencies
  Dependencies::NodeJS.new.execute
end

#cleanupObject



24
25
26
# File 'lib/learn_test/strategies/mocha.rb', line 24

def cleanup
  FileUtils.rm('.results.json') if File.exist?('.results.json')
end

#detectObject



10
11
12
13
14
# File 'lib/learn_test/strategies/mocha.rb', line 10

def detect
  return false if !js_package

  (has_js_dependency?(:mocha) || in_browser?) ? true : false
end

#outputObject



51
52
53
# File 'lib/learn_test/strategies/mocha.rb', line 51

def output
  @output ||= File.exist?('.results.json') ? Oj.load(File.read('.results.json'), symbol_keys: true) : nil
end

#push_results?Boolean

Returns:

  • (Boolean)


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

def push_results?
  !in_browser?
end

#resultsObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/learn_test/strategies/mocha.rb', line 32

def results
  @results ||= {
    username: username,
    github_user_id: user_id,
    learn_oauth_token: learn_oauth_token,
    repo_name: runner.repo,
    build: {
      test_suite: [{
        framework: 'mocha',
        formatted_output: output,
        duration: output[:stats]
      }]
    },
    examples: output[:stats][:tests],
    passing_count: output[:stats][:passes],
    failure_count: output[:stats][:failures]
  }
end

#runObject



20
21
22
# File 'lib/learn_test/strategies/mocha.rb', line 20

def run
  run_mocha
end

#service_endpointObject



6
7
8
# File 'lib/learn_test/strategies/mocha.rb', line 6

def service_endpoint
  '/e/flatiron_mocha'
end