http_decoy 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1e30669122e0653b4327cc91460096cfc2a560004188b0bf8e678fb475a2ba8f
4
+ data.tar.gz: 3258d93287f014e00dff0795c0a217203c24ed3d877e2d3fb0cfebd75ff574bb
5
+ SHA512:
6
+ metadata.gz: 0a63f8490e679a0e8909fdaadd8db7f94af4751c076d5119bf5e8246587551c28f3b5bb16778b3a7ded2cae1d2b65a1ec9da04d881d8395042c55616d391570d
7
+ data.tar.gz: 2930b0ac10c72d3f2a5c65cfb7de35ee6d6bd1c01c261a0a6478c2bda7c700f409c7f937abfbf8c30d544be77c2703598dbbd967bd65e2d0a02fcea3ed4b01cc
data/.rubocop.yml ADDED
@@ -0,0 +1,102 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ AllCops:
5
+ NewCops: enable
6
+ TargetRubyVersion: 3.1
7
+ Exclude:
8
+ - "bin/**/*"
9
+ - "sig/**/*"
10
+ - "coverage/**/*"
11
+ - "pkg/**/*"
12
+ - "vendor/**/*"
13
+
14
+ # ── Style ──────────────────────────────────────────────────────────────────
15
+
16
+ Style/StringLiterals:
17
+ EnforcedStyle: double_quotes
18
+
19
+ Style/FrozenStringLiteralComment:
20
+ Enabled: true
21
+ EnforcedStyle: always
22
+
23
+ Style/Documentation:
24
+ Enabled: false # internal gem, module-level docs live in README
25
+
26
+ Style/OpenStructUse:
27
+ Enabled: false
28
+
29
+ # Allow one-line method definitions (e.g. def port = @port)
30
+ Style/EndlessMethod:
31
+ Enabled: true
32
+ EnforcedStyle: allow_single_line
33
+
34
+ # ── Layout ─────────────────────────────────────────────────────────────────
35
+
36
+ Layout/LineLength:
37
+ Max: 120
38
+ AllowedPatterns:
39
+ - '^\s*#' # comments can be longer
40
+ - '^\s*it ' # long RSpec descriptions
41
+
42
+ Layout/MultilineMethodCallIndentation:
43
+ EnforcedStyle: indented
44
+
45
+ # ── Metrics ────────────────────────────────────────────────────────────────
46
+
47
+ Metrics/MethodLength:
48
+ Max: 30
49
+ Exclude:
50
+ - "spec/**/*"
51
+
52
+ Metrics/BlockLength:
53
+ Max: 60
54
+ Exclude:
55
+ - "spec/**/*"
56
+ - "httpfake.gemspec"
57
+
58
+ Metrics/AbcSize:
59
+ Max: 40
60
+
61
+ Metrics/ClassLength:
62
+ Max: 150
63
+
64
+ Metrics/CyclomaticComplexity:
65
+ Max: 12
66
+
67
+ Metrics/PerceivedComplexity:
68
+ Max: 12
69
+
70
+ # ── RuboCop-RSpec path convention ──────────────────────────────────────────
71
+ # Our module is HttpFake but the gem/dir is httpfake (no underscore).
72
+ # RSpec/SpecFilePathFormat expects http_fake/ — disable it.
73
+ RSpec/SpecFilePathFormat:
74
+ Enabled: false
75
+
76
+ # ── Lint ───────────────────────────────────────────────────────────────────
77
+ # We intentionally use === for matcher duck-typing in the have_received_request
78
+ # matcher (e.g. RSpec matchers, Ranges, Regexps all respond to ===).
79
+ Style/CaseEquality:
80
+ Exclude:
81
+ - "lib/httpfake/rspec.rb"
82
+
83
+ # Entry uses :http_method not :method, so this is moot — kept for awareness.
84
+ Lint/StructNewOverride:
85
+ Enabled: true
86
+
87
+ # ── RSpec ──────────────────────────────────────────────────────────────────
88
+
89
+ RSpec/ExampleLength:
90
+ Max: 20
91
+
92
+ RSpec/MultipleExpectations:
93
+ Max: 5
94
+
95
+ RSpec/NestedGroups:
96
+ Max: 4
97
+
98
+ RSpec/DescribeClass:
99
+ Enabled: false # integration specs don't always describe a class
100
+
101
+ RSpec/IndexedLet:
102
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,39 @@
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
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] — 2026-06-02
11
+
12
+ ### Added
13
+
14
+ - `HttpFake.define` — declare a named fake service with a DSL block
15
+ - `HttpFake::RouteMap` — route definition DSL (`get`, `post`, `put`, `patch`, `delete`)
16
+ - `HttpFake::Router` — path matching with `:param` template segments
17
+ - `HttpFake::Server` — real WEBrick HTTP server on OS-assigned port (port 0); starts in a background thread, stops cleanly
18
+ - `HttpFake::RequestLog` — thread-safe store of every received request; powers assertion helpers
19
+ - `HttpFake::HandlerContext` — `instance_eval` DSL surface inside handler blocks:
20
+ - `respond(status, json:, text:, headers:)` — build a response
21
+ - `respond_sequence(*entries)` — return different responses on successive calls
22
+ - `requires_body(*keys)` — assert required fields are present; raises `ContractError` with descriptive message if not
23
+ - `validates(key, type:, min:, max:, inclusion:)` — type and range validation
24
+ - `raise_error(:timeout | :reset | :refused)` — simulate transport-level failures
25
+ - `body`, `path_params`, `query_params` — request data accessors
26
+ - Lambdas in JSON response values are resolved at request time (`-> { body[:amount] }`)
27
+ - `fake_server(name) { ... }` — class-level RSpec macro; starts a fresh server per example, tears it down after
28
+ - `HttpFake.define(:name) { ... }.rspec_helpers` — suite-wide helper module pattern
29
+ - `with_scenario(:name) { ... }` — activate a named failure/alternate scenario in a test block
30
+ - `have_received_request(method, path)` — RSpec matcher with `.once`, `.twice`, `.times(n)`, `.with(body:)` chains
31
+ - WebMock auto-detection: if WebMock is loaded and `base_url` is declared, requests are intercepted automatically; teardown removes only httpfake's stub
32
+ - `HttpFake.configure { |c| c.auto_intercept = false }` — opt out of automatic WebMock interception
33
+ - Supports `application/json`, `application/x-www-form-urlencoded`, and raw bodies
34
+ - Compatible with Rack 2.x and Rack 3.x
35
+ - Ruby 3.1+ support
36
+ - 92% test coverage (SimpleCov), 66 examples
37
+
38
+ [Unreleased]: https://github.com/jibranusman/httpfake/compare/v0.1.0...HEAD
39
+ [0.1.0]: https://github.com/jibranusman/httpfake/releases/tag/v0.1.0
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,67 @@
1
+ # Contributing to httpfake
2
+
3
+ Thanks for taking the time. Bug reports, documentation improvements, and feature proposals are all welcome.
4
+
5
+ ## Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/jibranusman/httpfake
9
+ cd httpfake
10
+ bundle install
11
+ ```
12
+
13
+ ## Running the tests
14
+
15
+ ```bash
16
+ bundle exec rspec # full suite
17
+ bundle exec rspec spec/httpfake/server_spec.rb # single file
18
+ ```
19
+
20
+ ## Linting
21
+
22
+ ```bash
23
+ bundle exec rubocop # check
24
+ bundle exec rubocop -a # autocorrect safe offenses
25
+ ```
26
+
27
+ Both must be green before a PR can be merged. CI enforces this on every push.
28
+
29
+ ## Submitting a pull request
30
+
31
+ 1. Fork the repo and create a branch from `main`
32
+ 2. Write a failing test that describes the bug or feature
33
+ 3. Make it pass
34
+ 4. Run `bundle exec rspec` and `bundle exec rubocop` — both must be clean
35
+ 5. Update `CHANGELOG.md` under `[Unreleased]`
36
+ 6. Open a PR with a clear description of what and why
37
+
38
+ ## What we're looking for
39
+
40
+ - Bug fixes with a reproducing spec
41
+ - New DSL features (propose in an issue first if it's non-trivial)
42
+ - Additional body content-type support
43
+ - Better error messages
44
+ - Real-world usage examples in the README
45
+
46
+ ## Good first issues
47
+
48
+ Check the [`good first issue`](https://github.com/jibranusman/httpfake/issues?q=label%3A%22good+first+issue%22) label for beginner-friendly tasks.
49
+
50
+ ## Code style
51
+
52
+ - `frozen_string_literal: true` on every file
53
+ - Follow the existing RuboCop config (`.rubocop.yml`)
54
+ - Keep handler blocks and DSL methods small and focused
55
+ - No clever metaprogramming without a comment explaining why
56
+
57
+ ## Reporting bugs
58
+
59
+ Open a GitHub issue with:
60
+ - Ruby version (`ruby --version`)
61
+ - httpfake version
62
+ - Minimal reproduction case (ideally a failing RSpec example)
63
+ - What you expected vs what happened
64
+
65
+ ## Security issues
66
+
67
+ Do not open a public issue for security vulnerabilities. Email the maintainer directly (address in the gemspec).
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jibran Usman
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 all
13
+ 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 THE
21
+ SOFTWARE.