scrap4rb 0.2.0 → 0.2.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
  SHA256:
3
- metadata.gz: 96286449e9afa50fcf63563ab4c24e5ea34422d4b78aef3c8ba5c5fecd0dad0a
4
- data.tar.gz: 75e1b075bdc33a520a45c1cf95b5e20f484d6893969e5b138f1e6514e0fda703
3
+ metadata.gz: 6e95177ddee73c4a8b9c61d2b7ba4f71da0f0809f4fd321728b4212f68e195f8
4
+ data.tar.gz: c457ee8fe9023e42b7388093da7ad75488155b3c19d82139f34a52043bbb43b6
5
5
  SHA512:
6
- metadata.gz: 76526de107521d564ae46d855eb70920b67f1029a9cf13d8f1831ba8ad2db2173a9a550926ec8e01ebb849f1559d153f8d095157e76dd632005a0e68619ca062
7
- data.tar.gz: 0c6caaaf36b1d12058035482a7f8af88fabd089da3b8f3c54ccd08992bcadb1c80baa2fdf27204dfe866ddd378ac09a5368a623771a79057fdeeebc2a40a5daa
6
+ metadata.gz: c3018805b73ab90fc395558602f14c43d1a6314640008de45118f8bdc8e46b6617d4174cf81b156691ebbec0ddb85bd4fe9e77e69b9c735b94bd307d0a038058
7
+ data.tar.gz: 54bf9499db12c403578b056c4eddb4a1c0de6066e7f9e32a7103dbab2c91e0ee5f979cb064446be254abf89433174b359a28c3c0090b7a8c74de3bb8c023cc47
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.1] - 2026-10-16
10
+
11
+ ### Fixed
12
+ - The README tells you to run scrap4rb from the project root when you run it from a checkout. From the scrap4rb folder, scrap4rb does not find the shared assertion helpers of the project, and a test that uses one reads as `no-assertions`.
13
+ - The README lists all structure errors, limits the 35% low-assertion rule to files with more than two tests, and lists three more deviations from SCRAP.
14
+
9
15
  ## [0.2.0] - 2026-10-15
10
16
 
11
17
  ### Changed
@@ -37,6 +43,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
37
43
  `describe`/`it` blocks. A `define_method` test inside a loop over a table
38
44
  (`CASES.each`) is one table-driven test that spans the loop.
39
45
 
40
- [Unreleased]: https://github.com/roberthopman/scrap4rb/compare/v0.2.0...HEAD
46
+ [Unreleased]: https://github.com/roberthopman/scrap4rb/compare/v0.2.1...HEAD
47
+ [0.2.1]: https://github.com/roberthopman/scrap4rb/compare/v0.2.0...v0.2.1
41
48
  [0.2.0]: https://github.com/roberthopman/scrap4rb/compare/v0.1.0...v0.2.0
42
49
  [0.1.0]: https://github.com/roberthopman/scrap4rb/releases/tag/v0.1.0
data/README.md CHANGED
@@ -22,10 +22,11 @@ Or add it to a Gemfile:
22
22
  gem "scrap4rb", group: :development
23
23
  ```
24
24
 
25
- From a checkout you can run it without installing:
25
+ From a checkout you can run it without installing. Run it from the project root, because scrap4rb finds the shared assertion helpers from the current directory:
26
26
 
27
27
  ```bash
28
- ruby -Ilib exe/scrap4rb path/to/project/test
28
+ cd path/to/project
29
+ ruby -I path/to/scrap4rb/lib path/to/scrap4rb/exe/scrap4rb
29
30
  ```
30
31
 
31
32
  ## Usage
@@ -52,6 +53,8 @@ The comparison gives each changed file a verdict: `improved`, `worse`, `mixed` o
52
53
 
53
54
  ## Output
54
55
 
56
+ An example, with some lines left out and some lines shortened:
57
+
55
58
  ```
56
59
  test/models/smelly_test.rb
57
60
  score 48.46 HIGH mode LOCAL ai AUTO_REFACTOR tests=6 avg=12.78 max=18.26
@@ -85,8 +88,8 @@ EXTRACT A group of tests where a shared helper pays for itself
85
88
 
86
89
  Structure errors:
87
90
 
88
- - a `test` inside a `test`
89
- - a `setup`, `teardown`, `describe`, `context` or `class` inside a test
91
+ - a `test`, `it` or `specify` inside a test
92
+ - a `setup`, `teardown`, `before`, `after`, `describe`, `context`, `def setup` or `class` inside a test
90
93
  - a second `def test_x` with the same name in one class (the first one never runs)
91
94
  - parse errors
92
95
 
@@ -136,16 +139,18 @@ The policy numbers (weights, thresholds, levels) are SCRAP's, unchanged.
136
139
  ## Deviations from SCRAP
137
140
 
138
141
  - A test whose whole body is one context block, such as `travel_to(...) do ... end`, is unwrapped before the phase count. In Ruby that block is test context, not arrange code.
139
- - A call to an assertion helper defined in `test/test_helper.rb`, `test/application_system_test_case.rb`, `test/test_helpers/` or `test/support/` counts as one assertion. SCRAP only reads the spec file itself. Without this rule, every test that uses a shared assertion helper would be "no-assertions".
142
+ - A call to an assertion helper defined in `test/test_helper.rb`, `test/application_system_test_case.rb`, `test/test_helpers/` or `test/support/` counts as one assertion. scrap4rb finds these files from the current directory. SCRAP only reads the spec file itself. Without this rule, every test that uses a shared assertion helper would be "no-assertions".
140
143
  - A loop over a literal hash (`{ 5 => 0, 6 => 10 }.each`) counts as table-driven, the same as a loop over an array of arrays.
141
144
  - `--compare` does not call new tests that use a helper a helper regression. See `docs/compare-verdict.md`.
145
+ - The `where` lines show only for a file with more than one describe block or class. SCRAP shows them for each file.
146
+ - A `describe` inside a `describe` is not a structure error, because minitest/spec nests them. A second test with the same name is a structure error. SCRAP has no such check.
142
147
 
143
148
  ## Notes for Rails suites
144
149
 
145
150
  Two SCRAP rules can disagree with common Rails practice. Decide for your own suite.
146
151
 
147
152
  - **multiple-phases**: a system test that asserts after each click (to prove that the page changed before the next step) has several phases, and SCRAP gives it 5 points.
148
- - **Low-assertion files**: a file is not STABLE when more than 35% of its tests have one assertion or fewer. A suite with "one behavior, one assertion" tests will have many LOCAL files for this reason only.
153
+ - **Low-assertion files**: a file with more than two tests is not STABLE when more than 35% of its tests have one assertion or fewer. A suite with "one behavior, one assertion" tests will have many LOCAL files for this reason only.
149
154
 
150
155
  ## Development
151
156
 
@@ -161,7 +166,7 @@ The golden tests run the executable against the fixture suite in `test/fixtures/
161
166
 
162
167
  SCRAP is by Robert C. Martin (Uncle Bob): [github.com/unclebob/scrap](https://github.com/unclebob/scrap). The algorithm, the metrics, the smells and the policy numbers in scrap4rb come from SCRAP. scrap4rb is an independent Ruby implementation. It contains no SCRAP source code.
163
168
 
164
- scrap4rb 0.1.0 follows SCRAP at commit [`f793b28`](https://github.com/unclebob/scrap/tree/f793b28906d3c60e30b128e1ec08df6269a72b13) (2026-03-17). When SCRAP changes its rules or numbers, scrap4rb can differ until it follows again.
169
+ scrap4rb follows SCRAP at commit [`f793b28`](https://github.com/unclebob/scrap/tree/f793b28906d3c60e30b128e1ec08df6269a72b13) (2026-03-17). When SCRAP changes its rules or numbers, scrap4rb can differ until it follows again.
165
170
 
166
171
  Related tools by the same author: [crap4clj](https://github.com/unclebob/crap4clj), [crap4java](https://github.com/unclebob/crap4java), [crap4go](https://github.com/unclebob/crap4go) and [clj-mutate](https://github.com/unclebob/clj-mutate).
167
172
 
@@ -1,3 +1,3 @@
1
1
  module Scrap4rb
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrap4rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Hopman