suture 1.1.0 → 1.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03b931eb888e1ce5e2d66f44c82063095b2d77b7
4
- data.tar.gz: 395821b0b2c7075bfebddec65debbe8dc1860f4b
3
+ metadata.gz: f33e4939ed0c1027f6785cc54be152ea672ebdb4
4
+ data.tar.gz: bec9bab57ef345f7095cabf4ece4c84e242b79e1
5
5
  SHA512:
6
- metadata.gz: f909ce361c7a0b62da87a7332b022725d1c38e02d52c6aa0b4e7f884be841750e2d8b763f8b805cc48f6eff09ebe639d26d330254ef6a04933bba81076e3a335
7
- data.tar.gz: f054acf5f1bb4a577b67973df7f093d26a93258cd2435c86c93885c7e6f4f4c5e7b17c5b5d5a516c4756cbf7816e2cdef990a4fd04191da8f41d519de16cc938
6
+ metadata.gz: 6ddae427868b0b514a8d4b6c3b413f0185c15321e5cfd0acea5ed044a60d78c5232dba4b4cbb3219b33abca7bfad9350a85aff05849f97dc8f1215d341b650f1
7
+ data.tar.gz: 15ef4a1b3af52821d69f1c3aa6997b123bcbcdc0570ce6296cf420caf7437f64083a4442bc278427ccb302fb806705faba8acf2ca0c531cac20450fbaf3c2fb7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.1.0](https://github.com/testdouble/suture/tree/v1.1.0) (2016-09-18)
4
+ [Full Changelog](https://github.com/testdouble/suture/compare/v1.0.0...v1.1.0)
5
+
6
+ **Merged pull requests:**
7
+
8
+ - Return the old result when call\_both mismatches and raise is disable [\#63](https://github.com/testdouble/suture/pull/63) ([searls](https://github.com/searls))
9
+ - excludes example/ from codeclimate analysis [\#62](https://github.com/testdouble/suture/pull/62) ([JoshTGreenwood](https://github.com/JoshTGreenwood))
10
+ - update version in CHANGELOG \[ci skip\] [\#59](https://github.com/testdouble/suture/pull/59) ([y-yagi](https://github.com/y-yagi))
11
+
3
12
  ## [v1.0.0](https://github.com/testdouble/suture/tree/v1.0.0) (2016-09-07)
4
13
  [Full Changelog](https://github.com/testdouble/suture/compare/v0.5.0...v1.0.0)
5
14
 
@@ -16,11 +16,11 @@ module Suture::Error
16
16
  Arguments: ```
17
17
  #{@plan.args.inspect}
18
18
  ```
19
- The new code path returned: ```
20
- #{@new_result.inspect}
19
+ The new code path #{@new_result.errored? ? "raised error" : "returned value"}: ```
20
+ #{@new_result.value.inspect}
21
21
  ```
22
- The old code path returned: ```
23
- #{@old_result.inspect}
22
+ The old code path #{@old_result.errored? ? "raised error" : "returned value"}: ```
23
+ #{@old_result.value.inspect}
24
24
  ```
25
25
 
26
26
  Here's what we recommend you do next:
@@ -1,42 +1,73 @@
1
1
  require "suture/error/result_mismatch"
2
+ require "suture/value/result"
3
+ require "suture/util/compares_results"
2
4
  require "suture/util/scalpel"
3
5
 
4
6
  module Suture::Surgeon
5
7
  class Auditor
6
8
  include Suture::Adapter::Log
7
9
 
10
+ def initialize
11
+ @scalpel = Suture::Util::Scalpel.new
12
+ end
13
+
8
14
  def operate(plan)
9
- scalpel = Suture::Util::Scalpel.new
10
- new_result = scalpel.cut(plan, :new)
11
- old_result = scalpel.cut(plan, :old)
12
- if !plan.comparator.call(old_result, new_result)
15
+ new_result = result_for(plan, :new)
16
+ old_result = result_for(plan, :old)
17
+ if !comparable?(plan, old_result, new_result)
13
18
  handle_mismatch(plan, old_result, new_result)
14
19
  else
15
- new_result
20
+ return_result(new_result)
16
21
  end
17
22
  end
18
23
 
19
24
  private
20
25
 
26
+ def result_for(plan, path)
27
+ begin
28
+ Suture::Value::Result.returned(@scalpel.cut(plan, path))
29
+ rescue StandardError => error
30
+ Suture::Value::Result.errored(error)
31
+ end
32
+ end
33
+
34
+ def comparable?(plan, old_result, new_result)
35
+ Suture::Util::ComparesResults.new(plan.comparator).compare(
36
+ old_result,
37
+ new_result
38
+ )
39
+ end
40
+
21
41
  def handle_mismatch(plan, old_result, new_result)
22
42
  log_warning(plan, old_result, new_result)
23
43
  if plan.raise_on_result_mismatch
24
44
  raise Suture::Error::ResultMismatch.new(plan, new_result, old_result)
25
45
  elsif plan.return_old_on_result_mismatch
26
- old_result
46
+ return_result(old_result)
27
47
  else
28
- new_result
48
+ return_result(new_result)
49
+ end
50
+ end
51
+
52
+ def return_result(result)
53
+ if result.errored?
54
+ raise result.value
55
+ else
56
+ return result.value
29
57
  end
30
58
  end
31
59
 
32
60
  def log_warning(plan, old_result, new_result)
33
61
  log_warn <<-MSG.gsub(/^ {8}/,'')
34
62
  Seam #{plan.name.inspect} is set to :call_both the :new and :old code
35
- paths, but they did not match. The new result was: ```
36
- #{new_result.inspect}
63
+ paths, but they did not match.
64
+
65
+ The new result #{new_result.errored? ? "raised" : "returned"}: ```
66
+ #{new_result.value.inspect}
37
67
  ```
38
- The old result was: ```
39
- #{old_result.inspect}
68
+
69
+ The old result #{old_result.errored? ? "raised" : "returned"}: ```
70
+ #{old_result.value.inspect}
40
71
  ```
41
72
  MSG
42
73
  end
@@ -1,3 +1,3 @@
1
1
  module Suture
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suture
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-18 00:00:00.000000000 Z
11
+ date: 2016-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3