specdiff 0.1.1 → 0.3.0.pre.rc1

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
  SHA256:
3
- metadata.gz: 888c68bf9d22b79bcd5453f24049e375026f150ec28a96fee5610432246a480c
4
- data.tar.gz: 82d74700d65c9e0564862d6ae4b615f25381735e2378d0f1a6236b1b945b1c4b
3
+ metadata.gz: 68cf98631e494fb5f016c0b3632cce58f616dad54ba11c782b37e3de4f2b36c9
4
+ data.tar.gz: b97fee8a8e586b383a71bf0dcdcb32be7cf1c135356a90ec2ae7488fc2082071
5
5
  SHA512:
6
- metadata.gz: dbe9750778a84629cabee0b1a70936e471d180d71f38a585d056ca8e723b9b04925591ce4de9536a2b0855e03b1c73ccff10a4716b63358b7c233ee1f80443c8
7
- data.tar.gz: a115665ae50487b6decb6ebdddab0d840093702ab2c06d7f5b14536cbbd90ca81d3017c32deb390c325a2572a1e8aa13b9f828fcfa7846b7b5e288efef47a431
6
+ metadata.gz: b374cadd1aa564cf8252c4b3d6c4ca2be952b147891cdbec9f0799383349bf5bcf61a1ef94979bc2b1f7dbe4d850e586d4c11f1271c74a14dc9be09cffc4e184
7
+ data.tar.gz: 8379b0c263ae20900ec31b63ea9600e3c15cef8fe9b597c1e1349a708c323d03ee8bfaa46d6f6eeb666e2af0ee751e7ef2cd47917e927eeceb48a7f076a1e126
data/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
1
8
  ## [Unreleased]
2
9
 
10
+ ## [0.3.0-rc1]
11
+
12
+ ### Added
13
+
14
+ - Add rspec integration. `require "specdiff/rspec"` The rspec integration will cause rspec's differ to be replaced entirely with specdiff. It will also cause rspec's inspect (object formatter) to be replaced with Specdiff's inspect.
15
+ - Add `Specdiff.diff_inspect` method, which is a wrapper for `#inspect` with some extra logic to make diffs look better.
16
+ - Add `Specdiff.hashprint` method, which prints hashes/arrays recursively in a way that is friendly to a text differ.
17
+
18
+ ### Changed
19
+
20
+ - Improve contrast for some elements of the text differ
21
+ - Improve hash diffing. Introduce heuristic that decides whether a text diff of the hashes or the hashdiff gem's output is better for the situation.
22
+ - No longer produces a text diff of booleans
23
+ - No longer produces a text diff if both strings are a single line. (This would be useless since the diff is line-based.)
24
+
25
+ ## [0.2.0] - 2023-12-04
26
+
27
+ ### Changed
28
+
29
+ - Stop using thread locals ([#1](https://github.com/odinhb/specdiff/pull/1))
30
+
3
31
  ## [0.1.1] - 2023-12-04
4
32
 
5
33
  ### Fixed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- specdiff (0.1.1)
4
+ specdiff (0.3.0.pre.rc1)
5
5
  diff-lcs (~> 1.5)
6
6
  hashdiff (~> 1.0)
7
7
 
data/README.md CHANGED
@@ -11,7 +11,24 @@ dropping the content type requirement.
11
11
  Specdiff automagically detects the types of provided data and prints a suitable
12
12
  diff between them.
13
13
 
14
- Check out the examples directory to see what it might look like.
14
+ ## Cool, what does it look like?
15
+
16
+ When specdiff is enabled, webmock will produce a generic text diff using
17
+ [`Diff::LCS`](https://github.com/halostatue/diff-lcs) (basically the same
18
+ diff as rspec uses):
19
+
20
+ ![webmock_text_with_specdiff](./assets/webmock_text_with_specdiff.png)
21
+
22
+ It will also produce a json [hashdiff](https://github.com/liufengyun/hashdiff),
23
+ even if the request did not have the content type header:
24
+
25
+ ![d](./assets/webmock_json_with_specdiff.png)
26
+
27
+ (The output of the json diff is experimental, feedback would be great!)
28
+
29
+ You might also check out the `examples/` directory to play with it:
30
+
31
+ `$ cd examples/webmock && bundle install`
15
32
 
16
33
  ## Installation
17
34
 
@@ -47,8 +64,10 @@ Specdiff.configure do |config|
47
64
  end
48
65
  ```
49
66
 
50
- The webmock patch should make webmock show diffs from the specdiff gem when
51
- stubs mismatch.
67
+ ### WebMock
68
+
69
+ The webmock patch should make webmock show request body diffs by using the
70
+ specdiff gem when stubs mismatch. It only applies to request bodies.
52
71
 
53
72
  ### Direct usage
54
73
 
@@ -71,10 +90,13 @@ Specdiff.load!(:json)
71
90
  Specdiff.load!(MyCustomType)
72
91
  ```
73
92
 
74
- Check out the [source code](./lib/specdiff/plugins/json.rb) to learn the plugin interface.
93
+ [Check out the source code](./lib/specdiff/plugins/json.rb) to learn the plugin interface.
75
94
 
76
95
  ## Development
77
96
 
97
+ Check out the [glossary](./glossary.txt) to make sure you (and I) are using the
98
+ same words for things ;)
99
+
78
100
  Install the software versions specified in `.tool-versions`.
79
101
 
80
102
  Run `bin/setup` to install dependencies. Then, run `bundle exec rake` to run the tests and linter and make sure they're green before starting to make your changes.
@@ -83,8 +105,43 @@ Run `bundle exec rake -AD` for a full list of all the available tasks you may us
83
105
 
84
106
  You can also run `bin/console` for an interactive prompt that will allow you to experiment with the gem code loaded.
85
107
 
108
+ Remember to update the unreleased section of the [changelog](./CHANGELOG.md) before you submit your pull request.
109
+
110
+ ## How it works/"Architecture"
111
+
112
+ High level description of the heuristic specdiff implements
113
+
114
+ 1. receive 2 pieces of data: `a` and `b`
115
+ 2. determine types for `a` and `b`
116
+ 1. test against plugin types
117
+ 2. test against built in types
118
+ 3. fall back to the `:unknown` type
119
+ 3. determine which differ is appropriate for the types
120
+ 1. test against plugin differs
121
+ 2. test against built in differs
122
+ 3. fall back to the null differ (`NotFound`)
123
+ 7. run the selected differ with a and b
124
+ 8. package it into a `::Specdiff::Diff` which records the detected types
125
+
126
+ \<time passes>
127
+
128
+ 6. at some point later when `#to_s` is invoked, stringify the diff using the differ's `#stringify`
129
+
86
130
  ## Releasing
87
131
 
132
+ ### Release procedure
133
+
134
+ - [ ] unit tests are passing (`$ bundle exec rake test`)
135
+ - [ ] linter is happy (`$ bundle exec rake lint`)
136
+ - [ ] `examples/` look good
137
+ - [ ] update the version number in `version.rb`
138
+ - [ ] make sure the `examples/` `Gemfile.lock` files are updated (run bundle install)
139
+ - [ ] make sure `Gemfile.lock` is updated (run bundle install)
140
+ - [ ] move unreleased changes to the next version in the [changelog](./CHANGELOG.md)
141
+ - [ ] commit in the form "vX.X.X" and push
142
+ - [ ] make sure the pipeline is green
143
+ - [ ] `$ bundle exec rake release`
144
+
88
145
  To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
89
146
 
90
147
  ## Contributing
@@ -94,3 +151,12 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/odinhb
94
151
  ## License
95
152
 
96
153
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
154
+
155
+ ## TODO
156
+
157
+ This documents potential improvements/issues I know about or have thought about.
158
+
159
+ - [ ] test the webmock monkey-patch. currently there is an empty webmock_spec.rb (should we do this using rspec?) and the examples/ directory contains a few webmock examples (which are a good idea to run before releasing) but it would be nice to have the pipeline fail if it doesn't work for whatever reason
160
+ - [ ] finalize plugin interface (are the methods named intuitively? should we split type detector definitions and differ definitions?)
161
+ - [ ] document how to define a plugin properly (instead of just linking to the source code)
162
+ - [ ] is the stringification of hashdiff's output really better than pretty print? or just more wordy? (the colors are definitely nice)
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --require spec_helper
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rspec"
6
+ gem "debug"
7
+ gem "specdiff", path: "../../"
8
+
9
+ # gem "activesupport"
10
+ gem "bigdecimal"
@@ -0,0 +1,52 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ specdiff (0.3.0.pre.rc1)
5
+ diff-lcs (~> 1.5)
6
+ hashdiff (~> 1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ bigdecimal (3.1.7)
12
+ debug (1.9.1)
13
+ irb (~> 1.10)
14
+ reline (>= 0.3.8)
15
+ diff-lcs (1.5.1)
16
+ hashdiff (1.1.0)
17
+ io-console (0.7.2)
18
+ irb (1.12.0)
19
+ rdoc
20
+ reline (>= 0.4.2)
21
+ psych (5.1.2)
22
+ stringio
23
+ rdoc (6.6.2)
24
+ psych (>= 4.0.0)
25
+ reline (0.4.3)
26
+ io-console (~> 0.5)
27
+ rspec (3.13.0)
28
+ rspec-core (~> 3.13.0)
29
+ rspec-expectations (~> 3.13.0)
30
+ rspec-mocks (~> 3.13.0)
31
+ rspec-core (3.13.0)
32
+ rspec-support (~> 3.13.0)
33
+ rspec-expectations (3.13.0)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.13.0)
36
+ rspec-mocks (3.13.0)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.13.0)
39
+ rspec-support (3.13.1)
40
+ stringio (3.1.0)
41
+
42
+ PLATFORMS
43
+ x86_64-linux
44
+
45
+ DEPENDENCIES
46
+ bigdecimal
47
+ debug
48
+ rspec
49
+ specdiff!
50
+
51
+ BUNDLED WITH
52
+ 2.3.5