nexboard-api 0.1.1 → 0.3
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 +5 -5
- data/lib/nexboard_api.rb +81 -33
- data/nexboard-api.gemspec +10 -8
- data/spec/lib/nexboard_api_spec.rb +141 -68
- data/spec/pact_helper.rb +13 -0
- data/spec/pacts/nexboard_api_pact_spec.rb +107 -0
- data/spec/pacts/openhpi-nexboard.json +109 -0
- data/spec/spec_helper.rb +3 -1
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 27ffd8587d8b3de5b0662d005ed7c13ad373fabb395ad00505b23b0572363782
|
4
|
+
data.tar.gz: 1bbf7e8db7a511f146b49b570e85c36adc8dec14900879041d56100b5cd3d386
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d97678d15db58085fce73c7d7c7a314e736622a6dc9d458835e24ec25fa90b84a679b6d390cab7a13454ac4fca7f0782a8ae24683b2c67c243b7a6cc858fe7b
|
7
|
+
data.tar.gz: 94ada08cecb3879d28bac06bea53c789730b5ea8262da6d4ab2e4ebc5e1bbed71b7a8f1424e7d7aef0a918717dab5847a8a7dc08abd9ec14118f4cd0c09769e1
|
data/lib/nexboard_api.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'restify'
|
4
|
+
|
1
5
|
class NexboardApi
|
2
|
-
DEFAULT_BASE_URL = 'https://nexboard.nexenio.com/portal/api/public/'
|
6
|
+
DEFAULT_BASE_URL = 'https://nexboard.nexenio.com/portal/api/v1/public/'
|
3
7
|
|
4
8
|
attr_reader :api_key, :user_id, :template_project_id, :base_url
|
5
9
|
|
@@ -11,52 +15,96 @@ class NexboardApi
|
|
11
15
|
DEFAULT_BASE_URL
|
12
16
|
else
|
13
17
|
base_url
|
14
|
-
end
|
18
|
+
end
|
15
19
|
end
|
16
|
-
|
17
|
-
def get_project_ids
|
18
|
-
projects = Restify.new(@base_url + 'projects')
|
19
|
-
.get(userId: @user_id, token: @api_key)
|
20
|
-
.value!
|
21
20
|
|
22
|
-
|
21
|
+
def project_ids
|
22
|
+
projects = Restify.new(URI.join(base_url, 'projects'))
|
23
|
+
.get(userId: user_id, token: api_key)
|
24
|
+
.value!
|
25
|
+
projects.data.map(&:id)
|
23
26
|
end
|
24
27
|
|
25
|
-
def create_project(title:, description:)
|
28
|
+
def create_project(title:, description: nil)
|
26
29
|
data = {
|
27
|
-
|
28
|
-
|
29
|
-
user_id: @user_id
|
30
|
+
title: title,
|
31
|
+
userId: user_id,
|
30
32
|
}
|
33
|
+
data[:description] = description if description
|
31
34
|
|
32
|
-
Restify.new(
|
33
|
-
|
34
|
-
|
35
|
+
Restify.new(URI.join(base_url, 'projects'))
|
36
|
+
.post(data, token: api_key)
|
37
|
+
.value!
|
35
38
|
end
|
36
39
|
|
37
|
-
def
|
38
|
-
Restify.new(
|
39
|
-
|
40
|
-
|
40
|
+
def boards_for_project(project_id:)
|
41
|
+
Restify.new(URI.join(base_url, "projects/#{project_id}/boards"))
|
42
|
+
.get(token: api_key, userId: user_id)
|
43
|
+
.value!
|
41
44
|
end
|
42
45
|
|
43
|
-
def
|
44
|
-
return [] if
|
45
|
-
|
46
|
-
template_boards
|
46
|
+
def template_boards
|
47
|
+
return [] if template_project_id.nil?
|
48
|
+
|
49
|
+
template_boards = boards_for_project(project_id: template_project_id)
|
50
|
+
template_boards
|
51
|
+
.data
|
52
|
+
.map {|board| {board_id: board['id'], title: board['title']} }
|
47
53
|
end
|
48
54
|
|
49
|
-
def
|
55
|
+
def create_board(project_id:, title:, description: nil, template_id: nil)
|
50
56
|
data = {
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
user_id: @user_id
|
57
|
+
projectId: project_id,
|
58
|
+
userId: user_id,
|
59
|
+
title: title,
|
55
60
|
}
|
56
|
-
data
|
61
|
+
data[:description] = description if description
|
62
|
+
data[:template_id] = template_id unless template_id.nil?
|
63
|
+
|
64
|
+
Restify.new(URI.join(base_url, 'boards'))
|
65
|
+
.post(data, token: api_key)
|
66
|
+
.value!
|
67
|
+
end
|
68
|
+
|
69
|
+
def upload_image_to_board(board_id:, uploaded_io:)
|
70
|
+
uri = URI.join(
|
71
|
+
base_url,
|
72
|
+
"boards/images/#{board_id}",
|
73
|
+
"?token=#{api_key}",
|
74
|
+
)
|
75
|
+
|
76
|
+
multipart_request uri, uploaded_io
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
BOUNDARY = 'NexboardApiP3K'
|
82
|
+
|
83
|
+
def multipart_request(uri, uploaded_io)
|
84
|
+
uploaded_io.rewind
|
85
|
+
|
86
|
+
http = Net::HTTP.new uri.host, uri.port
|
87
|
+
request = Net::HTTP::Post.new uri.request_uri
|
88
|
+
request.body = post_body
|
89
|
+
request['Content-Type'] = "multipart/form-data, boundary=#{BOUNDARY}"
|
90
|
+
|
91
|
+
response = http.request(request)
|
92
|
+
response.is_a? Net::HTTPSuccess
|
93
|
+
end
|
94
|
+
|
95
|
+
def post_body(uploaded_io)
|
96
|
+
post_body = []
|
97
|
+
post_body << "--#{BOUNDARY}\r\n"
|
98
|
+
post_body << 'Content-Disposition: form-data; name="datafile"; '
|
99
|
+
post_body << "filename=\"#{to_ascii(uploaded_io.original_filename)}\"\r\n"
|
100
|
+
post_body << "Content-Type: text/plain\r\n"
|
101
|
+
post_body << "\r\n"
|
102
|
+
post_body << uploaded_io.tempfile.read
|
103
|
+
post_body << "\r\n--#{BOUNDARY}--\r\n"
|
104
|
+
post_body.join
|
105
|
+
end
|
57
106
|
|
58
|
-
|
59
|
-
|
60
|
-
.value!
|
107
|
+
def to_ascii(str)
|
108
|
+
str.encode('ascii', invalid: :replace, undef: :replace, replace: '?')
|
61
109
|
end
|
62
|
-
end
|
110
|
+
end
|
data/nexboard-api.gemspec
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Gem::Specification.new do |spec|
|
2
4
|
spec.name = 'nexboard-api'
|
3
|
-
spec.version = '0.
|
5
|
+
spec.version = '0.3'
|
4
6
|
spec.authors = ['Xikolo Development Team']
|
5
|
-
spec.email = %w
|
6
|
-
spec.description =
|
7
|
-
spec.summary =
|
7
|
+
spec.email = %w[xikolo-dev@hpi.uni-potsdam.de]
|
8
|
+
spec.description = 'Ruby wrapper for Nexboard API (https://nexboard.nexenio.com)'
|
9
|
+
spec.summary = 'Ruby wrapper for Nexboard API (https://nexboard.nexenio.com)'
|
8
10
|
spec.homepage = 'https://github.com/openHPI/nexboard-api'
|
9
11
|
spec.license = ''
|
10
12
|
|
11
|
-
spec.files = Dir['**/*'].grep(
|
12
|
-
.*\.gemspec|.*LICENSE.*|.*README.*|.*CHANGELOG.*)
|
13
|
-
spec.executables = spec.files.grep(%r{^bin/}) {
|
13
|
+
spec.files = Dir['**/*'].grep(%r{((bin|lib|test|spec|features)/|
|
14
|
+
.*\.gemspec|.*LICENSE.*|.*README.*|.*CHANGELOG.*)}x)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
|
14
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
-
spec.require_paths = %w
|
17
|
+
spec.require_paths = %w[lib]
|
16
18
|
|
17
19
|
spec.add_dependency 'restify'
|
18
20
|
|
@@ -1,130 +1,203 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe NexboardApi do
|
6
|
+
subject(:api) { described_class.new(**params) }
|
7
|
+
|
4
8
|
let(:api_key) { 'RandomApiKey' }
|
5
9
|
let(:user_id) { 1337 }
|
6
|
-
let(:params)
|
7
|
-
|
8
|
-
let(:
|
9
|
-
|
10
|
-
let(:default_base_url) { 'https://nexboard.nexenio.com/portal/api/public/' }
|
11
|
-
let(:default_headers) { {'Content-Type' => 'application/json'} }
|
10
|
+
let(:params) { {api_key: api_key, user_id: user_id} }
|
11
|
+
let(:default_base_url) { 'https://nexboard.nexenio.com/portal/api/v1/public/' }
|
12
|
+
let(:default_headers) { {'Content-Type' => 'application/json'} }
|
12
13
|
|
13
14
|
describe '#initialize' do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
expect(
|
18
|
-
expect(subject.user_id).to eq(user_id)
|
19
|
-
expect(subject.base_url).to eq(default_base_url)
|
15
|
+
it 'is initialized with correct params' do
|
16
|
+
expect(api.api_key).to eq(api_key)
|
17
|
+
expect(api.user_id).to eq(user_id)
|
18
|
+
expect(api.base_url).to eq(default_base_url)
|
20
19
|
end
|
21
20
|
|
22
21
|
context 'with custom base_url' do
|
23
22
|
let(:params) { super().merge(base_url: 'https://p3k.com') }
|
24
23
|
|
25
|
-
it '
|
26
|
-
expect(
|
27
|
-
end
|
28
|
-
end
|
24
|
+
it 'is initialized with custom base_url' do
|
25
|
+
expect(api.base_url).to eq('https://p3k.com')
|
26
|
+
end
|
27
|
+
end
|
29
28
|
|
30
29
|
context 'with template_project_id' do
|
31
30
|
let(:params) { super().merge(template_project_id: 666) }
|
32
31
|
|
33
|
-
it '
|
34
|
-
expect(
|
35
|
-
end
|
36
|
-
end
|
32
|
+
it 'is initialized with template_project_id' do
|
33
|
+
expect(api.template_project_id).to eq(666)
|
34
|
+
end
|
35
|
+
end
|
37
36
|
end
|
38
37
|
|
39
|
-
describe '#
|
40
|
-
subject { api.
|
38
|
+
describe '#project_ids' do
|
39
|
+
subject(:project_ids) { api.project_ids }
|
41
40
|
|
42
41
|
let!(:projects_stub) do
|
43
|
-
stub_request(:get, "#{default_base_url}projects?token=#{api_key}&userId=#{user_id}")
|
44
|
-
|
45
|
-
|
46
|
-
end
|
42
|
+
stub_request(:get, "#{default_base_url}projects?token=#{api_key}&userId=#{user_id}")
|
43
|
+
.with(headers: default_headers)
|
44
|
+
.to_return(status: 200, body: '[{"id": 1}, {"id": 3000}]', headers: default_headers)
|
45
|
+
end
|
47
46
|
|
48
|
-
it '
|
49
|
-
|
47
|
+
it 'requests Nexboard API' do
|
48
|
+
project_ids
|
50
49
|
expect(projects_stub).to have_been_requested
|
51
|
-
end
|
50
|
+
end
|
52
51
|
|
53
|
-
it '
|
54
|
-
expect(
|
55
|
-
end
|
52
|
+
it 'returns a list of project ids' do
|
53
|
+
expect(project_ids).to eq([1, 3000])
|
54
|
+
end
|
56
55
|
end
|
57
56
|
|
58
57
|
describe '#create_project' do
|
58
|
+
subject(:create_project) { api.create_project(**create_params) }
|
59
|
+
|
59
60
|
let(:create_params) { {title: 'My project', description: 'My description'} }
|
60
61
|
|
61
|
-
|
62
|
+
let(:create_body) do
|
63
|
+
{
|
64
|
+
userId: user_id,
|
65
|
+
title: 'My project',
|
66
|
+
description: 'My description',
|
67
|
+
}
|
68
|
+
end
|
62
69
|
|
63
70
|
let!(:create_project_stub) do
|
64
|
-
stub_request(:post, "#{default_base_url}projects?token=#{api_key}")
|
65
|
-
|
66
|
-
|
71
|
+
stub_request(:post, "#{default_base_url}projects?token=#{api_key}")
|
72
|
+
.with(
|
73
|
+
headers: default_headers,
|
74
|
+
body: create_body,
|
75
|
+
)
|
76
|
+
.to_return(status: 200, body: '{}', headers: default_headers)
|
67
77
|
end
|
68
78
|
|
69
|
-
it '
|
70
|
-
|
79
|
+
it 'requests Nexboard API' do
|
80
|
+
create_project
|
71
81
|
expect(create_project_stub).to have_been_requested
|
72
|
-
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'without description' do
|
85
|
+
let(:create_params) { {title: 'My project'} }
|
86
|
+
|
87
|
+
let(:create_body) do
|
88
|
+
{
|
89
|
+
userId: user_id,
|
90
|
+
title: 'My project',
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'requests Nexboard API' do
|
95
|
+
create_project
|
96
|
+
expect(create_project_stub).to have_been_requested
|
97
|
+
end
|
98
|
+
end
|
73
99
|
end
|
74
100
|
|
75
|
-
describe '#
|
76
|
-
|
101
|
+
describe '#boards_for_project' do
|
102
|
+
subject(:boards) { api.boards_for_project project_id: project_id }
|
77
103
|
|
78
|
-
|
104
|
+
let(:project_id) { 123 }
|
79
105
|
|
80
106
|
let(:board) do
|
81
107
|
{
|
82
|
-
|
83
|
-
|
108
|
+
id: 1,
|
109
|
+
projectId: project_id,
|
84
110
|
title: 'My board',
|
85
|
-
description: 'My description'
|
111
|
+
description: 'My description',
|
86
112
|
}
|
87
|
-
end
|
113
|
+
end
|
88
114
|
|
89
115
|
let!(:boards_stub) do
|
90
|
-
stub_request(:get, "#{default_base_url}projects/#{project_id}/boards?token=#{api_key}&userId=#{user_id}")
|
91
|
-
|
92
|
-
|
116
|
+
stub_request(:get, "#{default_base_url}projects/#{project_id}/boards?token=#{api_key}&userId=#{user_id}")
|
117
|
+
.with(headers: default_headers)
|
118
|
+
.to_return(status: 200, body: "[#{board.to_json}]", headers: default_headers)
|
93
119
|
end
|
94
120
|
|
95
|
-
it '
|
96
|
-
|
121
|
+
it 'requests Nexboard API' do
|
122
|
+
boards
|
97
123
|
expect(boards_stub).to have_been_requested
|
98
124
|
end
|
99
125
|
|
100
|
-
it '
|
101
|
-
expect(
|
102
|
-
end
|
126
|
+
it 'returns a list of board resources' do
|
127
|
+
expect(boards.data.to_json).to eq([board].to_json)
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'without description' do
|
131
|
+
let(:board) do
|
132
|
+
{
|
133
|
+
id: 1,
|
134
|
+
projectId: project_id,
|
135
|
+
title: 'My board',
|
136
|
+
}
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'requests Nexboard API' do
|
140
|
+
boards
|
141
|
+
expect(boards_stub).to have_been_requested
|
142
|
+
end
|
143
|
+
end
|
103
144
|
end
|
104
145
|
|
105
|
-
describe '#
|
106
|
-
|
146
|
+
describe '#create_board' do
|
147
|
+
subject(:create_board) { api.create_board(**create_params) }
|
107
148
|
|
108
|
-
|
149
|
+
let(:create_params) do
|
150
|
+
{
|
151
|
+
project_id: 123,
|
152
|
+
title: 'My title',
|
153
|
+
description: 'My description',
|
154
|
+
}
|
155
|
+
end
|
156
|
+
|
157
|
+
let(:create_body) do
|
158
|
+
{
|
159
|
+
projectId: 123,
|
160
|
+
title: 'My title',
|
161
|
+
description: 'My description',
|
162
|
+
userId: user_id,
|
163
|
+
}
|
164
|
+
end
|
109
165
|
|
110
166
|
let(:create_board_stub) do
|
111
|
-
stub_request(:post, "#{default_base_url}boards?token=#{api_key}")
|
112
|
-
|
113
|
-
|
167
|
+
stub_request(:post, "#{default_base_url}boards?token=#{api_key}")
|
168
|
+
.with(headers: default_headers, body: create_body)
|
169
|
+
.to_return(status: 200, body: '{}', headers: default_headers)
|
114
170
|
end
|
115
171
|
|
116
|
-
before { create_board_stub;
|
172
|
+
before { create_board_stub; create_board }
|
117
173
|
|
118
|
-
it '
|
174
|
+
it 'requests Nexboard API' do
|
119
175
|
expect(create_board_stub).to have_been_requested
|
120
|
-
end
|
176
|
+
end
|
121
177
|
|
122
178
|
context 'with template_id' do
|
123
|
-
let(:create_params)
|
124
|
-
|
125
|
-
|
179
|
+
let(:create_params) do
|
180
|
+
{
|
181
|
+
project_id: 123,
|
182
|
+
title: 'My title',
|
183
|
+
description: 'My description',
|
184
|
+
template_id: 1234,
|
185
|
+
}
|
186
|
+
end
|
187
|
+
|
188
|
+
let(:create_body) do
|
189
|
+
{
|
190
|
+
projectId: 123,
|
191
|
+
title: 'My title',
|
192
|
+
description: 'My description',
|
193
|
+
userId: user_id,
|
194
|
+
template_id: 1234,
|
195
|
+
}
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'requests Nexboard API' do
|
126
199
|
expect(create_board_stub).to have_been_requested
|
127
|
-
end
|
128
|
-
end
|
200
|
+
end
|
201
|
+
end
|
129
202
|
end
|
130
203
|
end
|
data/spec/pact_helper.rb
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pact_helper'
|
4
|
+
|
5
|
+
describe NexboardApi, pact: true do
|
6
|
+
let(:api_key) { 'RandomApiKey' }
|
7
|
+
let(:user_id) { '1337' }
|
8
|
+
let(:base_url) { 'http://localhost:1234/' }
|
9
|
+
let(:params) { {api_key: api_key, user_id: user_id, base_url: base_url} }
|
10
|
+
let(:encoded_credentials) { CGI.escape("token=#{api_key}&userId=#{user_id}") }
|
11
|
+
let(:encoded_token) { CGI.escape("token=#{api_key}") }
|
12
|
+
let(:client) { described_class.new(**params) }
|
13
|
+
|
14
|
+
describe 'get_project_ids' do
|
15
|
+
let(:response) { [{project_id: '1'}, {project_id: '2'}] }
|
16
|
+
|
17
|
+
before do
|
18
|
+
nexboard.given('user has valid credentials and some projects exist')
|
19
|
+
.upon_receiving('a request to get all projects')
|
20
|
+
.with(method: :get, path: '/projects', query: encoded_credentials)
|
21
|
+
.will_respond_with(
|
22
|
+
status: 200,
|
23
|
+
headers: {'Content-Type' => 'application/json'},
|
24
|
+
body: response,
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns the project ids' do
|
29
|
+
project_ids = client.get_project_ids
|
30
|
+
expect(project_ids).to eq(%w[1 2])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'create_project' do
|
35
|
+
let(:title) { 'A new project' }
|
36
|
+
let(:description) { 'This is a new project' }
|
37
|
+
let(:project_id) { '1' }
|
38
|
+
let(:response) { {project_id: project_id, title: title} }
|
39
|
+
let(:project_data) { {title: title, description: description} }
|
40
|
+
let(:post_body) { {title: title, description: description, user_id: user_id} }
|
41
|
+
|
42
|
+
before do
|
43
|
+
nexboard.given('user has valid credentials')
|
44
|
+
.upon_receiving('a request to create a project')
|
45
|
+
.with(method: :post, path: '/projects', query: encoded_token, body: post_body)
|
46
|
+
.will_respond_with(
|
47
|
+
status: 200,
|
48
|
+
headers: {'Content-Type' => 'application/json'},
|
49
|
+
body: response,
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'returns a new project' do
|
54
|
+
project = client.create_project(project_data)
|
55
|
+
expect(project.project_id).to eq(project_id)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'get_boards_for_project' do
|
60
|
+
let(:title) { 'A board' }
|
61
|
+
let(:project_id) { '1' }
|
62
|
+
let(:board_id) { '101' }
|
63
|
+
let(:response) { [{boardId: board_id, title: title}] }
|
64
|
+
|
65
|
+
before do
|
66
|
+
nexboard.given('user has valid credentials and an existing project with boards')
|
67
|
+
.upon_receiving('a request to get boards of a project')
|
68
|
+
.with(method: :get, path: "/projects/#{project_id}/boards", query: encoded_credentials)
|
69
|
+
.will_respond_with(
|
70
|
+
status: 200,
|
71
|
+
headers: {'Content-Type' => 'application/json'},
|
72
|
+
body: response,
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'returns a new project' do
|
77
|
+
boards = client.get_boards_for_project(project_id: project_id)
|
78
|
+
expect(boards.first.boardId).to eq(board_id)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'create_board_for_project' do
|
83
|
+
let(:title) { 'A new project' }
|
84
|
+
let(:description) { 'This is a new project' }
|
85
|
+
let(:project_id) { '1' }
|
86
|
+
let(:board_id) { '101' }
|
87
|
+
let(:response) { {board_id: board_id, project_id: project_id, title: title} }
|
88
|
+
let(:board_data) { {title: title, description: description, project_id: project_id} }
|
89
|
+
let(:post_body) { {title: title, description: description, project_id: project_id, user_id: user_id} }
|
90
|
+
|
91
|
+
before do
|
92
|
+
nexboard.given('user has valid credentials and an existing project')
|
93
|
+
.upon_receiving('a request to create a project')
|
94
|
+
.with(method: :post, path: '/boards', query: encoded_token, body: post_body)
|
95
|
+
.will_respond_with(
|
96
|
+
status: 200,
|
97
|
+
headers: {'Content-Type' => 'application/json'},
|
98
|
+
body: response,
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'returns a new project' do
|
103
|
+
board = client.create_board_for_project(board_data)
|
104
|
+
expect(board.board_id).to eq(board_id)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
{
|
2
|
+
"consumer": {
|
3
|
+
"name": "OpenHPI"
|
4
|
+
},
|
5
|
+
"provider": {
|
6
|
+
"name": "nexboard"
|
7
|
+
},
|
8
|
+
"interactions": [
|
9
|
+
{
|
10
|
+
"description": "a request to get all projects",
|
11
|
+
"providerState": "user has valid credentials and some projects exist",
|
12
|
+
"request": {
|
13
|
+
"method": "get",
|
14
|
+
"path": "/projects",
|
15
|
+
"query": "token=RandomApiKey&userId=1337"
|
16
|
+
},
|
17
|
+
"response": {
|
18
|
+
"status": 200,
|
19
|
+
"headers": {
|
20
|
+
"Content-Type": "application/json"
|
21
|
+
},
|
22
|
+
"body": [
|
23
|
+
{
|
24
|
+
"project_id": "1"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"project_id": "2"
|
28
|
+
}
|
29
|
+
]
|
30
|
+
}
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"description": "a request to create a project",
|
34
|
+
"providerState": "user has valid credentials",
|
35
|
+
"request": {
|
36
|
+
"method": "post",
|
37
|
+
"path": "/projects",
|
38
|
+
"query": "token=RandomApiKey",
|
39
|
+
"body": {
|
40
|
+
"title": "A new project",
|
41
|
+
"description": "This is a new project",
|
42
|
+
"user_id": "1337"
|
43
|
+
}
|
44
|
+
},
|
45
|
+
"response": {
|
46
|
+
"status": 200,
|
47
|
+
"headers": {
|
48
|
+
"Content-Type": "application/json"
|
49
|
+
},
|
50
|
+
"body": {
|
51
|
+
"project_id": "1",
|
52
|
+
"title": "A new project"
|
53
|
+
}
|
54
|
+
}
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"description": "a request to get boards of a project",
|
58
|
+
"providerState": "user has valid credentials and an existing project with boards",
|
59
|
+
"request": {
|
60
|
+
"method": "get",
|
61
|
+
"path": "/projects/1/boards",
|
62
|
+
"query": "token=RandomApiKey&userId=1337"
|
63
|
+
},
|
64
|
+
"response": {
|
65
|
+
"status": 200,
|
66
|
+
"headers": {
|
67
|
+
"Content-Type": "application/json"
|
68
|
+
},
|
69
|
+
"body": [
|
70
|
+
{
|
71
|
+
"boardId": "101",
|
72
|
+
"title": "A board"
|
73
|
+
}
|
74
|
+
]
|
75
|
+
}
|
76
|
+
},
|
77
|
+
{
|
78
|
+
"description": "a request to create a project",
|
79
|
+
"providerState": "user has valid credentials and an existing project",
|
80
|
+
"request": {
|
81
|
+
"method": "post",
|
82
|
+
"path": "/boards",
|
83
|
+
"query": "token=RandomApiKey",
|
84
|
+
"body": {
|
85
|
+
"title": "A new project",
|
86
|
+
"description": "This is a new project",
|
87
|
+
"project_id": "1",
|
88
|
+
"user_id": "1337"
|
89
|
+
}
|
90
|
+
},
|
91
|
+
"response": {
|
92
|
+
"status": 200,
|
93
|
+
"headers": {
|
94
|
+
"Content-Type": "application/json"
|
95
|
+
},
|
96
|
+
"body": {
|
97
|
+
"board_id": "101",
|
98
|
+
"project_id": "1",
|
99
|
+
"title": "A new project"
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
],
|
104
|
+
"metadata": {
|
105
|
+
"pactSpecification": {
|
106
|
+
"version": "2.0.0"
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
4
|
require 'simplecov'
|
3
5
|
SimpleCov.start do
|
@@ -14,7 +16,7 @@ require 'restify'
|
|
14
16
|
|
15
17
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
16
18
|
# in spec/support/ and its subdirectories.
|
17
|
-
Dir['spec/support/**/*.rb'].each {|f| require f}
|
19
|
+
Dir['spec/support/**/*.rb'].each {|f| require f }
|
18
20
|
|
19
21
|
RSpec.configure do |config|
|
20
22
|
# ## Mock Framework
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexboard-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xikolo Development Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: restify
|
@@ -49,6 +49,9 @@ files:
|
|
49
49
|
- lib/nexboard_api.rb
|
50
50
|
- nexboard-api.gemspec
|
51
51
|
- spec/lib/nexboard_api_spec.rb
|
52
|
+
- spec/pact_helper.rb
|
53
|
+
- spec/pacts/nexboard_api_pact_spec.rb
|
54
|
+
- spec/pacts/openhpi-nexboard.json
|
52
55
|
- spec/spec_helper.rb
|
53
56
|
homepage: https://github.com/openHPI/nexboard-api
|
54
57
|
licenses:
|
@@ -69,11 +72,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
72
|
- !ruby/object:Gem::Version
|
70
73
|
version: '0'
|
71
74
|
requirements: []
|
72
|
-
|
73
|
-
rubygems_version: 2.5.1
|
75
|
+
rubygems_version: 3.0.3
|
74
76
|
signing_key:
|
75
77
|
specification_version: 4
|
76
78
|
summary: Ruby wrapper for Nexboard API (https://nexboard.nexenio.com)
|
77
79
|
test_files:
|
78
80
|
- spec/lib/nexboard_api_spec.rb
|
81
|
+
- spec/pact_helper.rb
|
82
|
+
- spec/pacts/nexboard_api_pact_spec.rb
|
83
|
+
- spec/pacts/openhpi-nexboard.json
|
79
84
|
- spec/spec_helper.rb
|