regresso 0.1.0

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.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +3 -0
  3. data/CHANGELOG.md +3 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +258 -0
  6. data/Rakefile +12 -0
  7. data/assets/logo-header.svg +28 -0
  8. data/lib/generators/regresso/install_generator.rb +29 -0
  9. data/lib/generators/regresso/templates/regresso.rb +18 -0
  10. data/lib/regresso/adapters/.gitkeep +0 -0
  11. data/lib/regresso/adapters/base.rb +30 -0
  12. data/lib/regresso/adapters/csv.rb +43 -0
  13. data/lib/regresso/adapters/database.rb +53 -0
  14. data/lib/regresso/adapters/database_snapshot.rb +49 -0
  15. data/lib/regresso/adapters/graphql.rb +75 -0
  16. data/lib/regresso/adapters/graphql_batch.rb +42 -0
  17. data/lib/regresso/adapters/http.rb +70 -0
  18. data/lib/regresso/adapters/json_file.rb +30 -0
  19. data/lib/regresso/adapters/proc.rb +30 -0
  20. data/lib/regresso/ci/github_annotation_formatter.rb +46 -0
  21. data/lib/regresso/ci/github_pr_commenter.rb +55 -0
  22. data/lib/regresso/ci/junit_xml_formatter.rb +42 -0
  23. data/lib/regresso/ci/reporter.rb +49 -0
  24. data/lib/regresso/ci.rb +6 -0
  25. data/lib/regresso/comparator.rb +45 -0
  26. data/lib/regresso/configuration.rb +92 -0
  27. data/lib/regresso/differ.rb +129 -0
  28. data/lib/regresso/difference.rb +45 -0
  29. data/lib/regresso/history/entry.rb +70 -0
  30. data/lib/regresso/history/file_backend.rb +51 -0
  31. data/lib/regresso/history/statistics.rb +65 -0
  32. data/lib/regresso/history/store.rb +122 -0
  33. data/lib/regresso/history/trend_reporter.rb +68 -0
  34. data/lib/regresso/history.rb +7 -0
  35. data/lib/regresso/json_path.rb +55 -0
  36. data/lib/regresso/minitest.rb +107 -0
  37. data/lib/regresso/notifiers/base.rb +33 -0
  38. data/lib/regresso/notifiers/microsoft_teams.rb +60 -0
  39. data/lib/regresso/notifiers/slack.rb +72 -0
  40. data/lib/regresso/notifiers.rb +5 -0
  41. data/lib/regresso/parallel/comparison_result.rb +51 -0
  42. data/lib/regresso/parallel/parallel_result.rb +68 -0
  43. data/lib/regresso/parallel/result_aggregator.rb +25 -0
  44. data/lib/regresso/parallel/runner.rb +71 -0
  45. data/lib/regresso/parallel.rb +6 -0
  46. data/lib/regresso/reporter.rb +68 -0
  47. data/lib/regresso/result.rb +70 -0
  48. data/lib/regresso/rspec/.gitkeep +0 -0
  49. data/lib/regresso/rspec/shared_examples.rb +42 -0
  50. data/lib/regresso/rspec.rb +142 -0
  51. data/lib/regresso/snapshot_manager.rb +57 -0
  52. data/lib/regresso/tasks/ci.rake +51 -0
  53. data/lib/regresso/tasks/history.rake +36 -0
  54. data/lib/regresso/templates/.gitkeep +0 -0
  55. data/lib/regresso/templates/report.html.erb +44 -0
  56. data/lib/regresso/version.rb +6 -0
  57. data/lib/regresso/web_ui/diff_formatter.rb +46 -0
  58. data/lib/regresso/web_ui/public/css/app.css +239 -0
  59. data/lib/regresso/web_ui/public/js/app.js +117 -0
  60. data/lib/regresso/web_ui/result_store.rb +60 -0
  61. data/lib/regresso/web_ui/server.rb +70 -0
  62. data/lib/regresso/web_ui/views/index.erb +58 -0
  63. data/lib/regresso/web_ui/views/layout.erb +13 -0
  64. data/lib/regresso/web_ui.rb +5 -0
  65. data/lib/regresso.rb +46 -0
  66. data/sig/regresso.rbs +4 -0
  67. data/site/Gemfile +7 -0
  68. data/site/assets/logo-header.png +0 -0
  69. data/site/assets/site.css +458 -0
  70. data/site/content/index.md +6 -0
  71. data/site/craze.yml +24 -0
  72. data/site/dist/assets/logo-header.svg +28 -0
  73. data/site/dist/assets/site.css +458 -0
  74. data/site/dist/index.html +232 -0
  75. data/site/dist/search.json +9 -0
  76. data/site/dist/sitemap.xml +7 -0
  77. data/site/templates/index.erb +232 -0
  78. data/site/templates/layout.erb +17 -0
  79. metadata +190 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7df7c1a0aba2f0a6b526c8bad5e1732aea99a43db264c550603ff8dcd9535587
4
+ data.tar.gz: 822d789eb0d6f80ed0c412a3c367790eea686ae3345c0d58e3737441b3d59ea1
5
+ SHA512:
6
+ metadata.gz: 932ee045cd248b9a8de21960569265f03bbacd13c303c2782a80dd35dadfa2a2d2bfc2ffcbb6f59cfc2234a2791212cec51fc46b4531613d580100ae381e4e20
7
+ data.tar.gz: eabe7f3d69c7b7df776f61f98288de3c8656ca112bd233921e37123b162caf8f06c2e40da87ad2bfa1b1903458bf245a57bf1e2ea7d92f2205da33295438f89d
data/.yardopts ADDED
@@ -0,0 +1,3 @@
1
+ - README.md
2
+ - lib/**/*.rb
3
+ - --markup markdown
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## [0.1.0] - 2025-01-18
2
+
3
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Yudai Takada
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,258 @@
1
+ <p align="center">
2
+ <img src="assets/logo-header.svg" alt="regresso header logo">
3
+ <b>Regression testing for Ruby APIs, files, and data snapshots.</b>
4
+ <br>
5
+ Compare outputs across environments with tolerances and ignore rules.
6
+ </p>
7
+
8
+ <p align="center">
9
+ <img src="https://img.shields.io/badge/ruby-%3E%3D%203.2-ruby.svg" alt="Ruby Version">
10
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
11
+ <a href="https://badge.fury.io/rb/regresso"><img src="https://badge.fury.io/rb/regresso.svg" alt="Gem Version" height="18"></a>
12
+ <a href="https://github.com/ydah/regresso/actions/workflows/main.yml">
13
+ <img src="https://github.com/ydah/regresso/actions/workflows/main.yml/badge.svg" alt="CI Status">
14
+ </a>
15
+ </p>
16
+
17
+ <p align="center">
18
+ <a href="#features">Features</a> •
19
+ <a href="#quick-start">Quick Start</a> •
20
+ <a href="#how-it-works">How It Works</a> •
21
+ <a href="#installation">Installation</a> •
22
+ <a href="#configuration">Configuration</a> •
23
+ <a href="#documentation">Documentation</a> •
24
+ <a href="#web-ui">Web UI</a>
25
+ </p>
26
+
27
+ ## Features
28
+
29
+ - Compare API responses, CSV exports, JSON files, or custom data sources
30
+ - Tolerances and per-path overrides for numeric differences
31
+ - Ignore paths by JSONPath or regex to avoid noisy fields
32
+ - Snapshot testing for stable outputs
33
+ - RSpec and Minitest integrations
34
+ - GraphQL, database, and batch comparisons
35
+ - Parallel execution with CI-ready reports
36
+ - Optional Web UI for browsing results
37
+
38
+ ## Quick Start
39
+
40
+ ```ruby
41
+ require "regresso/rspec"
42
+
43
+ old_api = { base_url: "https://old.example.com", endpoint: "/reports/sales" }
44
+ new_api = { base_url: "https://new.example.com", endpoint: "/reports/sales" }
45
+
46
+ RSpec.describe "Sales report" do
47
+ it "has no regression" do
48
+ expect(new_api).to have_no_regression_from(old_api)
49
+ .with_tolerance(0.01)
50
+ .ignoring("$.timestamp")
51
+ end
52
+ end
53
+ ```
54
+
55
+ ## How It Works
56
+
57
+ 1. Build two data sources (old and new)
58
+ 2. Normalize and compare outputs
59
+ 3. Apply tolerances and ignore rules
60
+ 4. Report a diff summary and pass/fail result
61
+
62
+ ## Usage Examples
63
+
64
+ ### API comparison
65
+
66
+ ```ruby
67
+ old_source = Regresso::Adapters::Http.new(
68
+ base_url: "https://old.example.com",
69
+ endpoint: "/api/v1/reports",
70
+ params: { year: 2024 }
71
+ )
72
+
73
+ new_source = Regresso::Adapters::Http.new(
74
+ base_url: "https://new.example.com",
75
+ endpoint: "/api/v1/reports",
76
+ params: { year: 2024 }
77
+ )
78
+
79
+ result = Regresso::Comparator.new(source_a: old_source, source_b: new_source).compare
80
+ puts result.summary
81
+ ```
82
+
83
+ ### CSV comparison
84
+
85
+ ```ruby
86
+ old_csv = Regresso::Adapters::Csv.new(path: "tmp/old.csv")
87
+ new_csv = Regresso::Adapters::Csv.new(path: "tmp/new.csv")
88
+
89
+ result = Regresso::Comparator.new(source_a: old_csv, source_b: new_csv).compare
90
+ puts result.passed?
91
+ ```
92
+
93
+ ### Snapshot testing
94
+
95
+ ```ruby
96
+ require "regresso/rspec"
97
+
98
+ RSpec.describe "Snapshot" do
99
+ it "matches snapshot" do
100
+ payload = { "total" => 120 }
101
+ expect(payload).to match_snapshot("report_total")
102
+ end
103
+ end
104
+ ```
105
+
106
+ ### Tolerance and ignore paths
107
+
108
+ ```ruby
109
+ expect(new_api).to have_no_regression_from(old_api)
110
+ .with_tolerance(0.01)
111
+ .with_path_tolerance("$.amount", 0.1)
112
+ .ignoring("$.updated_at")
113
+ ```
114
+
115
+ ### Shared examples
116
+
117
+ ```ruby
118
+ require "regresso/rspec/shared_examples"
119
+
120
+ include_examples "regresso:api_regression", {
121
+ old_base_url: ENV["OLD_API"],
122
+ new_base_url: ENV["NEW_API"],
123
+ patterns: [{ endpoint: "/api/v1/reports" }]
124
+ }
125
+ ```
126
+
127
+ ### Database query comparison
128
+
129
+ ```ruby
130
+ old_db = Regresso::Adapters::Database.new(
131
+ connection_config: { adapter: "sqlite3", database: "tmp/old.db" },
132
+ query: "SELECT * FROM users WHERE active = :active",
133
+ params: { active: true },
134
+ row_identifier: :id
135
+ )
136
+
137
+ new_db = Regresso::Adapters::Database.new(
138
+ connection_config: { adapter: "sqlite3", database: "tmp/new.db" },
139
+ query: "SELECT * FROM users WHERE active = :active",
140
+ params: { active: true },
141
+ row_identifier: :id
142
+ )
143
+
144
+ result = Regresso::Comparator.new(source_a: old_db, source_b: new_db).compare
145
+ puts result.summary
146
+ ```
147
+
148
+ ### GraphQL batch comparison
149
+
150
+ ```ruby
151
+ source_a = Regresso::Adapters::GraphQLBatch.new(
152
+ endpoint: "https://old.example.com/graphql",
153
+ queries: [
154
+ { name: "users", query: "{ users { id name } }" },
155
+ { name: "stats", query: "{ stats { total } }" }
156
+ ]
157
+ )
158
+
159
+ source_b = Regresso::Adapters::GraphQLBatch.new(
160
+ endpoint: "https://new.example.com/graphql",
161
+ queries: [
162
+ { name: "users", query: "{ users { id name } }" },
163
+ { name: "stats", query: "{ stats { total } }" }
164
+ ]
165
+ )
166
+
167
+ result = Regresso::Comparator.new(source_a: source_a, source_b: source_b).compare
168
+ puts result.passed?
169
+ ```
170
+
171
+ ### Parallel comparisons
172
+
173
+ ```ruby
174
+ comparisons = [
175
+ {
176
+ name: "sales",
177
+ source_a: Regresso::Adapters::Proc.new { { total: 120 } },
178
+ source_b: Regresso::Adapters::Proc.new { { total: 121 } }
179
+ }
180
+ ]
181
+
182
+ runner = Regresso::Parallel::Runner.new(comparisons: comparisons, workers: 4)
183
+ parallel_result = runner.run
184
+ puts parallel_result.summary
185
+ ```
186
+
187
+ ## Installation
188
+
189
+ Add to your Gemfile:
190
+
191
+ ```bash
192
+ bundle add regresso
193
+ ```
194
+
195
+ Or install directly:
196
+
197
+ ```bash
198
+ gem install regresso
199
+ ```
200
+
201
+ ## Configuration
202
+
203
+ ```ruby
204
+ Regresso.configure do |config|
205
+ config.default_tolerance = 0.01
206
+ config.ignore_paths = [/\.id$/, /\.updated_at$/]
207
+ config.tolerance_overrides = { "$.amount" => 0.1 }
208
+ config.array_order_sensitive = true
209
+ config.type_coercion = true
210
+ end
211
+ ```
212
+
213
+ ## Adapters
214
+
215
+ - HTTP: `Regresso::Adapters::Http`
216
+ - CSV: `Regresso::Adapters::Csv`
217
+ - JSON file: `Regresso::Adapters::JsonFile`
218
+ - Proc: `Regresso::Adapters::Proc`
219
+ - Database query: `Regresso::Adapters::Database`
220
+ - Database snapshot: `Regresso::Adapters::DatabaseSnapshot`
221
+ - GraphQL: `Regresso::Adapters::GraphQL`
222
+ - GraphQL batch: `Regresso::Adapters::GraphQLBatch`
223
+
224
+ ## Test framework integration
225
+
226
+ - RSpec: `require "regresso/rspec"`
227
+ - Minitest: `require "regresso/minitest"`
228
+
229
+ ## Documentation
230
+
231
+ ```bash
232
+ bundle exec rake yard
233
+ ```
234
+
235
+ ## CI reporting
236
+
237
+ ```ruby
238
+ reporter = Regresso::CI::Reporter.new(parallel_result)
239
+ File.write("tmp/regresso.xml", reporter.to_junit_xml)
240
+ ```
241
+
242
+ ## Web UI
243
+
244
+ ```ruby
245
+ require "regresso/web_ui"
246
+
247
+ store = Regresso::WebUI::ResultStore.new(storage_path: "tmp/regresso_results")
248
+ Regresso::WebUI::Server.set :result_store, store
249
+ Regresso::WebUI::Server.run!
250
+ ```
251
+
252
+ ## Contributing
253
+
254
+ Bug reports and pull requests are welcome. Please run tests before submitting changes.
255
+
256
+ ## License
257
+
258
+ MIT License. See `LICENSE.txt` for details.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "yard"
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ YARD::Rake::YardocTask.new(:yard)
9
+
10
+ task default: :spec
11
+
12
+ Dir.glob(File.join(__dir__, "lib/regresso/tasks/**/*.rake")).each { |path| load path }