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 pathschema_test.rb
More file actions
171 lines (133 loc) · 3.35 KB
/
Copy pathschema_test.rb
File metadata and controls
171 lines (133 loc) · 3.35 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
require File.expand_path('../helper', __FILE__)
class DefaultSchemaTest < Service::TestCase
class SchemaService < Service
end
def setup
@svc = SchemaService
end
def test_title
assert_equal 'SchemaService', @svc.title
end
def test_hook_name
assert_equal 'schemaservice', @svc.hook_name
end
def test_default_events
assert_equal [:push], @svc.default_events
end
def test_supported_events
assert_equal [], @svc.supported_events
end
def test_schema
assert_equal [], @svc.schema
end
def test_white_listed_attributes
assert_equal [], @svc.white_listed
end
def test_url
assert_nil @svc.url
end
def test_logo_url
assert_nil @svc.logo_url
end
def test_maintainers
assert_equal [], @svc.maintainers
end
def test_supporters
assert_equal [], @svc.supporters
end
end
class DefaultSchemaWithEventsTest < DefaultSchemaTest
class SchemaService < Service
def receive_push
end
def receive_issues
end
end
def setup
@svc = SchemaService
end
def test_supported_events
assert_equal %w(issues push), @svc.supported_events.sort
end
end
class DefaultSchemaWithAllEventsTest < DefaultSchemaTest
class SchemaService < Service
def receive_event
end
def receive_push
end
def receive_issues
end
end
def setup
@svc = SchemaService
end
def test_supported_events
assert_equal Service::ALL_EVENTS, @svc.supported_events.sort
end
end
class CustomSchemaTest < DefaultSchemaTest
class SchemaService < Service
title "Custom!"
hook_name "custom"
string :abc
password :def
boolean :ghi
white_list :abc, :ghi
url 'url'
logo_url 'logo'
maintained_by :email => 'abc@def.com',
:web => 'http://def.com/support',
:github => 'abc',
:twitter => 'def'
supported_by :email => 'abc@def.com',
:web => 'http://def.com/support',
:github => %w(abc def),
:twitter => 'def'
end
def setup
@svc = SchemaService
end
def test_title
assert_equal 'Custom!', @svc.title
end
def test_hook_name
assert_equal 'custom', @svc.hook_name
end
def test_schema
assert_equal [
[:string, :abc],
[:password, :def],
[:boolean, :ghi]], @svc.schema
end
def test_white_listed_attributes
assert_equal %w(abc ghi), @svc.white_listed
end
def test_maintainers
maintainers = @svc.maintainers
assert_contributor :email, 'abc@def.com', maintainers
assert_contributor :web, 'http://def.com/support', maintainers
assert_contributor :github, 'abc', maintainers
assert_contributor :twitter, 'def', maintainers
assert_equal 4, maintainers.size
end
def test_supporters
supporters = @svc.supporters
assert_contributor :email, 'abc@def.com', supporters
assert_contributor :web, 'http://def.com/support', supporters
assert_contributor :github, 'abc', supporters
assert_contributor :github, 'def', supporters
assert_contributor :twitter, 'def', supporters
assert_equal 5, supporters.size
end
def test_url
assert_equal 'url', @svc.url
end
def test_logo_url
assert_equal 'logo', @svc.logo_url
end
def assert_contributor(contributor_type, value, contributors)
assert contributors.detect { |c| c.class.contributor_type == contributor_type &&
c.value == value }
end
end