waithook 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -9
- data/README.md +5 -4
- data/lib/waithook/cli.rb +1 -1
- data/lib/waithook/version.rb +1 -1
- data/tests/server_test.rb +25 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a26ed1226248d9e7c723e90350cbd4aac3e79f34
|
4
|
+
data.tar.gz: 8bfd8186172f19c10097a9cafe096a83d3217efc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81bae6f2664ba1e400c578c4ef8c4e5f218dd2ee456b707702ca7a3ee24e7634b2ad06c1e19e52648eb0c278b9bf4fa912ec740c4a76cb23fd96258ed6192a4b
|
7
|
+
data.tar.gz: 813f5cf7e5654427189ad78157bee4c2642247f7bfdd0ee85a42d032402b234e607fa60ced2c942c6566dbde019b98648c3378322cef1b98497056cc6fb1047e
|
data/Gemfile.lock
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
waithook (0.2)
|
4
|
+
waithook (0.3.2)
|
5
5
|
websocket (~> 1.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
addressable (2.5.
|
11
|
-
public_suffix (
|
10
|
+
addressable (2.5.2)
|
11
|
+
public_suffix (>= 2.0.2, < 4.0)
|
12
12
|
ansi (1.5.0)
|
13
13
|
builder (3.2.3)
|
14
|
-
excon (0.
|
15
|
-
minitest (5.10.
|
16
|
-
minitest-reporters (1.1.
|
14
|
+
excon (0.58.0)
|
15
|
+
minitest (5.10.3)
|
16
|
+
minitest-reporters (1.1.16)
|
17
17
|
ansi
|
18
18
|
builder
|
19
19
|
minitest (>= 5.0)
|
20
20
|
ruby-progressbar
|
21
|
-
public_suffix (
|
21
|
+
public_suffix (3.0.0)
|
22
22
|
rake (12.0.0)
|
23
23
|
ruby-progressbar (1.8.1)
|
24
|
-
websocket (1.2.
|
24
|
+
websocket (1.2.4)
|
25
25
|
|
26
26
|
PLATFORMS
|
27
27
|
ruby
|
@@ -34,4 +34,4 @@ DEPENDENCIES
|
|
34
34
|
waithook!
|
35
35
|
|
36
36
|
BUNDLED WITH
|
37
|
-
1.
|
37
|
+
1.15.3
|
data/README.md
CHANGED
@@ -15,18 +15,19 @@ gem install waithook
|
|
15
15
|
```
|
16
16
|
|
17
17
|
Subscribe and print incoming requests:
|
18
|
-
|
18
|
+
```sh
|
19
19
|
waithook waithook.com/my_path
|
20
20
|
```
|
21
21
|
|
22
22
|
Subscribe and forvard to other web server:
|
23
|
-
|
23
|
+
```sh
|
24
24
|
waithook waithook.com/my_path --forward http://localhost:3000/notify
|
25
25
|
```
|
26
26
|
|
27
27
|
### Ruby API
|
28
28
|
|
29
29
|
```ruby
|
30
|
+
Waithook.default_path = 'my-notification-endpoint' # or using ":path" option in Waithook.subscribe
|
30
31
|
waithook = Waithook.subscribe(timeout: 60, raise_on_timeout: true) do |webhook|
|
31
32
|
webhook.json_body['order_id'] == order_id
|
32
33
|
end
|
@@ -34,7 +35,7 @@ end
|
|
34
35
|
waithook.send_to("http://localhost:3000/notify")
|
35
36
|
```
|
36
37
|
|
37
|
-
###
|
38
|
+
### When it can be used?
|
38
39
|
|
39
40
|
* Testing integration with payment gateway
|
40
41
|
* Testing github webhooks
|
@@ -42,5 +43,5 @@ waithook.send_to("http://localhost:3000/notify")
|
|
42
43
|
* Testing slack bots
|
43
44
|
* Testing facebook webhooks
|
44
45
|
|
45
|
-
|
46
|
+
Waithook service just help to deliver webhook to your application when public IP is unknown or not available. It can help when multiple developers testing integration with other service on localhost or your automated tests running in CI.
|
46
47
|
|
data/lib/waithook/cli.rb
CHANGED
data/lib/waithook/version.rb
CHANGED
data/tests/server_test.rb
CHANGED
@@ -69,7 +69,7 @@ describe "Server" do
|
|
69
69
|
it "should serve index.html" do
|
70
70
|
response = GET("")
|
71
71
|
|
72
|
-
assert_includes(response.body, "<html>")
|
72
|
+
assert_includes(response.body, "<html lang='en'>")
|
73
73
|
assert_equal({
|
74
74
|
"Connection" => "close",
|
75
75
|
"Content-Length" => response.headers["Content-Length"],
|
@@ -156,4 +156,28 @@ describe "Server" do
|
|
156
156
|
response = POST(PATH + "?type=slack", '{"challenge": []}')
|
157
157
|
assert_equal(response.body, "OK\n")
|
158
158
|
end
|
159
|
+
|
160
|
+
it "should response with custom body" do
|
161
|
+
response = POST(PATH + "?resp=foo", "AAA")
|
162
|
+
assert_equal(response.body, "foo")
|
163
|
+
assert_equal(response.headers['Content-Type'], "text/plain")
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should response with custom content type" do
|
167
|
+
response = POST(PATH + "?resp=foo&resp_type=text/csv", "AAA")
|
168
|
+
assert_equal(response.body, "foo")
|
169
|
+
assert_equal(response.headers['Content-Type'], "text/csv")
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should support shortcuts for resp_type" do
|
173
|
+
shortcuts = {
|
174
|
+
json: "application/json",
|
175
|
+
xml: "application/xml",
|
176
|
+
html: "text/html"
|
177
|
+
}
|
178
|
+
shortcuts.each do |short, long|
|
179
|
+
response = POST(PATH + "?resp=foo&resp_type=#{short}", "AAA")
|
180
|
+
assert_equal(response.headers['Content-Type'], long)
|
181
|
+
end
|
182
|
+
end
|
159
183
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waithook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Evstigneev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket
|