Class: LearnTest::Strategies::Mocha
Instance Attribute Summary
#options, #runner
Instance Method Summary
collapse
Methods included from JsStrategy
#has_js_dependency?, #js_package, #missing_dependencies?, #modules_missing?, #npm_install
#argv, #configure, #die, #initialize, #learn_oauth_token, #run_install, #user_id, #username
Instance Method Details
#check_dependencies ⇒ Object
18
19
20
|
# File 'lib/learn_test/strategies/mocha.rb', line 18
def check_dependencies
Dependencies::NodeJS.new.execute
end
|
#cleanup ⇒ Object
26
27
28
|
# File 'lib/learn_test/strategies/mocha.rb', line 26
def cleanup
FileUtils.rm('.results.json') if File.exist?('.results.json')
end
|
#detect ⇒ Object
12
13
14
15
16
|
# File 'lib/learn_test/strategies/mocha.rb', line 12
def detect
return false unless js_package
(has_js_dependency?(:mocha) || in_browser?) ? true : false
end
|
#output ⇒ Object
53
54
55
|
# File 'lib/learn_test/strategies/mocha.rb', line 53
def output
@output ||= File.exist?('.results.json') ? Oj.load(File.read('.results.json'), symbol_keys: true) : nil
end
|
#push_results? ⇒ Boolean
30
31
32
|
# File 'lib/learn_test/strategies/mocha.rb', line 30
def push_results?
!in_browser?
end
|
#results ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/learn_test/strategies/mocha.rb', line 34
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
|
#run ⇒ Object
22
23
24
|
# File 'lib/learn_test/strategies/mocha.rb', line 22
def run
run_mocha
end
|
#service_endpoint ⇒ Object
8
9
10
|
# File 'lib/learn_test/strategies/mocha.rb', line 8
def service_endpoint
'/e/flatiron_mocha'
end
|