cobot_client 5.0.0 → 6.0.0

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.
@@ -1,36 +1,58 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
- describe CobotClient::NavigationLinkService, '#install_links' do
4
- let(:service) { CobotClient::NavigationLinkService.new(api_client, 'co-up') }
5
- let(:api_client) { instance_double(CobotClient::ApiClient) }
5
+ describe CobotClient::NavigationLinkService do
6
+ let(:service) { described_class.new(api_client, 'co-up') }
7
+ let(:api_client) { CobotClient::ApiClient.new('access_token') }
6
8
 
7
9
  context 'when there are links already' do
8
10
  let(:existing_link) do
9
- instance_double(CobotClient::NavigationLink, label: 'existing link',
10
- section: 'admin/setup', iframe_url: 'http://example.com/1').as_null_object
11
+ CobotClient::NavigationLink.new(
12
+ label: 'existing link',
13
+ section: 'admin/setup',
14
+ iframe_url: 'http://example.com/1'
15
+ )
11
16
  end
12
17
  let(:new_link) do
13
- instance_double(CobotClient::NavigationLink, label: 'new link',
14
- section: 'admin/setup', iframe_url: 'http://example.com/2').as_null_object
18
+ CobotClient::NavigationLink.new(
19
+ label: 'new link',
20
+ section: 'admin/setup',
21
+ iframe_url: 'http://example.com/2'
22
+ )
15
23
  end
16
24
 
17
- before(:each) do
25
+ before do
18
26
  allow(api_client).to receive(:get)
19
27
  .with('co-up', '/navigation_links')
20
- .and_return([{label: 'existing link',
21
- section: 'admin/setup', iframe_url: 'http://example.com/1'}])
28
+ .and_return(
29
+ [
30
+ {
31
+ label: 'existing link',
32
+ section: 'admin/setup',
33
+ iframe_url: 'http://example.com/1'
34
+ }
35
+ ]
36
+ )
22
37
  end
23
38
 
24
39
  it 'installs the missing links' do
25
40
  expect(api_client).to receive(:post)
26
- .with('co-up', '/navigation_links', hash_including(label: 'new link',
27
- section: 'admin/setup', iframe_url: 'http://example.com/2')) { {} }
41
+ .with(
42
+ 'co-up',
43
+ '/navigation_links',
44
+ hash_including(
45
+ label: 'new link',
46
+ section: 'admin/setup',
47
+ iframe_url: 'http://example.com/2'
48
+ )
49
+ ).and_return({})
28
50
 
29
51
  service.install_links [existing_link, new_link]
30
52
  end
31
53
 
32
54
  it 'returns all the links' do
33
- allow(api_client).to receive(:post) { {label: 'new link'} }
55
+ allow(api_client).to receive(:post).and_return({label: 'new link'})
34
56
 
35
57
  expect(service.install_links([existing_link, new_link]).map(&:label)).to eql(['existing link', 'new link'])
36
58
  end
@@ -38,28 +60,31 @@ describe CobotClient::NavigationLinkService, '#install_links' do
38
60
 
39
61
  context 'when there are no links installed' do
40
62
  let(:link) do
41
- instance_double(CobotClient::NavigationLink,
42
- section: 'admin/manage', label: 'test link', iframe_url: '/test',
43
- user_editable: true)
63
+ CobotClient::NavigationLink.new(
64
+ section: 'admin/manage',
65
+ label: 'test link',
66
+ iframe_url: '/test',
67
+ user_editable: true
68
+ )
44
69
  end
45
70
 
46
- before(:each) do
47
- allow(api_client).to receive(:get).with('co-up', '/navigation_links') { [] }
71
+ before do
72
+ allow(api_client).to receive(:get).with('co-up', '/navigation_links').and_return([])
48
73
  end
49
74
 
50
75
  it 'installs the links' do
51
76
  expect(api_client).to receive(:post)
52
77
  .with('co-up', '/navigation_links',
53
- section: 'admin/manage',
54
- label: 'test link',
55
- iframe_url: '/test',
56
- user_editable: true) { {} }
78
+ section: 'admin/manage',
79
+ label: 'test link',
80
+ iframe_url: '/test',
81
+ user_editable: true).and_return({})
57
82
 
58
83
  service.install_links [link]
59
84
  end
60
85
 
61
86
  it 'returns the links created' do
62
- allow(api_client).to receive(:post) { {label: 'test link'} }
87
+ allow(api_client).to receive(:post).and_return({label: 'test link'})
63
88
 
64
89
  expect(service.install_links([link]).map(&:label)).to eql(['test link'])
65
90
  end
@@ -1,18 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
- describe CobotClient::UrlHelper, 'cobot_url' do
5
+ describe CobotClient::UrlHelper do
4
6
  let(:helper) do
5
7
  Object.new.tap do |o|
6
- o.extend CobotClient::UrlHelper
8
+ o.extend described_class
7
9
  end
8
10
  end
9
11
 
10
- after(:each) do
11
- CobotClient::UrlHelper.site = 'https://www.cobot.me'
12
+ after do
13
+ described_class.site = 'https://www.cobot.me'
12
14
  end
13
15
 
14
16
  it 'lets me change the site' do
15
- CobotClient::UrlHelper.site = 'https://www.cobot.com'
17
+ described_class.site = 'https://www.cobot.com'
16
18
 
17
19
  expect(helper.cobot_url).to eql('https://www.cobot.com/')
18
20
  end
@@ -21,7 +23,7 @@ describe CobotClient::UrlHelper, 'cobot_url' do
21
23
  expect(helper.cobot_url).to eql('https://www.cobot.me/')
22
24
  end
23
25
 
24
- it 'returns a url with a sudomain' do
26
+ it 'returns a url with a subdomain' do
25
27
  expect(helper.cobot_url('co-up')).to eql('https://co-up.cobot.me/')
26
28
  end
27
29
 
data/spec/spec_helper.rb CHANGED
@@ -1 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV['RBS_TEST_LOGLEVEL'] ||= 'error'
4
+ ENV['RBS_TEST_TARGET'] ||= 'CobotClient*'
5
+
6
+ require 'rbs/test/setup'
7
+
1
8
  require_relative '../lib/cobot_client'
9
+
10
+ require 'webmock/rspec'
11
+ WebMock.disable_net_connect!
metadata CHANGED
@@ -1,31 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobot_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Lang
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-10-18 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: virtus
13
+ name: activemodel
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '1.0'
18
+ version: '5.2'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - "~>"
23
+ - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: '1.0'
25
+ version: '5.2'
27
26
  - !ruby/object:Gem::Dependency
28
- name: oauth2
27
+ name: json
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - "~>"
@@ -39,21 +38,7 @@ dependencies:
39
38
  - !ruby/object:Gem::Version
40
39
  version: '2.0'
41
40
  - !ruby/object:Gem::Dependency
42
- name: rest-client
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 2.0.1
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 2.0.1
55
- - !ruby/object:Gem::Dependency
56
- name: json
41
+ name: oauth2
57
42
  requirement: !ruby/object:Gem::Requirement
58
43
  requirements:
59
44
  - - "~>"
@@ -66,34 +51,6 @@ dependencies:
66
51
  - - "~>"
67
52
  - !ruby/object:Gem::Version
68
53
  version: '2.0'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3.0'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 12.3.3
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 12.3.3
97
54
  description: Client for the Cobot API plus helpers
98
55
  email:
99
56
  - alex@cobot.me
@@ -101,8 +58,10 @@ executables: []
101
58
  extensions: []
102
59
  extra_rdoc_files: []
103
60
  files:
61
+ - ".github/workflows/ruby.yml"
62
+ - ".github/workflows/test.yml"
104
63
  - ".gitignore"
105
- - ".travis.yml"
64
+ - ".rubocop.yml"
106
65
  - CHANGELOG.md
107
66
  - Gemfile
108
67
  - LICENSE
@@ -113,11 +72,23 @@ files:
113
72
  - lib/cobot_client.rb
114
73
  - lib/cobot_client/api_client.rb
115
74
  - lib/cobot_client/engine.rb
116
- - lib/cobot_client/exceptions.rb
75
+ - lib/cobot_client/errors.rb
117
76
  - lib/cobot_client/navigation_link.rb
118
77
  - lib/cobot_client/navigation_link_service.rb
78
+ - lib/cobot_client/request.rb
79
+ - lib/cobot_client/response.rb
119
80
  - lib/cobot_client/url_helper.rb
120
81
  - lib/cobot_client/version.rb
82
+ - rbs_collection.yaml
83
+ - sig/cobot_client/api_client.rbs
84
+ - sig/cobot_client/errors.rbs
85
+ - sig/cobot_client/navigation_link.rbs
86
+ - sig/cobot_client/navigation_link_service.rbs
87
+ - sig/cobot_client/request.rbs
88
+ - sig/cobot_client/response.rbs
89
+ - sig/cobot_client/url_helper.rbs
90
+ - sig/cobot_client/version.rbs
91
+ - sig/manifests.yaml
121
92
  - spec/cobot_client/api_client_spec.rb
122
93
  - spec/cobot_client/navigation_link_service_spec.rb
123
94
  - spec/cobot_client/url_helper_spec.rb
@@ -125,8 +96,8 @@ files:
125
96
  homepage: http://github.com/cobot/cobot_client
126
97
  licenses:
127
98
  - MIT
128
- metadata: {}
129
- post_install_message:
99
+ metadata:
100
+ rubygems_mfa_required: 'true'
130
101
  rdoc_options: []
131
102
  require_paths:
132
103
  - lib
@@ -134,19 +105,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
105
  requirements:
135
106
  - - ">="
136
107
  - !ruby/object:Gem::Version
137
- version: '0'
108
+ version: '3.3'
109
+ - - "<"
110
+ - !ruby/object:Gem::Version
111
+ version: '5'
138
112
  required_rubygems_version: !ruby/object:Gem::Requirement
139
113
  requirements:
140
114
  - - ">="
141
115
  - !ruby/object:Gem::Version
142
116
  version: '0'
143
117
  requirements: []
144
- rubygems_version: 3.1.6
145
- signing_key:
118
+ rubygems_version: 4.0.10
146
119
  specification_version: 4
147
120
  summary: Client for the Cobot API plus helpers
148
- test_files:
149
- - spec/cobot_client/api_client_spec.rb
150
- - spec/cobot_client/navigation_link_service_spec.rb
151
- - spec/cobot_client/url_helper_spec.rb
152
- - spec/spec_helper.rb
121
+ test_files: []
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- rvm:
2
- - 2.2.4
3
- - 2.3.0
4
- - 2.4.0
@@ -1,17 +0,0 @@
1
- require 'rest_client'
2
-
3
- module CobotClient
4
- module Exceptions
5
- EXCEPTIONS_MAP = {}
6
- end
7
-
8
- class Exception < RestClient::Exception
9
- end
10
-
11
- RestClient::STATUSES.each_pair do |code, message|
12
- superclass = RestClient::Exceptions::EXCEPTIONS_MAP.fetch code
13
- klass = Class.new(superclass)
14
- klass_constant = const_set message.delete(' \-\''), klass
15
- Exceptions::EXCEPTIONS_MAP[superclass] = klass_constant
16
- end
17
- end