|
5 | 5 | describe Prometheus::Client::Push do |
6 | 6 | let(:gateway) { 'http://localhost:9091' } |
7 | 7 | let(:registry) { Prometheus::Client.registry } |
8 | | - let(:push) { Prometheus::Client::Push.new('test-job', nil, gateway) } |
| 8 | + let(:push) { Prometheus::Client::Push.new(job: 'test-job', gateway: gateway) } |
9 | 9 |
|
10 | 10 | describe '.new' do |
11 | 11 | it 'returns a new push instance' do |
12 | 12 | expect(push).to be_a(Prometheus::Client::Push) |
13 | 13 | end |
14 | 14 |
|
15 | 15 | it 'uses localhost as default Pushgateway' do |
16 | | - push = Prometheus::Client::Push.new('test-job') |
| 16 | + push = Prometheus::Client::Push.new(job: 'test-job') |
17 | 17 |
|
18 | 18 | expect(push.gateway).to eql('http://localhost:9091') |
19 | 19 | end |
20 | 20 |
|
21 | 21 | it 'allows to specify a custom Pushgateway' do |
22 | | - push = Prometheus::Client::Push.new('test-job', nil, 'http://pu.sh:1234') |
| 22 | + push = Prometheus::Client::Push.new(job: 'test-job', gateway: 'http://pu.sh:1234') |
23 | 23 |
|
24 | 24 | expect(push.gateway).to eql('http://pu.sh:1234') |
25 | 25 | end |
26 | 26 |
|
27 | | - it 'raises an ArgumentError if the job is not provided' do |
| 27 | + it 'raises an ArgumentError if the job is nil' do |
28 | 28 | expect do |
29 | | - Prometheus::Client::Push.new(nil) |
| 29 | + Prometheus::Client::Push.new(job: nil) |
30 | 30 | end.to raise_error ArgumentError |
31 | 31 | end |
32 | 32 |
|
33 | 33 | it 'raises an ArgumentError if the given gateway URL is invalid' do |
34 | 34 | ['inva.lid:1233', 'http://[invalid]'].each do |url| |
35 | 35 | expect do |
36 | | - Prometheus::Client::Push.new('test-job', nil, url) |
| 36 | + Prometheus::Client::Push.new(job: 'test-job', gateway: url) |
37 | 37 | end.to raise_error ArgumentError |
38 | 38 | end |
39 | 39 | end |
|
65 | 65 |
|
66 | 66 | describe '#path' do |
67 | 67 | it 'uses the default metrics path if no instance value given' do |
68 | | - push = Prometheus::Client::Push.new('test-job') |
| 68 | + push = Prometheus::Client::Push.new(job: 'test-job') |
69 | 69 |
|
70 | 70 | expect(push.path).to eql('/metrics/job/test-job') |
71 | 71 | end |
72 | 72 |
|
73 | 73 | it 'uses the full metrics path if an instance value is given' do |
74 | | - push = Prometheus::Client::Push.new('bar-job', 'foo') |
| 74 | + push = Prometheus::Client::Push.new(job: 'bar-job', instance: 'foo') |
75 | 75 |
|
76 | 76 | expect(push.path).to eql('/metrics/job/bar-job/instance/foo') |
77 | 77 | end |
78 | 78 |
|
79 | 79 | it 'escapes non-URL characters' do |
80 | | - push = Prometheus::Client::Push.new('bar job', 'foo <my instance>') |
| 80 | + push = Prometheus::Client::Push.new(job: 'bar job', instance: 'foo <my instance>') |
81 | 81 |
|
82 | 82 | expected = '/metrics/job/bar+job/instance/foo+%3Cmy+instance%3E' |
83 | 83 | expect(push.path).to eql(expected) |
|
0 commit comments