barthes 0.0.11 → 0.0.12
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.
- data/lib/barthes/action.rb +40 -26
- data/lib/barthes/reporter/junit_xml.rb +13 -0
- data/lib/barthes/runner.rb +1 -3
- data/lib/barthes/version.rb +1 -1
- metadata +1 -1
data/lib/barthes/action.rb
CHANGED
@@ -13,42 +13,56 @@ module Barthes
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def action(action)
|
16
|
-
|
17
|
-
|
16
|
+
begin
|
17
|
+
@env.update(action['env']) if action['env']
|
18
|
+
params = evaluate_params(action['params'])
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
if action['expectations']
|
21
|
+
if action['max_loop']
|
22
|
+
action['max_loop'].to_i.times do
|
23
|
+
sleep action['sleep'].to_i/1000 if action['sleep']
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
response = @client.action(params)
|
26
|
+
action['expectations'].each do |expectation|
|
27
|
+
result = @client.compare(response, evaluate_params(expectation))
|
28
|
+
expectation.update(result)
|
29
|
+
end
|
30
|
+
if action['expectations'].all? {|e| e['result'] == true }
|
31
|
+
break
|
32
|
+
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
34
|
-
end
|
35
36
|
|
36
|
-
|
37
|
+
sleep action['sleep'].to_i/1000 if action['sleep']
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
action['request'] = params
|
40
|
+
action['response'] = response = @client.action(params)
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
if action['expectations']
|
43
|
+
action['expectations'].each do |expectation|
|
44
|
+
result = @client.compare(response, evaluate_params(expectation))
|
45
|
+
expectation.update(result)
|
46
|
+
end
|
47
|
+
if action['expectations'].all? {|e| e['result'] == true }
|
48
|
+
action['status'] = 'failure'
|
49
|
+
end
|
50
|
+
else
|
51
|
+
action['status'] = 'success'
|
45
52
|
end
|
46
|
-
end
|
47
53
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
54
|
+
if cache_config = action['cache']
|
55
|
+
value = @client.extract(cache_config, response)
|
56
|
+
action['cache']['value'] = value
|
57
|
+
Barthes::Cache[cache_config['key']] = value
|
58
|
+
end
|
59
|
+
rescue StandardError => e
|
60
|
+
action['status'] = 'error'
|
61
|
+
action['error'] = {
|
62
|
+
'class' => e.class,
|
63
|
+
'message' => e.message,
|
64
|
+
'backtrace' => e.backtrace
|
65
|
+
}
|
52
66
|
end
|
53
67
|
action
|
54
68
|
end
|
@@ -57,7 +57,20 @@ module Barthes
|
|
57
57
|
when 'skipped'
|
58
58
|
@xml.skipped
|
59
59
|
when 'failure'
|
60
|
+
failure = "failed expectations: \n"
|
61
|
+
expectations = action['expectations'] || []
|
62
|
+
expectations.each do |expectation|
|
63
|
+
if expectation['result'] == false
|
64
|
+
failure += JSON.pretty_generate(expectation) + "\n"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
@xml.failure failure
|
60
68
|
when 'error'
|
69
|
+
error = "error:\n"
|
70
|
+
error += "class: #{json.last['error']['class']}\n"
|
71
|
+
error += "message: #{json.last['error']['message']}\n"
|
72
|
+
error += "backtrace: #{json.last['error']['backtrace'].join("\n")}\n"
|
73
|
+
@xml.error error
|
61
74
|
end
|
62
75
|
if json.last['status'] != 'skipped' && json.last['request'] && json.last['response']
|
63
76
|
stdout = "request:\n"
|
data/lib/barthes/runner.rb
CHANGED
@@ -111,9 +111,7 @@ module Barthes
|
|
111
111
|
content['number'] = @num
|
112
112
|
if Barthes::Config[:dryrun] == 0 && !@failed
|
113
113
|
content = Action.new(env).action(content)
|
114
|
-
if
|
115
|
-
@failed = true
|
116
|
-
end
|
114
|
+
@failed = true if %w(failure error).include?(content['status'])
|
117
115
|
end
|
118
116
|
content['status'] = 'skipped' if Barthes::Config[:dryrun] > 0
|
119
117
|
content
|
data/lib/barthes/version.rb
CHANGED