Class: LearnTest::Strategies::Mocha
Instance Attribute Summary
#options, #runner
Instance Method Summary
collapse
#argv, #configure, #die, #initialize, #push_results?, #run_install, #user_id, #username
Instance Method Details
#check_dependencies ⇒ Object
#cleanup ⇒ Object
57
58
59
|
# File 'lib/learn_test/strategies/mocha.rb', line 57
def cleanup
FileUtils.rm('.results.json') if File.exist?('.results.json')
end
|
#detect ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/learn_test/strategies/mocha.rb', line 8
def detect
package = File.exists?('package.json') ? Oj.load(File.read('package.json'), symbol_keys: true) : nil
return false if !package
if package[:scripts] && package[:scripts][:test]
return true if package[:scripts][:test].include?('mocha')
end
if package[:devDependencies] && package[:devDependencies][:mocha]
return true if (package[:devDependencies][:mocha].length > 0)
end
if package[:dependencies] && package[:dependencies][:mocha]
return true if (package[:dependencies][:mocha].length > 0)
end
return false
end
|
#output ⇒ Object
35
36
37
|
# File 'lib/learn_test/strategies/mocha.rb', line 35
def output
@output ||= File.exists?('.results.json') ? Oj.load(File.read('.results.json'), symbol_keys: true) : nil
end
|
#results ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/learn_test/strategies/mocha.rb', line 39
def results
@results ||= {
username: username,
github_user_id: user_id,
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
31
32
33
|
# File 'lib/learn_test/strategies/mocha.rb', line 31
def run
run_mocha
end
|
#service_endpoint ⇒ Object
4
5
6
|
# File 'lib/learn_test/strategies/mocha.rb', line 4
def service_endpoint
'/e/flatiron_mocha'
end
|