barthes 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,13 +39,15 @@ module Barthes
39
39
  action['request'] = params
40
40
  action['response'] = response = @client.action(params)
41
41
 
42
- if action['expectations']
42
+ if action['expectations'] && !action['expectations'].empty?
43
43
  action['expectations'].each do |expectation|
44
44
  result = @client.compare(response, evaluate_params(expectation))
45
45
  expectation.update(result)
46
46
  end
47
- if action['expectations'].all? {|e| e['result'] == true }
47
+ if !action['expectations'].all? {|e| e['result'] == true }
48
48
  action['status'] = 'failure'
49
+ else
50
+ action['status'] = 'success'
49
51
  end
50
52
  else
51
53
  action['status'] = 'success'
@@ -25,8 +25,16 @@ module Barthes
25
25
  if Barthes::Config[:quiet] == 0 && Barthes::Config[:dryrun] == 0
26
26
  puts indent scenarios.size + 1, "request:"
27
27
  puts indent scenarios.size + 2, JSON.pretty_generate(action['request'])
28
- puts indent scenarios.size + 1, "response:"
29
- puts indent scenarios.size + 2, JSON.pretty_generate(action['response'])
28
+ if %w(success failure).include?(action['status'])
29
+ puts indent scenarios.size + 1, "response:"
30
+ puts indent scenarios.size + 2, JSON.pretty_generate(action['response'])
31
+ elsif action['status'] == 'error'
32
+ puts indent scenarios.size + 1, "error:"
33
+ puts indent scenarios.size + 2, "class: #{action['error']['class']}"
34
+ puts indent scenarios.size + 2, "message: #{action['error']['message']}"
35
+ puts indent scenarios.size + 2, "backtrace:"
36
+ puts indent scenarios.size + 3, action['error']['backtrace'].join("\n")
37
+ end
30
38
  end
31
39
  expectations = action['expectations'] || []
32
40
  expectations.each do |expectation|
@@ -38,10 +46,10 @@ module Barthes
38
46
  flag = ''
39
47
  if Barthes::Config[:dryrun] > 0
40
48
  flag = 'skipped'
41
- elsif expectations.empty? || expectations.all? {|r| r['result'] == true }
42
- flag = green {'success'}
49
+ elsif action['status'] == 'success'
50
+ flag = green { action['status'] }
43
51
  else
44
- flag = red {'failure'}
52
+ flag = red { action['status'] }
45
53
  end
46
54
  puts indent(scenarios.size + 1, "result: #{flag}")
47
55
  end
@@ -58,7 +58,7 @@ module Barthes
58
58
  @xml.skipped
59
59
  when 'failure'
60
60
  failure = "failed expectations: \n"
61
- expectations = action['expectations'] || []
61
+ expectations = json.last['expectations'] || []
62
62
  expectations.each do |expectation|
63
63
  if expectation['result'] == false
64
64
  failure += JSON.pretty_generate(expectation) + "\n"
@@ -1,3 +1,3 @@
1
1
  module Barthes
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barthes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: