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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d214777edd71e383a966f35752f38f26346242b2
4
- data.tar.gz: 1ed8fefa24cab78bd6daefe80360c891d256b146
3
+ metadata.gz: a26ed1226248d9e7c723e90350cbd4aac3e79f34
4
+ data.tar.gz: 8bfd8186172f19c10097a9cafe096a83d3217efc
5
5
  SHA512:
6
- metadata.gz: 97e70f11d204e89e9dcf173f7c6c212c52e1dfd7486ec1b0deac9e04c5067692855cb9e2d1f1cf01024e6778bef01a746672653bee7c8777e96d2ac73a79ad7d
7
- data.tar.gz: b65223696ed2b22744d51093a3bcee3f8419b64387b1ba9dc8b5501a8c7f639bfb007b7ff8e8a50403d0d489a92e7c2563bb70e540586a99c4ea6fe840210142
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.0)
11
- public_suffix (~> 2.0, >= 2.0.2)
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.54.0)
15
- minitest (5.10.1)
16
- minitest-reporters (1.1.14)
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 (2.0.5)
21
+ public_suffix (3.0.0)
22
22
  rake (12.0.0)
23
23
  ruby-progressbar (1.8.1)
24
- websocket (1.2.3)
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.14.2
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
- ````sh
18
+ ```sh
19
19
  waithook waithook.com/my_path
20
20
  ```
21
21
 
22
22
  Subscribe and forvard to other web server:
23
- ````sh
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
- ### Usage examples
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
- So waithook 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
+ 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
@@ -21,7 +21,7 @@ class Waithook
21
21
  def listen(url, options)
22
22
  puts "Run with options: #{options}" if options[:verbose]
23
23
  unless url.start_with?('ws://', 'wss://')
24
- url = 'wss://' + url
24
+ url = 'ws://' + url
25
25
  end
26
26
 
27
27
  unless url =~ /\A#{URI::regexp(['ws', 'wss'])}\z/
@@ -1,3 +1,3 @@
1
1
  class Waithook
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
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.2
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-02-16 00:00:00.000000000 Z
11
+ date: 2017-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket