ribose-cli 0.1.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +27 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +9 -1075
- data/Gemfile +3 -0
- data/README.md +315 -7
- data/bin/console +2 -5
- data/bin/ribose +22 -0
- data/lib/ribose/cli/auth.rb +10 -0
- data/lib/ribose/cli/command.rb +60 -0
- data/lib/ribose/cli/commands/base.rb +80 -0
- data/lib/ribose/cli/commands/conversation.rb +114 -0
- data/lib/ribose/cli/commands/file.rb +96 -0
- data/lib/ribose/cli/commands/invitation.rb +81 -0
- data/lib/ribose/cli/commands/join_space.rb +78 -0
- data/lib/ribose/cli/commands/member.rb +81 -0
- data/lib/ribose/cli/commands/message.rb +98 -0
- data/lib/ribose/cli/commands/note.rb +98 -0
- data/lib/ribose/cli/commands/space.rb +86 -0
- data/lib/ribose/cli/rcfile.rb +67 -0
- data/lib/ribose/cli/util.rb +22 -0
- data/lib/ribose/cli/version.rb +2 -2
- data/lib/ribose/cli.rb +21 -2
- data/ribose-cli.gemspec +11 -3
- data/spec/acceptance/config_spec.rb +17 -0
- data/spec/acceptance/conversation_spec.rb +90 -0
- data/spec/acceptance/file_spec.rb +80 -0
- data/spec/acceptance/invitation_spec.rb +109 -0
- data/spec/acceptance/join_space_spec.rb +73 -0
- data/spec/acceptance/member_spec.rb +87 -0
- data/spec/acceptance/message_spec.rb +67 -0
- data/spec/acceptance/note_spec.rb +61 -0
- data/spec/acceptance/space_spec.rb +112 -0
- data/spec/fixtures/.riboserc +4 -0
- data/spec/ribose/cli/rcfile_spec.rb +27 -0
- data/spec/spec_helper.rb +15 -1
- data/spec/support/console_helper.rb +29 -0
- metadata +113 -18
- data/.travis.yml +0 -5
- data/spec/ribose/cli_spec.rb +0 -4
@@ -0,0 +1,112 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe "Ribose Space" do
|
4
|
+
describe "Listing spaces" do
|
5
|
+
context "default option" do
|
6
|
+
it "retrieves user spaces in default format" do
|
7
|
+
command = %w(space list)
|
8
|
+
|
9
|
+
stub_ribose_space_list_api
|
10
|
+
output = capture_stdout { Ribose::CLI.start(command) }
|
11
|
+
|
12
|
+
expect(output).to match(/Work/)
|
13
|
+
expect(output).to match(/0e8d5c16-1a31-4df9-83d9-eeaa374d5adc/)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "with format option" do
|
18
|
+
it "retrieves user spaces in specified format" do
|
19
|
+
command = %w(space list --format json)
|
20
|
+
|
21
|
+
stub_ribose_space_list_api
|
22
|
+
output = capture_stdout { Ribose::CLI.start(command) }
|
23
|
+
|
24
|
+
expect(output).to match(/"name":"Work"/)
|
25
|
+
expect(output).to match(/"id":"0e8d5c16-1a31-4df9-83d9-eeaa374d5adc"/)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "Retrieving a space" do
|
31
|
+
context "with default options" do
|
32
|
+
it "displays the space in tabular format" do
|
33
|
+
command = %w(space show --space-id 123456789)
|
34
|
+
|
35
|
+
stub_ribose_space_fetch_api(123_456_789)
|
36
|
+
output = capture_stdout { Ribose::CLI.start(command) }
|
37
|
+
|
38
|
+
expect(output).to match(/name | Work/)
|
39
|
+
expect(output).to match(/visibility | invisible/)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "with format option" do
|
44
|
+
it "displays as the space in supported format" do
|
45
|
+
command = %w(space show --space-id 123456789 --format json)
|
46
|
+
|
47
|
+
stub_ribose_space_fetch_api(123_456_789)
|
48
|
+
output = capture_stdout { Ribose::CLI.start(command) }
|
49
|
+
|
50
|
+
expect(output).to match(/"name":"Work"/)
|
51
|
+
expect(output).to match(/"id":"0e8d5c16-1a31-4df9-83d9-eeaa374d5adc"/)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "Adding a new space" do
|
57
|
+
it "allows us to add a new space" do
|
58
|
+
command = %W(
|
59
|
+
space add
|
60
|
+
--name #{space.name}
|
61
|
+
--access #{space.access}
|
62
|
+
--description #{space.description}
|
63
|
+
--category-id #{space.category_id}
|
64
|
+
)
|
65
|
+
|
66
|
+
stub_ribose_space_create_api(space.to_h)
|
67
|
+
output = capture_stdout { Ribose::CLI.start(command) }
|
68
|
+
|
69
|
+
expect(output).to match(/New Space created!/)
|
70
|
+
expect(output).to match(/Id: 6b2741ad-4cde-4b4d-af3b-a162a4f6bc25/)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "Updating a space" do
|
75
|
+
it "updates an existing user space" do
|
76
|
+
command = %W(
|
77
|
+
space update
|
78
|
+
--space-id 123456789
|
79
|
+
--access #{space.access}
|
80
|
+
--description #{space.description}
|
81
|
+
--category-id #{space.category_id}
|
82
|
+
--name #{space.name}
|
83
|
+
)
|
84
|
+
|
85
|
+
stub_ribose_space_update_api(123456789, space.to_h)
|
86
|
+
output = capture_stdout { Ribose::CLI.start(command) }
|
87
|
+
|
88
|
+
expect(output).to match(/Your space has been updated!/)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "Remove an existing space" do
|
93
|
+
it "removes an existing space" do
|
94
|
+
space_uuid = "6b2741ad-4cde-4b4d-af3b-a162a4f6bc25"
|
95
|
+
command = %W(space remove --space-id #{space_uuid} --confirmation 12345)
|
96
|
+
|
97
|
+
stub_ribose_space_remove_api(space_uuid, password_confirmation: "12345")
|
98
|
+
output = capture_stdout { Ribose::CLI.start(command) }
|
99
|
+
|
100
|
+
expect(output).to match(/The Sapce has been removed!/)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def space
|
105
|
+
@space ||= OpenStruct.new(
|
106
|
+
access: "public",
|
107
|
+
description: "Space description",
|
108
|
+
category_id: "12",
|
109
|
+
name: "CLI Space",
|
110
|
+
)
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "ribose/cli/rcfile"
|
3
|
+
|
4
|
+
RSpec.describe Ribose::CLI::RCFile do
|
5
|
+
describe ".set" do
|
6
|
+
it "allows us to set API Token and User Email" do
|
7
|
+
api_token = "SECRET_TOKEN"
|
8
|
+
user_email = "user-one@example.com"
|
9
|
+
user_password = "SECRET_PASSWORD"
|
10
|
+
allow(File).to receive(:expand_path).and_return(fixtures_path)
|
11
|
+
|
12
|
+
Ribose::CLI::RCFile.set(
|
13
|
+
token: api_token,
|
14
|
+
email: user_email,
|
15
|
+
password: user_password,
|
16
|
+
)
|
17
|
+
|
18
|
+
expect(Ribose::CLI::RCFile.api_token).to eq(api_token)
|
19
|
+
expect(Ribose::CLI::RCFile.user_email).to eq(user_email)
|
20
|
+
expect(Ribose::CLI::RCFile.user_password).to eq(user_password)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def fixtures_path
|
25
|
+
File.expand_path("../../../fixtures", __FILE__)
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,25 @@
|
|
1
|
-
require "
|
1
|
+
require "webmock/rspec"
|
2
2
|
require "ribose/cli"
|
3
|
+
require "ribose/rspec"
|
4
|
+
|
5
|
+
Dir["./spec/support/**/*.rb"].sort.each { |file| require file }
|
3
6
|
|
4
7
|
RSpec.configure do |config|
|
5
8
|
# Enable flags like --only-failures and --next-failure
|
6
9
|
config.example_status_persistence_file_path = ".rspec_status"
|
10
|
+
config.include Ribose::ConsoleHelper
|
7
11
|
|
8
12
|
config.expect_with :rspec do |c|
|
9
13
|
c.syntax = :expect
|
10
14
|
end
|
15
|
+
|
16
|
+
config.before :all do
|
17
|
+
Ribose.configure do |ribose_config|
|
18
|
+
ribose_config.api_host = ENV["RIBOSE_API_HOST"] || "www.ribose.com"
|
19
|
+
ribose_config.user_email = ENV["RIBOSE_USER_EMAIL"] || "user@ribose.com"
|
20
|
+
ribose_config.user_password = ENV["RIBOSE_USER_PASSWORD"] || "SECRET_PASS"
|
21
|
+
|
22
|
+
ribose_config.client = Ribose::Client.new
|
23
|
+
end
|
24
|
+
end
|
11
25
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Ribose
|
2
|
+
module ConsoleHelper
|
3
|
+
def capture_stdout(&_block)
|
4
|
+
original_stdout = $stdout
|
5
|
+
$stdout = fake = StringIO.new
|
6
|
+
|
7
|
+
begin
|
8
|
+
yield
|
9
|
+
ensure
|
10
|
+
$stdout = original_stdout
|
11
|
+
end
|
12
|
+
|
13
|
+
fake.string
|
14
|
+
end
|
15
|
+
|
16
|
+
def capture_stderr(&_block)
|
17
|
+
original_stderr = $stderr
|
18
|
+
$stderr = fake = StringIO.new
|
19
|
+
|
20
|
+
begin
|
21
|
+
yield
|
22
|
+
ensure
|
23
|
+
$stderr = original_stderr
|
24
|
+
end
|
25
|
+
|
26
|
+
fake.string
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,45 +1,115 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ribose-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: thor
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :
|
19
|
+
version: 0.19.4
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.19.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ribose
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: terminal-table
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
27
69
|
- !ruby/object:Gem::Dependency
|
28
70
|
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
29
99
|
requirement: !ruby/object:Gem::Requirement
|
30
100
|
requirements:
|
31
101
|
- - "~>"
|
32
102
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
103
|
+
version: '3.0'
|
34
104
|
type: :development
|
35
105
|
prerelease: false
|
36
106
|
version_requirements: !ruby/object:Gem::Requirement
|
37
107
|
requirements:
|
38
108
|
- - "~>"
|
39
109
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
110
|
+
version: '3.0'
|
41
111
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
112
|
+
name: webmock
|
43
113
|
requirement: !ruby/object:Gem::Requirement
|
44
114
|
requirements:
|
45
115
|
- - "~>"
|
@@ -55,32 +125,58 @@ dependencies:
|
|
55
125
|
description: The Ribose CLI
|
56
126
|
email:
|
57
127
|
- operations@ribose.com
|
58
|
-
executables:
|
128
|
+
executables:
|
129
|
+
- ribose
|
59
130
|
extensions: []
|
60
131
|
extra_rdoc_files: []
|
61
132
|
files:
|
133
|
+
- ".github/workflows/test.yml"
|
62
134
|
- ".gitignore"
|
63
135
|
- ".hound.yml"
|
64
136
|
- ".rspec"
|
65
137
|
- ".rubocop.yml"
|
66
|
-
- ".travis.yml"
|
67
138
|
- Gemfile
|
68
139
|
- LICENSE.txt
|
69
140
|
- README.md
|
70
141
|
- Rakefile
|
71
142
|
- bin/console
|
143
|
+
- bin/ribose
|
72
144
|
- bin/rspec
|
73
145
|
- bin/setup
|
74
146
|
- lib/ribose/cli.rb
|
147
|
+
- lib/ribose/cli/auth.rb
|
148
|
+
- lib/ribose/cli/command.rb
|
149
|
+
- lib/ribose/cli/commands/base.rb
|
150
|
+
- lib/ribose/cli/commands/conversation.rb
|
151
|
+
- lib/ribose/cli/commands/file.rb
|
152
|
+
- lib/ribose/cli/commands/invitation.rb
|
153
|
+
- lib/ribose/cli/commands/join_space.rb
|
154
|
+
- lib/ribose/cli/commands/member.rb
|
155
|
+
- lib/ribose/cli/commands/message.rb
|
156
|
+
- lib/ribose/cli/commands/note.rb
|
157
|
+
- lib/ribose/cli/commands/space.rb
|
158
|
+
- lib/ribose/cli/rcfile.rb
|
159
|
+
- lib/ribose/cli/util.rb
|
75
160
|
- lib/ribose/cli/version.rb
|
76
161
|
- ribose-cli.gemspec
|
77
|
-
- spec/
|
162
|
+
- spec/acceptance/config_spec.rb
|
163
|
+
- spec/acceptance/conversation_spec.rb
|
164
|
+
- spec/acceptance/file_spec.rb
|
165
|
+
- spec/acceptance/invitation_spec.rb
|
166
|
+
- spec/acceptance/join_space_spec.rb
|
167
|
+
- spec/acceptance/member_spec.rb
|
168
|
+
- spec/acceptance/message_spec.rb
|
169
|
+
- spec/acceptance/note_spec.rb
|
170
|
+
- spec/acceptance/space_spec.rb
|
171
|
+
- spec/fixtures/.riboserc
|
172
|
+
- spec/ribose/cli/rcfile_spec.rb
|
78
173
|
- spec/spec_helper.rb
|
174
|
+
- spec/support/console_helper.rb
|
79
175
|
homepage: https://github.com/riboseinc/ribose-cli
|
80
176
|
licenses:
|
81
177
|
- MIT
|
82
178
|
metadata: {}
|
83
|
-
post_install_message:
|
179
|
+
post_install_message:
|
84
180
|
rdoc_options: []
|
85
181
|
require_paths:
|
86
182
|
- lib
|
@@ -88,16 +184,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
184
|
requirements:
|
89
185
|
- - ">="
|
90
186
|
- !ruby/object:Gem::Version
|
91
|
-
version:
|
187
|
+
version: 2.5.0
|
92
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
189
|
requirements:
|
94
190
|
- - ">="
|
95
191
|
- !ruby/object:Gem::Version
|
96
192
|
version: '0'
|
97
193
|
requirements: []
|
98
|
-
|
99
|
-
|
100
|
-
signing_key:
|
194
|
+
rubygems_version: 3.2.3
|
195
|
+
signing_key:
|
101
196
|
specification_version: 4
|
102
197
|
summary: The Ribose CLI
|
103
198
|
test_files: []
|
data/.travis.yml
DELETED
data/spec/ribose/cli_spec.rb
DELETED