reynard 0.0.8 → 0.0.9
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 +4 -4
- data/README.md +14 -0
- data/lib/reynard/version.rb +1 -1
- data/lib/reynard.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec98b52096f95c7c03aaa61a7f27555f5d595ab83ac15510e49fbdc600cbb3a0
|
4
|
+
data.tar.gz: e3fc7d6e0aa537ea08c727e89aec68b2e66986f5e4e1e53ebd6f74733bde6b8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b18bf2403a99460ded8be2c85efc08b28ffa8616d35628dbdb0806f58613e426acf48eff05d6f0c74bc0e602ed9a0bb6bc69e3604818b6b7a1ba9f1c4f38848
|
7
|
+
data.tar.gz: c566c502480ff527e5e8a6451bebd5b8629c714fb41a27faa486a311fb8a20ee85aea14d1c89c211fe20e6dd63e768027d678593341178d89177cda3f24512df
|
data/README.md
CHANGED
@@ -66,6 +66,20 @@ employee = reynard.
|
|
66
66
|
execute
|
67
67
|
```
|
68
68
|
|
69
|
+
## Mocking
|
70
|
+
|
71
|
+
You can mock Reynard requests by changing the HTTP implementation. The class **must** implement a single `request` method that accepts an URI and net/http request object. It **must** return a net/http response object or an object with the exact same interface.
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
Reynard.http = MyMock.new
|
75
|
+
|
76
|
+
class MyMock
|
77
|
+
def request(uri, net_http_request)
|
78
|
+
Net::HTTPResponse::CODE_TO_OBJ['404'].new('HTTP/1.1', '200', 'OK')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
```
|
82
|
+
|
69
83
|
## Copyright and other legal
|
70
84
|
|
71
85
|
See LICENCE.
|
data/lib/reynard/version.rb
CHANGED
data/lib/reynard.rb
CHANGED
@@ -34,6 +34,14 @@ class Reynard
|
|
34
34
|
@specification = Specification.new(filename: filename)
|
35
35
|
end
|
36
36
|
|
37
|
+
# Assign an object that follows Reynard's internal request interface to mock requests or use a
|
38
|
+
# different HTTP client.
|
39
|
+
class << self
|
40
|
+
attr_writer :http
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns Reynard's global request interface. This is a global object to allow persistent
|
44
|
+
# connections, caching, and other features that need a persistent object in the process.
|
37
45
|
def self.http
|
38
46
|
@http ||= begin
|
39
47
|
http = Net::HTTP::Persistent.new(name: 'Reynard')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reynard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manfred Stienstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|