routemaster-client 1.2.1 → 1.2.2
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/.gitmodules +0 -3
- data/.ruby-version +1 -1
- data/.travis.yml +4 -13
- data/Gemfile +2 -1
- data/Gemfile.lock +58 -44
- data/Gemfile.lock.updated +100 -0
- data/LICENSE.txt +2 -1
- data/README.md +4 -4
- data/routemaster/client/version.rb +1 -1
- data/routemaster/client.rb +1 -1
- data/routemaster-client.gemspec +3 -3
- data/spec/client_spec.rb +73 -50
- data/spec/receiver_spec.rb +3 -2
- metadata +9 -10
- data/spec/support/rack_test.rb +0 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d9f9dd8c84df18d79d2a320e0790dafc18439b04
|
|
4
|
+
data.tar.gz: afbff019ebff4328bc489a04669d939ffd646847
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 722006ea6038bada4f48b65f97e8a7f48e6ba58ddd82b2534b99ed5648eee8c117dbffde4c34ea57a6126d2408e1a3fee7b10fab3d46dbdfecadcb263a9f7047
|
|
7
|
+
data.tar.gz: d5d48a0e5e50f62a63bf091656ee8bee4702c9ea84420ab14cabb6ab68ebfc5f15c9f8a4fe1b99d0a81aad656420d3e7e4c562de58b578ea975726d4bd6d5258
|
data/.gitmodules
CHANGED
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.3.1
|
data/.travis.yml
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
language: ruby
|
|
2
|
+
cache: bundler
|
|
2
3
|
rvm:
|
|
3
|
-
- 1.9.3
|
|
4
4
|
- 2.0.0
|
|
5
|
-
- 2.1.
|
|
6
|
-
- 2.
|
|
7
|
-
- 2.
|
|
8
|
-
- 2.2.2
|
|
5
|
+
- 2.1.9
|
|
6
|
+
- 2.2.5
|
|
7
|
+
- 2.3.1
|
|
9
8
|
script:
|
|
10
9
|
- bundle exec rspec
|
|
11
|
-
install:
|
|
12
|
-
- "./rebund/run download"
|
|
13
|
-
- bundle install --path vendor/bundle
|
|
14
|
-
after_script:
|
|
15
|
-
- "./rebund/run upload"
|
|
16
|
-
env:
|
|
17
|
-
global:
|
|
18
|
-
secure: "kMxJcT8xyQ+QyCeKW5lDP44IU99Y8iN1AWZo9Z1BKN6HigGa8Ua8O/aD8AJjrTfRRSjnM402utmW6mk78RYVxJha3+69jJYr25I9EeyYhV2cuRu+5Ictxfcb9R9VhS0b6LDncz9h55xDS1UA35rvj+EOO4/M9moccw7T2qzPa2U="
|
data/Gemfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
source
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
3
|
# Specify your gem's dependencies in routemaster_client.gemspec
|
|
4
4
|
gemspec
|
|
@@ -6,6 +6,7 @@ gemspec
|
|
|
6
6
|
# just here to avoid a safety warning
|
|
7
7
|
gem 'psych'
|
|
8
8
|
|
|
9
|
+
# development/testing gems
|
|
9
10
|
gem 'bundler'
|
|
10
11
|
gem 'rake'
|
|
11
12
|
gem 'guard-rspec'
|
data/Gemfile.lock
CHANGED
|
@@ -1,76 +1,87 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
routemaster-client (1.2.
|
|
4
|
+
routemaster-client (1.2.2)
|
|
5
5
|
faraday (>= 0.9.0)
|
|
6
|
-
net-http-persistent
|
|
7
|
-
wisper (>= 1.
|
|
6
|
+
net-http-persistent (>= 2.9.4)
|
|
7
|
+
wisper (>= 1.6.1)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
addressable (2.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
coderay (1.1.0)
|
|
16
|
-
crack (0.4.2)
|
|
12
|
+
addressable (2.4.0)
|
|
13
|
+
coderay (1.1.1)
|
|
14
|
+
crack (0.4.3)
|
|
17
15
|
safe_yaml (~> 1.0.0)
|
|
18
16
|
diff-lcs (1.2.5)
|
|
19
|
-
faraday (0.9.
|
|
17
|
+
faraday (0.9.2)
|
|
20
18
|
multipart-post (>= 1.2, < 3)
|
|
21
|
-
ffi (1.9.
|
|
19
|
+
ffi (1.9.12)
|
|
22
20
|
formatador (0.2.5)
|
|
23
|
-
guard (2.
|
|
21
|
+
guard (2.14.0)
|
|
24
22
|
formatador (>= 0.2.4)
|
|
25
|
-
listen (
|
|
23
|
+
listen (>= 2.7, < 4.0)
|
|
26
24
|
lumberjack (~> 1.0)
|
|
25
|
+
nenv (~> 0.1)
|
|
26
|
+
notiffany (~> 0.0)
|
|
27
27
|
pry (>= 0.9.12)
|
|
28
|
+
shellany (~> 0.0)
|
|
28
29
|
thor (>= 0.18.1)
|
|
29
|
-
guard-
|
|
30
|
+
guard-compat (1.2.1)
|
|
31
|
+
guard-rspec (4.7.2)
|
|
30
32
|
guard (~> 2.1)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
rb-
|
|
36
|
-
|
|
33
|
+
guard-compat (~> 1.1)
|
|
34
|
+
rspec (>= 2.99.0, < 4.0)
|
|
35
|
+
hashdiff (0.3.0)
|
|
36
|
+
listen (3.0.8)
|
|
37
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
|
38
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
|
39
|
+
ruby_dep (~> 1.2)
|
|
40
|
+
lumberjack (1.0.10)
|
|
37
41
|
method_source (0.8.2)
|
|
38
42
|
multipart-post (2.0.0)
|
|
43
|
+
nenv (0.3.0)
|
|
39
44
|
net-http-persistent (2.9.4)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
notiffany (0.1.0)
|
|
46
|
+
nenv (~> 0.1)
|
|
47
|
+
shellany (~> 0.0)
|
|
48
|
+
pry (0.10.3)
|
|
49
|
+
coderay (~> 1.1.0)
|
|
50
|
+
method_source (~> 0.8.1)
|
|
43
51
|
slop (~> 3.4)
|
|
44
|
-
pry-nav (0.2.
|
|
45
|
-
pry (
|
|
46
|
-
psych (2.0
|
|
47
|
-
rack (1.6.
|
|
48
|
-
rack-test (0.6.
|
|
52
|
+
pry-nav (0.2.4)
|
|
53
|
+
pry (>= 0.9.10, < 0.11.0)
|
|
54
|
+
psych (2.1.0)
|
|
55
|
+
rack (1.6.4)
|
|
56
|
+
rack-test (0.6.3)
|
|
49
57
|
rack (>= 1.0)
|
|
50
|
-
rake (
|
|
51
|
-
rb-fsevent (0.9.
|
|
52
|
-
rb-inotify (0.9.
|
|
58
|
+
rake (11.2.2)
|
|
59
|
+
rb-fsevent (0.9.7)
|
|
60
|
+
rb-inotify (0.9.7)
|
|
53
61
|
ffi (>= 0.5.0)
|
|
54
|
-
rspec (3.
|
|
55
|
-
rspec-core (~> 3.
|
|
56
|
-
rspec-expectations (~> 3.
|
|
57
|
-
rspec-mocks (~> 3.
|
|
58
|
-
rspec-core (3.0
|
|
59
|
-
rspec-support (~> 3.
|
|
60
|
-
rspec-expectations (3.0
|
|
62
|
+
rspec (3.5.0)
|
|
63
|
+
rspec-core (~> 3.5.0)
|
|
64
|
+
rspec-expectations (~> 3.5.0)
|
|
65
|
+
rspec-mocks (~> 3.5.0)
|
|
66
|
+
rspec-core (3.5.0)
|
|
67
|
+
rspec-support (~> 3.5.0)
|
|
68
|
+
rspec-expectations (3.5.0)
|
|
61
69
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
62
|
-
rspec-support (~> 3.
|
|
63
|
-
rspec-mocks (3.0
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
rspec-support (~> 3.5.0)
|
|
71
|
+
rspec-mocks (3.5.0)
|
|
72
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
73
|
+
rspec-support (~> 3.5.0)
|
|
74
|
+
rspec-support (3.5.0)
|
|
75
|
+
ruby_dep (1.3.1)
|
|
66
76
|
safe_yaml (1.0.4)
|
|
77
|
+
shellany (0.0.1)
|
|
67
78
|
slop (3.6.0)
|
|
68
79
|
thor (0.19.1)
|
|
69
|
-
|
|
70
|
-
webmock (1.18.0)
|
|
80
|
+
webmock (2.1.0)
|
|
71
81
|
addressable (>= 2.3.6)
|
|
72
82
|
crack (>= 0.3.2)
|
|
73
|
-
|
|
83
|
+
hashdiff
|
|
84
|
+
wisper (1.6.1)
|
|
74
85
|
|
|
75
86
|
PLATFORMS
|
|
76
87
|
ruby
|
|
@@ -84,3 +95,6 @@ DEPENDENCIES
|
|
|
84
95
|
rake
|
|
85
96
|
routemaster-client!
|
|
86
97
|
webmock
|
|
98
|
+
|
|
99
|
+
BUNDLED WITH
|
|
100
|
+
1.12.5
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
routemaster-client (1.2.1)
|
|
5
|
+
faraday (>= 0.9.0)
|
|
6
|
+
net-http-persistent
|
|
7
|
+
wisper (>= 1.4.0)
|
|
8
|
+
|
|
9
|
+
GEM
|
|
10
|
+
remote: https://rubygems.org/
|
|
11
|
+
specs:
|
|
12
|
+
addressable (2.4.0)
|
|
13
|
+
coderay (1.1.1)
|
|
14
|
+
crack (0.4.3)
|
|
15
|
+
safe_yaml (~> 1.0.0)
|
|
16
|
+
diff-lcs (1.2.5)
|
|
17
|
+
faraday (0.9.2)
|
|
18
|
+
multipart-post (>= 1.2, < 3)
|
|
19
|
+
ffi (1.9.12)
|
|
20
|
+
formatador (0.2.5)
|
|
21
|
+
guard (2.14.0)
|
|
22
|
+
formatador (>= 0.2.4)
|
|
23
|
+
listen (>= 2.7, < 4.0)
|
|
24
|
+
lumberjack (~> 1.0)
|
|
25
|
+
nenv (~> 0.1)
|
|
26
|
+
notiffany (~> 0.0)
|
|
27
|
+
pry (>= 0.9.12)
|
|
28
|
+
shellany (~> 0.0)
|
|
29
|
+
thor (>= 0.18.1)
|
|
30
|
+
guard-compat (1.2.1)
|
|
31
|
+
guard-rspec (4.7.2)
|
|
32
|
+
guard (~> 2.1)
|
|
33
|
+
guard-compat (~> 1.1)
|
|
34
|
+
rspec (>= 2.99.0, < 4.0)
|
|
35
|
+
hashdiff (0.3.0)
|
|
36
|
+
listen (3.1.5)
|
|
37
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
|
38
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
|
39
|
+
ruby_dep (~> 1.2)
|
|
40
|
+
lumberjack (1.0.10)
|
|
41
|
+
method_source (0.8.2)
|
|
42
|
+
multipart-post (2.0.0)
|
|
43
|
+
nenv (0.3.0)
|
|
44
|
+
net-http-persistent (2.9.4)
|
|
45
|
+
notiffany (0.1.0)
|
|
46
|
+
nenv (~> 0.1)
|
|
47
|
+
shellany (~> 0.0)
|
|
48
|
+
pry (0.10.3)
|
|
49
|
+
coderay (~> 1.1.0)
|
|
50
|
+
method_source (~> 0.8.1)
|
|
51
|
+
slop (~> 3.4)
|
|
52
|
+
pry-nav (0.2.4)
|
|
53
|
+
pry (>= 0.9.10, < 0.11.0)
|
|
54
|
+
psych (2.1.0)
|
|
55
|
+
rack (2.0.1)
|
|
56
|
+
rack-test (0.6.3)
|
|
57
|
+
rack (>= 1.0)
|
|
58
|
+
rake (11.2.2)
|
|
59
|
+
rb-fsevent (0.9.7)
|
|
60
|
+
rb-inotify (0.9.7)
|
|
61
|
+
ffi (>= 0.5.0)
|
|
62
|
+
rspec (3.5.0)
|
|
63
|
+
rspec-core (~> 3.5.0)
|
|
64
|
+
rspec-expectations (~> 3.5.0)
|
|
65
|
+
rspec-mocks (~> 3.5.0)
|
|
66
|
+
rspec-core (3.5.0)
|
|
67
|
+
rspec-support (~> 3.5.0)
|
|
68
|
+
rspec-expectations (3.5.0)
|
|
69
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
70
|
+
rspec-support (~> 3.5.0)
|
|
71
|
+
rspec-mocks (3.5.0)
|
|
72
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
73
|
+
rspec-support (~> 3.5.0)
|
|
74
|
+
rspec-support (3.5.0)
|
|
75
|
+
ruby_dep (1.3.1)
|
|
76
|
+
safe_yaml (1.0.4)
|
|
77
|
+
shellany (0.0.1)
|
|
78
|
+
slop (3.6.0)
|
|
79
|
+
thor (0.19.1)
|
|
80
|
+
webmock (2.1.0)
|
|
81
|
+
addressable (>= 2.3.6)
|
|
82
|
+
crack (>= 0.3.2)
|
|
83
|
+
hashdiff
|
|
84
|
+
wisper (1.6.1)
|
|
85
|
+
|
|
86
|
+
PLATFORMS
|
|
87
|
+
ruby
|
|
88
|
+
|
|
89
|
+
DEPENDENCIES
|
|
90
|
+
bundler
|
|
91
|
+
guard-rspec
|
|
92
|
+
pry-nav
|
|
93
|
+
psych
|
|
94
|
+
rack-test
|
|
95
|
+
rake
|
|
96
|
+
routemaster-client!
|
|
97
|
+
webmock
|
|
98
|
+
|
|
99
|
+
BUNDLED WITH
|
|
100
|
+
1.12.5
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# routemaster-client
|
|
2
2
|
|
|
3
|
-
A Ruby API for the [Routemaster](https://github.com/
|
|
3
|
+
A Ruby API for the [Routemaster](https://github.com/mezis/routemaster) event
|
|
4
4
|
bus.
|
|
5
5
|
|
|
6
6
|
[](https://rubygems.org/gems/routemaster-client)
|
|
7
7
|
|
|
8
|
-
[](https://travis-ci.org/mezis/routemaster-client)
|
|
9
9
|
|
|
10
|
-
[](http://rubydoc.info/github/
|
|
10
|
+
[](http://rubydoc.info/github/mezis/routemaster-client/frames/file/README.md)
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
@@ -111,7 +111,7 @@ client.monitor_subscriptions
|
|
|
111
111
|
|
|
112
112
|
## Contributing
|
|
113
113
|
|
|
114
|
-
1. Fork it ( http://github.com/
|
|
114
|
+
1. Fork it ( http://github.com/mezis/routemaster-client/fork )
|
|
115
115
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
116
116
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
117
117
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/routemaster/client.rb
CHANGED
|
@@ -92,7 +92,7 @@ module Routemaster
|
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
def _assert_valid_topic(topic)
|
|
95
|
-
_assert (topic =~ /^[a-z_]{1,
|
|
95
|
+
_assert (topic =~ /^[a-z_]{1,64}$/), 'bad topic name: must only include letters and underscores'
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
def _assert_valid_timestamp(timestamp)
|
data/routemaster-client.gemspec
CHANGED
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.authors = ['Julien Letessier']
|
|
10
10
|
spec.email = ['julien.letessier@gmail.com']
|
|
11
11
|
spec.summary = %q{Client API for the Routemaster event bus}
|
|
12
|
-
spec.homepage = 'http://github.com/
|
|
12
|
+
spec.homepage = 'http://github.com/mezis/routemaster-client'
|
|
13
13
|
spec.license = 'MIT'
|
|
14
14
|
|
|
15
15
|
spec.files = `git ls-files`.split($/)
|
|
@@ -17,6 +17,6 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.require_paths = %w(.)
|
|
18
18
|
|
|
19
19
|
spec.add_runtime_dependency 'faraday', '>= 0.9.0'
|
|
20
|
-
spec.add_runtime_dependency 'net-http-persistent'
|
|
21
|
-
spec.add_runtime_dependency 'wisper', '>= 1.
|
|
20
|
+
spec.add_runtime_dependency 'net-http-persistent', '>= 2.9.4'
|
|
21
|
+
spec.add_runtime_dependency 'wisper', '>= 1.6.1'
|
|
22
22
|
end
|
data/spec/client_spec.rb
CHANGED
|
@@ -7,11 +7,14 @@ describe Routemaster::Client do
|
|
|
7
7
|
let(:options) do
|
|
8
8
|
{ url: 'https://bus.example.com', uuid: 'john_doe' }
|
|
9
9
|
end
|
|
10
|
+
let(:pulse_response) { 204 }
|
|
10
11
|
|
|
11
12
|
subject { described_class.new(options) }
|
|
12
13
|
|
|
13
14
|
before do
|
|
14
|
-
@stub_pulse = stub_request(:get, %r{^https
|
|
15
|
+
@stub_pulse = stub_request(:get, %r{^https://bus.example.com/pulse$}).
|
|
16
|
+
with(basic_auth: [options[:uuid], 'x']).
|
|
17
|
+
to_return(status: pulse_response)
|
|
15
18
|
end
|
|
16
19
|
|
|
17
20
|
describe '#initialize' do
|
|
@@ -36,12 +39,13 @@ describe Routemaster::Client do
|
|
|
36
39
|
|
|
37
40
|
context 'when connection fails' do
|
|
38
41
|
before do
|
|
39
|
-
stub_request(:any, %r{^https
|
|
42
|
+
stub_request(:any, %r{^https://bus.example.com}).
|
|
43
|
+
with(basic_auth: [options[:uuid], 'x']).
|
|
40
44
|
to_raise(Faraday::ConnectionFailed)
|
|
41
45
|
end
|
|
42
46
|
|
|
43
47
|
it 'fails' do
|
|
44
|
-
expect { subject }.to raise_error
|
|
48
|
+
expect { subject }.to raise_error(Faraday::ConnectionFailed)
|
|
45
49
|
end
|
|
46
50
|
|
|
47
51
|
it 'passes if :lazy' do
|
|
@@ -50,14 +54,17 @@ describe Routemaster::Client do
|
|
|
50
54
|
end
|
|
51
55
|
end
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
context 'when the heartbeat fails' do
|
|
58
|
+
let(:pulse_response) { 500 }
|
|
59
|
+
|
|
60
|
+
it 'fails if it does not get a successful heartbeat from the app' do
|
|
61
|
+
expect { subject }.to raise_error(RuntimeError)
|
|
62
|
+
end
|
|
56
63
|
end
|
|
57
64
|
|
|
58
65
|
it 'fails if the timeout value is not an integer' do
|
|
59
66
|
options[:timeout] = 'timeout'
|
|
60
|
-
expect { subject }.to raise_error
|
|
67
|
+
expect { subject }.to raise_error(ArgumentError)
|
|
61
68
|
end
|
|
62
69
|
end
|
|
63
70
|
|
|
@@ -65,48 +72,61 @@ describe Routemaster::Client do
|
|
|
65
72
|
let(:callback) { 'https://app.example.com/widgets/123' }
|
|
66
73
|
let(:topic) { 'widgets' }
|
|
67
74
|
let(:perform) { subject.send(event, topic, callback) }
|
|
75
|
+
let(:http_status) { nil }
|
|
68
76
|
|
|
69
77
|
before do
|
|
70
|
-
@stub = stub_request(
|
|
71
|
-
:
|
|
72
|
-
).with(status: 200)
|
|
73
|
-
end
|
|
78
|
+
@stub = stub_request(:post, 'https://bus.example.com/topics/widgets').
|
|
79
|
+
with(basic_auth: [options[:uuid], 'x'])
|
|
74
80
|
|
|
75
|
-
|
|
76
|
-
perform
|
|
77
|
-
expect(@stub).to have_been_requested
|
|
81
|
+
@stub.to_return(status: http_status) if http_status
|
|
78
82
|
end
|
|
79
83
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
context 'when the bus responds 200' do
|
|
85
|
+
let(:http_status) { 200 }
|
|
86
|
+
|
|
87
|
+
it 'sends the event' do
|
|
88
|
+
perform
|
|
89
|
+
expect(@stub).to have_been_requested
|
|
83
90
|
end
|
|
84
|
-
perform
|
|
85
|
-
end
|
|
86
91
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
it 'sends a JSON payload' do
|
|
93
|
+
@stub.with do |req|
|
|
94
|
+
expect(req.headers['Content-Type']).to eq('application/json')
|
|
95
|
+
end
|
|
96
|
+
perform
|
|
97
|
+
end
|
|
91
98
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
99
|
+
it 'fails with a bad callback URL' do
|
|
100
|
+
callback.replace 'http.foo.bar'
|
|
101
|
+
expect { perform }.to raise_error(ArgumentError)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it 'fails with a non-SSL URL' do
|
|
105
|
+
callback.replace 'http://example.com'
|
|
106
|
+
expect { perform }.to raise_error(ArgumentError)
|
|
107
|
+
end
|
|
96
108
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
109
|
+
it 'fails with a bad topic name' do
|
|
110
|
+
topic.replace 'foo123$bar'
|
|
111
|
+
expect { perform }.to raise_error(ArgumentError, 'bad topic name: must only include letters and underscores')
|
|
112
|
+
end
|
|
100
113
|
end
|
|
101
114
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
115
|
+
context 'when the bus responds 500' do
|
|
116
|
+
let(:http_status) { 500 }
|
|
117
|
+
|
|
118
|
+
it 'raises an exception' do
|
|
119
|
+
expect { perform }.to raise_error(RuntimeError)
|
|
120
|
+
end
|
|
105
121
|
end
|
|
106
122
|
|
|
107
|
-
|
|
108
|
-
@stub.to_timeout
|
|
109
|
-
|
|
123
|
+
context 'when the bus times out' do
|
|
124
|
+
before { @stub.to_timeout }
|
|
125
|
+
|
|
126
|
+
it 'fails' do
|
|
127
|
+
@stub.to_timeout
|
|
128
|
+
expect { perform }.to raise_error(Faraday::TimeoutError)
|
|
129
|
+
end
|
|
110
130
|
end
|
|
111
131
|
|
|
112
132
|
context 'with explicit timestamp' do
|
|
@@ -114,9 +134,12 @@ describe Routemaster::Client do
|
|
|
114
134
|
let(:perform) { subject.send(event, topic, callback, timestamp) }
|
|
115
135
|
|
|
116
136
|
before do
|
|
117
|
-
@stub = stub_request(
|
|
118
|
-
|
|
119
|
-
|
|
137
|
+
@stub = stub_request(:post, 'https://@bus.example.com/topics/widgets').
|
|
138
|
+
with(
|
|
139
|
+
body: { type: anything, url: callback, timestamp: timestamp },
|
|
140
|
+
basic_auth: [options[:uuid], 'x'],
|
|
141
|
+
).
|
|
142
|
+
to_return(status: 200)
|
|
120
143
|
end
|
|
121
144
|
|
|
122
145
|
it 'sends the event' do
|
|
@@ -128,7 +151,7 @@ describe Routemaster::Client do
|
|
|
128
151
|
let(:timestamp) { 'foo' }
|
|
129
152
|
|
|
130
153
|
it 'fails with non-numeric timestamp' do
|
|
131
|
-
expect { perform }.to raise_error
|
|
154
|
+
expect { perform }.to raise_error(ArgumentError)
|
|
132
155
|
end
|
|
133
156
|
end
|
|
134
157
|
end
|
|
@@ -164,9 +187,9 @@ describe Routemaster::Client do
|
|
|
164
187
|
}}
|
|
165
188
|
|
|
166
189
|
before do
|
|
167
|
-
@stub = stub_request(
|
|
168
|
-
|
|
169
|
-
|
|
190
|
+
@stub = stub_request(:post, 'https://bus.example.com/subscription').
|
|
191
|
+
with(basic_auth: [options[:uuid], 'x']).
|
|
192
|
+
with { |r|
|
|
170
193
|
r.headers['Content-Type'] == 'application/json' &&
|
|
171
194
|
JSON.parse(r.body).all? { |k,v| subscribe_options[k.to_sym] == v }
|
|
172
195
|
}
|
|
@@ -222,13 +245,13 @@ describe Routemaster::Client do
|
|
|
222
245
|
end
|
|
223
246
|
|
|
224
247
|
before do
|
|
225
|
-
@stub = stub_request(
|
|
226
|
-
:
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
248
|
+
@stub = stub_request(:get, 'https://bus.example.com/topics').
|
|
249
|
+
with(basic_auth: [options[:uuid], 'x']).
|
|
250
|
+
with { |r|
|
|
251
|
+
r.headers['Content-Type'] == 'application/json'
|
|
252
|
+
}.to_return {
|
|
253
|
+
{ status: 200, body: expected_result.to_json }
|
|
254
|
+
}
|
|
232
255
|
end
|
|
233
256
|
|
|
234
257
|
it 'expects a collection of topics' do
|
data/spec/receiver_spec.rb
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
-
require '
|
|
2
|
+
require 'rack/test'
|
|
3
3
|
require 'routemaster/receiver'
|
|
4
4
|
|
|
5
5
|
describe Routemaster::Receiver do
|
|
6
|
+
include Rack::Test::Methods
|
|
7
|
+
|
|
6
8
|
let(:handler) { double 'handler', on_events: nil, on_events_received: true }
|
|
7
9
|
let(:app) { described_class.new(fake_app, options) }
|
|
8
10
|
|
|
9
|
-
|
|
10
11
|
def perform
|
|
11
12
|
post '/events', payload, 'CONTENT_TYPE' => 'application/json'
|
|
12
13
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: routemaster-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Julien Letessier
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-08-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -30,28 +30,28 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: 2.9.4
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
40
|
+
version: 2.9.4
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: wisper
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 1.
|
|
47
|
+
version: 1.6.1
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 1.
|
|
54
|
+
version: 1.6.1
|
|
55
55
|
description:
|
|
56
56
|
email:
|
|
57
57
|
- julien.letessier@gmail.com
|
|
@@ -66,6 +66,7 @@ files:
|
|
|
66
66
|
- ".travis.yml"
|
|
67
67
|
- Gemfile
|
|
68
68
|
- Gemfile.lock
|
|
69
|
+
- Gemfile.lock.updated
|
|
69
70
|
- Guardfile
|
|
70
71
|
- LICENSE.txt
|
|
71
72
|
- README.md
|
|
@@ -80,9 +81,8 @@ files:
|
|
|
80
81
|
- spec/client_spec.rb
|
|
81
82
|
- spec/receiver_spec.rb
|
|
82
83
|
- spec/spec_helper.rb
|
|
83
|
-
- spec/support/rack_test.rb
|
|
84
84
|
- spec/topic_spec.rb
|
|
85
|
-
homepage: http://github.com/
|
|
85
|
+
homepage: http://github.com/mezis/routemaster-client
|
|
86
86
|
licenses:
|
|
87
87
|
- MIT
|
|
88
88
|
metadata: {}
|
|
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
102
102
|
version: '0'
|
|
103
103
|
requirements: []
|
|
104
104
|
rubyforge_project:
|
|
105
|
-
rubygems_version: 2.
|
|
105
|
+
rubygems_version: 2.5.1
|
|
106
106
|
signing_key:
|
|
107
107
|
specification_version: 4
|
|
108
108
|
summary: Client API for the Routemaster event bus
|
|
@@ -110,5 +110,4 @@ test_files:
|
|
|
110
110
|
- spec/client_spec.rb
|
|
111
111
|
- spec/receiver_spec.rb
|
|
112
112
|
- spec/spec_helper.rb
|
|
113
|
-
- spec/support/rack_test.rb
|
|
114
113
|
- spec/topic_spec.rb
|