This repository was archived by the owner on Jan 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathfirebase_test.rb
More file actions
85 lines (72 loc) · 2.06 KB
/
Copy pathfirebase_test.rb
File metadata and controls
85 lines (72 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
require File.expand_path('../helper', __FILE__)
class FirebaseTest < Service::TestCase
def setup
@stubs = Faraday::Adapter::Test::Stubs.new
end
def test_push
@stubs.post '/commits.json' do |env|
assert_equal 'test.firebaseio.com', env[:url].host
compare = ''
body = JSON.parse(env[:body])
payload['commits'].each do |commit|
if commit['id'] == body['id']
compare = commit
end
end
assert_equal compare, body
[200, {}, '']
end
svc = service :push, {
'firebase' => 'https://test.firebaseio.com/commits'
}, payload
svc.receive_push
end
def test_push_with_secret
@stubs.post '/commits.json' do |env|
params = Faraday::Utils.parse_nested_query(env[:url].query)
assert_equal({'auth' => '12345678abcdefgh'}, params)
end
svc = service :push, {
'firebase' => 'https://test.firebaseio.com/commits',
'secret' => '12345678abcdefgh'
}, payload
svc.receive_push
end
def test_push_with_suffix
@stubs.post '/commits.json' do |env|
assert_equal 'test.firebaseio.com', env[:url].host
params = Faraday::Utils.parse_nested_query(env[:url].query)
assert_equal({'auth' => '12345678abcdefgh'}, params)
[200, {}, '']
end
svc = service :push, {
'firebase' => 'https://test.firebaseio.com/commits.json',
'secret' => '12345678abcdefgh'
}, payload
svc.receive_push
end
def test_without_firebase
assert_raises Service::ConfigurationError do
svc = service :push,
{'firebase' => ''}, payload
svc.receive_push
end
end
def test_without_https
assert_raises Service::ConfigurationError do
svc = service :push,
{'firebase' => 'http://test.firebaseio.com'}, payload
svc.receive_push
end
end
def test_invalid_scheme
assert_raises Service::ConfigurationError do
svc = service :push,
{'firebase' => 'ftp://test.firebaseio.com'}, payload
svc.receive_push
end
end
def service(*args)
super Service::Firebase, *args
end
end