t 1.3.0 → 1.3.1
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.
- data/README.md +27 -27
- data/lib/t/cli.rb +1 -1
- data/lib/t/version.rb +1 -1
- data/spec/cli_spec.rb +443 -981
- data/spec/delete_spec.rb +43 -99
- data/spec/helper.rb +6 -0
- data/spec/list_spec.rb +69 -151
- data/spec/rcfile_spec.rb +66 -66
- data/spec/search_spec.rb +126 -280
- data/spec/set_spec.rb +28 -52
- data/spec/stream_spec.rb +33 -33
- data/spec/utils_spec.rb +21 -21
- metadata +2 -2
data/spec/rcfile_spec.rb
CHANGED
@@ -8,23 +8,23 @@ describe T::RCFile do
|
|
8
8
|
File.delete(project_path + "/tmp/trc") if File.exist?(project_path + "/tmp/trc")
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
12
|
-
T::RCFile.
|
13
|
-
|
11
|
+
it "is a singleton" do
|
12
|
+
expect(T::RCFile).to be_a Class
|
13
|
+
expect do
|
14
14
|
T::RCFile.new
|
15
|
-
end.
|
15
|
+
end.to raise_error(NoMethodError, /private method `new' called/)
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
19
|
-
it
|
18
|
+
describe "#[]" do
|
19
|
+
it "should return the profiles for a user" do
|
20
20
|
rcfile = T::RCFile.instance
|
21
21
|
rcfile.path = fixture_path + "/.trc"
|
22
|
-
rcfile['testcli'].keys.
|
22
|
+
expect(rcfile['testcli'].keys).to eq ['abc123']
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe
|
27
|
-
it
|
26
|
+
describe "#[]=" do
|
27
|
+
it "should add a profile for a user" do
|
28
28
|
rcfile = T::RCFile.instance
|
29
29
|
rcfile.path = project_path + "/tmp/trc"
|
30
30
|
rcfile['testcli'] = {
|
@@ -36,9 +36,9 @@ describe T::RCFile do
|
|
36
36
|
:secret => 'jkl012',
|
37
37
|
}
|
38
38
|
}
|
39
|
-
rcfile['testcli'].keys.
|
39
|
+
expect(rcfile['testcli'].keys).to eq ['abc123']
|
40
40
|
end
|
41
|
-
it
|
41
|
+
it "should write the data to disk" do
|
42
42
|
rcfile = T::RCFile.instance
|
43
43
|
rcfile.path = project_path + "/tmp/trc"
|
44
44
|
rcfile['testcli'] = {
|
@@ -50,9 +50,9 @@ describe T::RCFile do
|
|
50
50
|
:secret => 'jkl012',
|
51
51
|
}
|
52
52
|
}
|
53
|
-
rcfile['testcli'].keys.
|
53
|
+
expect(rcfile['testcli'].keys).to eq ['abc123']
|
54
54
|
end
|
55
|
-
it
|
55
|
+
it "should not be world readable or writable" do
|
56
56
|
rcfile = T::RCFile.instance
|
57
57
|
rcfile.path = project_path + "/tmp/trc"
|
58
58
|
rcfile['testcli'] = {
|
@@ -64,143 +64,143 @@ describe T::RCFile do
|
|
64
64
|
:secret => 'jkl012',
|
65
65
|
}
|
66
66
|
}
|
67
|
-
File.stat(rcfile.path).mode.
|
67
|
+
expect(File.stat(rcfile.path).mode).to eq 33152
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
describe
|
72
|
-
it
|
71
|
+
describe "#configuration" do
|
72
|
+
it "should return configuration" do
|
73
73
|
rcfile = T::RCFile.instance
|
74
74
|
rcfile.path = fixture_path + "/.trc"
|
75
|
-
rcfile.configuration.keys.
|
75
|
+
expect(rcfile.configuration.keys).to eq ['default_profile']
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
describe
|
80
|
-
it
|
79
|
+
describe "#active_consumer_key" do
|
80
|
+
it "should return default consumer key" do
|
81
81
|
rcfile = T::RCFile.instance
|
82
82
|
rcfile.path = fixture_path + "/.trc"
|
83
|
-
rcfile.active_consumer_key.
|
83
|
+
expect(rcfile.active_consumer_key).to eq 'abc123'
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
describe
|
88
|
-
it
|
87
|
+
describe "#active_consumer_secret" do
|
88
|
+
it "should return default consumer secret" do
|
89
89
|
rcfile = T::RCFile.instance
|
90
90
|
rcfile.path = fixture_path + "/.trc"
|
91
|
-
rcfile.active_consumer_secret.
|
91
|
+
expect(rcfile.active_consumer_secret).to eq 'asdfasd223sd2'
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
describe
|
96
|
-
it
|
95
|
+
describe "#active_profile" do
|
96
|
+
it "should return default profile" do
|
97
97
|
rcfile = T::RCFile.instance
|
98
98
|
rcfile.path = fixture_path + "/.trc"
|
99
|
-
rcfile.active_profile.
|
99
|
+
expect(rcfile.active_profile).to eq ['testcli', 'abc123']
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
describe
|
104
|
-
it
|
103
|
+
describe "#active_profile=" do
|
104
|
+
it "should set default profile" do
|
105
105
|
rcfile = T::RCFile.instance
|
106
106
|
rcfile.path = project_path + "/tmp/trc"
|
107
107
|
rcfile.active_profile = {'username' => 'testcli', 'consumer_key' => 'abc123'}
|
108
|
-
rcfile.active_profile.
|
108
|
+
expect(rcfile.active_profile).to eq ['testcli', 'abc123']
|
109
109
|
end
|
110
|
-
it
|
110
|
+
it "should write the data to disk" do
|
111
111
|
rcfile = T::RCFile.instance
|
112
112
|
rcfile.path = project_path + "/tmp/trc"
|
113
113
|
rcfile.active_profile = {'username' => 'testcli', 'consumer_key' => 'abc123'}
|
114
|
-
rcfile.active_profile.
|
114
|
+
expect(rcfile.active_profile).to eq ['testcli', 'abc123']
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
-
describe
|
119
|
-
it
|
118
|
+
describe "#active_token" do
|
119
|
+
it "should return default token" do
|
120
120
|
rcfile = T::RCFile.instance
|
121
121
|
rcfile.path = fixture_path + "/.trc"
|
122
|
-
rcfile.active_token.
|
122
|
+
expect(rcfile.active_token).to eq '428004849-cebdct6bwobn'
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
describe
|
127
|
-
it
|
126
|
+
describe "#active_secret" do
|
127
|
+
it "should return default secret" do
|
128
128
|
rcfile = T::RCFile.instance
|
129
129
|
rcfile.path = fixture_path + "/.trc"
|
130
|
-
rcfile.active_secret.
|
130
|
+
expect(rcfile.active_secret).to eq 'epzrjvxtumoc'
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
describe
|
135
|
-
it
|
134
|
+
describe "#delete" do
|
135
|
+
it "should delete the rcfile" do
|
136
136
|
path = project_path + "/tmp/trc"
|
137
137
|
File.open(path, 'w'){|file| file.write(YAML.dump({}))}
|
138
|
-
File.exist?(path).
|
138
|
+
expect(File.exist?(path)).to be_true
|
139
139
|
rcfile = T::RCFile.instance
|
140
140
|
rcfile.path = path
|
141
141
|
rcfile.delete
|
142
|
-
File.exist?(path).
|
142
|
+
expect(File.exist?(path)).to be_false
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
-
describe
|
147
|
-
context
|
148
|
-
it
|
146
|
+
describe "#empty?" do
|
147
|
+
context "when a non-empty file exists" do
|
148
|
+
it "should return false" do
|
149
149
|
rcfile = T::RCFile.instance
|
150
150
|
rcfile.path = fixture_path + "/.trc"
|
151
|
-
rcfile.empty
|
151
|
+
expect(rcfile.empty?).to be_false
|
152
152
|
end
|
153
153
|
end
|
154
|
-
context
|
155
|
-
it
|
154
|
+
context "when file does not exist at path" do
|
155
|
+
it "should return true" do
|
156
156
|
rcfile = T::RCFile.instance
|
157
157
|
rcfile.path = File.expand_path('../fixtures/foo', __FILE__)
|
158
|
-
rcfile.empty
|
158
|
+
expect(rcfile.empty?).to be_true
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
|
-
describe
|
164
|
-
context
|
165
|
-
it
|
163
|
+
describe "#load_file" do
|
164
|
+
context "when file exists at path" do
|
165
|
+
it "should load data from file" do
|
166
166
|
rcfile = T::RCFile.instance
|
167
167
|
rcfile.path = fixture_path + "/.trc"
|
168
|
-
rcfile.load_file['profiles']['testcli']['abc123']['username'].
|
168
|
+
expect(rcfile.load_file['profiles']['testcli']['abc123']['username']).to eq 'testcli'
|
169
169
|
end
|
170
170
|
end
|
171
|
-
context
|
172
|
-
it
|
171
|
+
context "when file does not exist at path" do
|
172
|
+
it "should load default structure" do
|
173
173
|
rcfile = T::RCFile.instance
|
174
174
|
rcfile.path = File.expand_path('../fixtures/foo', __FILE__)
|
175
|
-
rcfile.load_file.keys.sort.
|
175
|
+
expect(rcfile.load_file.keys.sort).to eq ['configuration', 'profiles']
|
176
176
|
end
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
180
|
-
describe
|
181
|
-
it
|
182
|
-
T::RCFile.instance.path.
|
180
|
+
describe "#path" do
|
181
|
+
it "should default to ~/.trc" do
|
182
|
+
expect(T::RCFile.instance.path).to eq File.join(File.expand_path('~'), '.trc')
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
|
-
describe
|
187
|
-
it
|
186
|
+
describe "#path=" do
|
187
|
+
it "should override path" do
|
188
188
|
rcfile = T::RCFile.instance
|
189
189
|
rcfile.path = project_path + "/tmp/trc"
|
190
|
-
rcfile.path.
|
190
|
+
expect(rcfile.path).to eq project_path + "/tmp/trc"
|
191
191
|
end
|
192
|
-
it
|
192
|
+
it "should reload data" do
|
193
193
|
rcfile = T::RCFile.instance
|
194
194
|
rcfile.path = fixture_path + "/.trc"
|
195
|
-
rcfile['testcli']['abc123']['username'].
|
195
|
+
expect(rcfile['testcli']['abc123']['username']).to eq 'testcli'
|
196
196
|
end
|
197
197
|
end
|
198
198
|
|
199
|
-
describe
|
200
|
-
it
|
199
|
+
describe "#profiles" do
|
200
|
+
it "should return profiles" do
|
201
201
|
rcfile = T::RCFile.instance
|
202
202
|
rcfile.path = fixture_path + "/.trc"
|
203
|
-
rcfile.profiles.keys.
|
203
|
+
expect(rcfile.profiles.keys).to eq ['testcli']
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|