results_keeper 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/results_keeper.rb +31 -19
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 529561f32d09a5d68e0184afd63888010f1129e3
|
4
|
+
data.tar.gz: c2ac7a79925433080048a151be9ec3a338641c04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6902c3773f74d2cb0ea4c5065ea81e43fe1e2da4060557ec9e0058f77c1c87c0d9c4dc9f84884ef6af62692fe76dfd6cb8a8cf6258e5886a5ef3b5a1e501fe28
|
7
|
+
data.tar.gz: 21bf37d7b1af7a6131f607b4ec55ffc0d9676999093a2a241111a66c3ff16b01a089ca56f57f143cd3a16b8e347be3f67e9612a4d23610ba174befad7a6ffa99
|
data/lib/results_keeper.rb
CHANGED
@@ -19,41 +19,53 @@ class ResultsKeeper
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def send_revision
|
22
|
-
data = {
|
22
|
+
data = {revision: @revision_name, project: project_name}
|
23
23
|
@revision = send_json(data, 'revisions', "#{@revision_project} > #{@revision_name} started")
|
24
24
|
end
|
25
25
|
|
26
26
|
def send_revision_complete
|
27
|
-
data = {
|
27
|
+
data = {revision: @revision_name, project: project_name, completed: 1}
|
28
28
|
send_json(data, 'revisions', "#{@revision_name} completed")
|
29
29
|
end
|
30
30
|
|
31
31
|
def send_test(scenario)
|
32
32
|
test_duration = Time.now - @test_started_at
|
33
33
|
@screenshot_path = save_screenshot(scenario) if ENV['SEND_SCREENSHOTS']
|
34
|
-
scenario_steps = scenario.test_steps.map{|s| "And #{s.to_s}"} unless ENV['NO_STEPS']
|
35
34
|
scenario_error = scenario.exception.message if scenario.exception
|
36
35
|
run_path = "cucumber #{scenario.location.file}:#{scenario.location.line}"
|
37
|
-
data = {
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
36
|
+
data = {name: scenario.name,
|
37
|
+
status: scenario.status,
|
38
|
+
feature_name: scenario.feature.name,
|
39
|
+
run_path: run_path,
|
40
|
+
tags: scenario.tags.map(&:name).join(', '),
|
41
|
+
error: scenario_error,
|
42
|
+
revision_id: @revision['revision_id'],
|
43
|
+
steps: scenario_steps(scenario),
|
44
|
+
duration: test_duration
|
46
45
|
}
|
47
46
|
@test = send_json(data, 'tests')
|
48
47
|
send_screenshot(@screenshot_path) if @screenshot_path
|
49
48
|
end
|
50
49
|
|
50
|
+
def scenario_steps(scenario)
|
51
|
+
if scenario.test_steps.first.to_s.include? 'Cucumber::Core::Test'
|
52
|
+
scenario.test_steps.map { |s| "And #{s.name.to_s}" }
|
53
|
+
else
|
54
|
+
scenario.test_steps.map { |s| "And #{s.to_s}" }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
51
58
|
def save_screenshot(scenario)
|
52
59
|
if scenario.exception
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
60
|
+
begin
|
61
|
+
screenshot_name = "#{Time.now.to_i}_#{rand(1000..9999)}.png"
|
62
|
+
@file_path = "tmp/screenshots/#{screenshot_name}"
|
63
|
+
Capybara.page.save_screenshot(@file_path)
|
64
|
+
@file_path
|
65
|
+
rescue
|
66
|
+
console_message('Could not take a screenshot :(')
|
67
|
+
nil
|
68
|
+
end
|
57
69
|
end
|
58
70
|
end
|
59
71
|
|
@@ -65,9 +77,9 @@ class ResultsKeeper
|
|
65
77
|
@path = "/api/#{path}"
|
66
78
|
@body = body.to_json
|
67
79
|
|
68
|
-
request = Net::HTTP::Post.new(@path, initheader = {'Content-Type' =>'application/json'})
|
80
|
+
request = Net::HTTP::Post.new(@path, initheader = {'Content-Type' => 'application/json'})
|
69
81
|
request.body = @body
|
70
|
-
response = Net::HTTP.new(@host, @port).start {|http| http.request(request)
|
82
|
+
response = Net::HTTP.new(@host, @port).start {|http| http.request(request)}
|
71
83
|
begin
|
72
84
|
message_to_client ? console_message("#{message_to_client} - #{response.code} - #{response.message}") : console_message("#{response.code} - #{response.message}")
|
73
85
|
results_hash = JSON.parse(response.body)
|
@@ -80,7 +92,7 @@ class ResultsKeeper
|
|
80
92
|
def send_screenshot(screenshot_path)
|
81
93
|
if ENV['SEND_SCREENSHOTS']
|
82
94
|
t1 = Thread.new do
|
83
|
-
params = {
|
95
|
+
params = {project: @revision['project_id'], revision: @revision['revision_id'], test: @test['id']}
|
84
96
|
RestClient.post("http://#{@host}:#{@port}/api/tests/upload_screenshot",
|
85
97
|
:name_of_file_param => File.new(screenshot_path), :body => params)
|
86
98
|
File.delete(screenshot_path)
|