specdiff 0.2.0 → 0.3.0.pre.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +1 -1
- data/README.md +21 -4
- data/assets/webmock_json_with_specdiff.png +0 -0
- data/assets/webmock_text_with_specdiff.png +0 -0
- data/examples/rspec/.rspec +2 -0
- data/examples/rspec/Gemfile +10 -0
- data/examples/rspec/Gemfile.lock +52 -0
- data/examples/rspec/spec/example_spec.rb +678 -0
- data/examples/rspec/spec/spec_helper.rb +68 -0
- data/examples/webmock/Gemfile.lock +2 -2
- data/lib/specdiff/colorize.rb +5 -0
- data/lib/specdiff/diff.rb +3 -1
- data/lib/specdiff/differ/hashdiff.rb +101 -22
- data/lib/specdiff/differ/not_found.rb +1 -1
- data/lib/specdiff/differ/text.rb +21 -7
- data/lib/specdiff/hashprint.rb +154 -0
- data/lib/specdiff/inspect.rb +41 -0
- data/lib/specdiff/rspec.rb +33 -0
- data/lib/specdiff/version.rb +1 -1
- data/lib/specdiff/webmock.rb +41 -1
- data/lib/specdiff.rb +15 -1
- metadata +19 -10
- data/lib/specdiff/webmock/request_body_diff.rb +0 -41
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specdiff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0.pre.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Odin Heggvold Bekkelund
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashdiff
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.5'
|
41
|
-
description:
|
41
|
+
description:
|
42
42
|
email:
|
43
43
|
- odinhb@protonmail.com
|
44
44
|
executables: []
|
@@ -54,6 +54,13 @@ files:
|
|
54
54
|
- LICENSE.txt
|
55
55
|
- README.md
|
56
56
|
- Rakefile
|
57
|
+
- assets/webmock_json_with_specdiff.png
|
58
|
+
- assets/webmock_text_with_specdiff.png
|
59
|
+
- examples/rspec/.rspec
|
60
|
+
- examples/rspec/Gemfile
|
61
|
+
- examples/rspec/Gemfile.lock
|
62
|
+
- examples/rspec/spec/example_spec.rb
|
63
|
+
- examples/rspec/spec/spec_helper.rb
|
57
64
|
- examples/webmock/Gemfile
|
58
65
|
- examples/webmock/Gemfile.lock
|
59
66
|
- examples/webmock/json.rb
|
@@ -68,12 +75,14 @@ files:
|
|
68
75
|
- lib/specdiff/differ/hashdiff.rb
|
69
76
|
- lib/specdiff/differ/not_found.rb
|
70
77
|
- lib/specdiff/differ/text.rb
|
78
|
+
- lib/specdiff/hashprint.rb
|
79
|
+
- lib/specdiff/inspect.rb
|
71
80
|
- lib/specdiff/plugin.rb
|
72
81
|
- lib/specdiff/plugins.rb
|
73
82
|
- lib/specdiff/plugins/json.rb
|
83
|
+
- lib/specdiff/rspec.rb
|
74
84
|
- lib/specdiff/version.rb
|
75
85
|
- lib/specdiff/webmock.rb
|
76
|
-
- lib/specdiff/webmock/request_body_diff.rb
|
77
86
|
- specdiff.gemspec
|
78
87
|
homepage: https://github.com/odinhb/specdiff
|
79
88
|
licenses:
|
@@ -82,7 +91,7 @@ metadata:
|
|
82
91
|
homepage_uri: https://github.com/odinhb/specdiff
|
83
92
|
source_code_uri: https://github.com/odinhb/specdiff
|
84
93
|
changelog_uri: https://github.com/odinhb/specdiff/CHANGELOG.md
|
85
|
-
post_install_message:
|
94
|
+
post_install_message:
|
86
95
|
rdoc_options: []
|
87
96
|
require_paths:
|
88
97
|
- lib
|
@@ -93,12 +102,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
102
|
version: 3.0.0
|
94
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
104
|
requirements:
|
96
|
-
- - "
|
105
|
+
- - ">"
|
97
106
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
107
|
+
version: 1.3.1
|
99
108
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
101
|
-
signing_key:
|
109
|
+
rubygems_version: 3.2.22
|
110
|
+
signing_key:
|
102
111
|
specification_version: 4
|
103
112
|
summary: Improved request body diffs for webmock
|
104
113
|
test_files: []
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require "hashdiff"
|
2
|
-
require "json"
|
3
|
-
|
4
|
-
module WebMock
|
5
|
-
class RequestBodyDiff
|
6
|
-
def initialize(request_signature, request_stub)
|
7
|
-
@request_signature = request_signature
|
8
|
-
@request_stub = request_stub
|
9
|
-
end
|
10
|
-
|
11
|
-
PrettyPrintableThingy = Struct.new(:specdiff) do
|
12
|
-
# webmock does not print the diff if it responds true to this.
|
13
|
-
def empty?
|
14
|
-
specdiff.empty?
|
15
|
-
end
|
16
|
-
|
17
|
-
# webmock prints the diff by passing us to PP.pp, which in turn uses this
|
18
|
-
# method.
|
19
|
-
def pretty_print(pp)
|
20
|
-
pp.text("\r") # remove a space that isn't supposed to be there
|
21
|
-
pp.text(specdiff.to_s)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def body_diff
|
26
|
-
specdiff = Specdiff.diff(request_stub_body, request_signature.body)
|
27
|
-
PrettyPrintableThingy.new(specdiff)
|
28
|
-
end
|
29
|
-
|
30
|
-
attr_reader :request_signature, :request_stub
|
31
|
-
private :request_signature, :request_stub
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def request_stub_body
|
36
|
-
request_stub.request_pattern &&
|
37
|
-
request_stub.request_pattern.body_pattern &&
|
38
|
-
request_stub.request_pattern.body_pattern.pattern
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|