Class: LearnTest::Strategies::Protractor
Instance Attribute Summary
#options, #runner
Instance Method Summary
collapse
#argv, #configure, #die, #initialize, #learn_oauth_token, #push_results?, #run_install, #user_id, #username
Instance Method Details
#check_dependencies ⇒ Object
#cleanup ⇒ Object
85
86
87
|
# File 'lib/learn_test/strategies/protractor.rb', line 85
def cleanup
FileUtils.rm('.results.json') if File.exist?('.results.json')
end
|
#detect ⇒ Object
12
13
14
|
# File 'lib/learn_test/strategies/protractor.rb', line 12
def detect
runner.files.include?('conf.js')
end
|
#output ⇒ Object
62
63
64
|
# File 'lib/learn_test/strategies/protractor.rb', line 62
def output
File.exists?('.results.json') ? Oj.load(File.read('.results.json'), symbol_keys: true) : nil
end
|
#results ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/learn_test/strategies/protractor.rb', line 66
def results
@results ||= {
username: username,
github_user_id: user_id,
learn_oauth_token: learn_oauth_token,
repo_name: runner.repo,
build: {
test_suite: [{
framework: 'protractor',
formatted_output: output,
duration: duration
}]
},
examples: passing_count + failure_count,
passing_count: passing_count,
failure_count: failure_count
}
end
|
#run ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/learn_test/strategies/protractor.rb', line 21
def run
unless selenium_running?
stdin, stdout, stderr, wait_thr = Open3.popen3('webdriver-manager start')
@pid = wait_thr.pid
@server_started = false
while !@server_started && line = stderr.gets do
puts line
if line.include?('Selenium Server is up and running')
@server_started = true
stdin.close
stdout.close
stderr.close
end
end
end
Open3.popen3('protractor conf.js --resultJsonOutputFile .results.json') do |stdin, stdout, stderr, wait_thr|
while line = stdout.gets do
if line.include?('Error: Cannot find module')
@modules_missing = true
end
puts line
end
while stderr_line = stderr.gets do
puts stderr_line
end
if wait_thr.value.exitstatus != 0
if @modules_missing
die("You appear to be missing npm dependencies. Try running `npm install`\nIf the issue persists, check the package.json")
end
end
end
safe_kill(@pid)
safe_kill(@selenium_pid) if selenium_running?
end
|
#service_endpoint ⇒ Object
8
9
10
|
# File 'lib/learn_test/strategies/protractor.rb', line 8
def service_endpoint
'/e/flatiron_protractor'
end
|