ayadn 1.7.1 → 1.7.2

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.
@@ -16,17 +16,55 @@ def init_stubs
16
16
  link: :magenta
17
17
  },
18
18
  timeline: {
19
+ directed: 1,
20
+ deleted: 0,
21
+ html: 0,
22
+ annotations: 1,
23
+ show_source: true,
24
+ show_symbols: true,
19
25
  show_real_name: true,
20
26
  show_date: true,
21
- show_symbols: true,
22
- show_source: true
27
+ show_spinner: true,
28
+ show_debug: false
23
29
  },
24
30
  formats: {table: {width: 75}},
25
31
  counts: {
26
- default: 33
32
+ default: 50,
33
+ unified: 100,
34
+ global: 100,
35
+ checkins: 100,
36
+ conversations: 50,
37
+ photos: 50,
38
+ trending: 100,
39
+ mentions: 100,
40
+ convo: 100,
41
+ posts: 100,
42
+ messages: 50,
43
+ search: 200,
44
+ whoreposted: 50,
45
+ whostarred: 50,
46
+ whatstarred: 100,
47
+ files: 100
27
48
  },
28
49
  scroll: {
29
- timer: 5
50
+ timer: 3
51
+ },
52
+ movie: {
53
+ hashtag: 'nowwatching'
54
+ },
55
+ tvshow: {
56
+ hashtag: 'nowwatching'
57
+ },
58
+ nicerank: {
59
+ threshold: 2.1,
60
+ cache: 48,
61
+ filter: true,
62
+ filter_unranked: false
63
+ },
64
+ backup: {
65
+ auto_save_sent_posts: false,
66
+ auto_save_sent_messages: false,
67
+ auto_save_lists: false
30
68
  }
31
69
  })
32
70
  Ayadn::Settings.stub(:config).and_return({
@@ -54,44 +92,78 @@ describe Ayadn::SetScroll do
54
92
  before do
55
93
  init_stubs
56
94
  end
57
- describe "#validate" do
58
- it "validates a correct timer value" do
59
- timer = Ayadn::SetScroll.new.validate(3)
60
- expect(timer).to eq 3
61
- end
62
- it "validates a correct timer value" do
63
- timer = Ayadn::SetScroll.new.validate(1)
64
- expect(timer).to eq 1
65
- end
66
- it "validates a correct timer value" do
67
- timer = Ayadn::SetScroll.new.validate(2)
68
- expect(timer).to eq 2
69
- end
70
- it "validates a correct timer value" do
71
- timer = Ayadn::SetScroll.new.validate(10.2)
72
- expect(timer).to eq 10
73
- end
74
- it "validates a correct timer value" do
75
- timer = Ayadn::SetScroll.new.validate(1.1)
76
- expect(timer).to eq 1
77
- end
78
- it "sets a default if incorrect timer value" do
79
- timer = Ayadn::SetScroll.new.validate(0)
80
- expect(timer).to eq 3
81
- end
82
- it "sets a default if incorrect timer value" do
83
- timer = Ayadn::SetScroll.new.validate('johnson')
84
- expect(timer).to eq 3
95
+
96
+ describe "#timer" do
97
+ it "creates a default value" do
98
+ expect(Ayadn::Settings.options[:scroll][:timer]).to eq 3
99
+ Ayadn::SetScroll.new.timer('2')
100
+ expect(Ayadn::Settings.options[:scroll][:timer]).to eq 2
101
+ Ayadn::SetScroll.new.timer('4.2')
102
+ expect(Ayadn::Settings.options[:scroll][:timer]).to eq 4
103
+ Ayadn::SetScroll.new.timer('0')
104
+ expect(Ayadn::Settings.options[:scroll][:timer]).to eq 3
105
+ Ayadn::SetScroll.new.timer('johnson')
106
+ expect(Ayadn::Settings.options[:scroll][:timer]).to eq 3
107
+ Ayadn::SetScroll.new.timer('-666')
108
+ expect(Ayadn::Settings.options[:scroll][:timer]).to eq 3
109
+ Ayadn::SetScroll.new.timer('0')
110
+ expect(Ayadn::Settings.options[:scroll][:timer]).to eq 3
85
111
  end
86
- it "sets a default if incorrect timer value" do
87
- timer = Ayadn::SetScroll.new.validate(-666)
88
- expect(timer).to eq 3
112
+ end
113
+
114
+ after do
115
+ File.delete('spec/mock/ayadn.log')
116
+ end
117
+ end
118
+
119
+ describe Ayadn::SetColor do
120
+ before do
121
+ init_stubs
122
+ end
123
+
124
+ describe "#" do
125
+ it "creates a default value" do
126
+ colors_list = %w{red green magenta cyan yellow blue white black}
127
+ %w{id index username name date link dots hashtags mentions source symbols debug}.each do |meth|
128
+ command = meth.to_sym
129
+ color = colors_list.sample
130
+ Ayadn::SetColor.new.send(command, color)
131
+ expect(Ayadn::Settings.options[:colors][command]).to eq color.to_sym
132
+ end
89
133
  end
90
- it "sets a default if incorrect timer value" do
91
- timer = Ayadn::SetScroll.new.validate(0.5)
92
- expect(timer).to eq 3
134
+ end
135
+
136
+ after do
137
+ File.delete('spec/mock/ayadn.log')
138
+ end
139
+ end
140
+
141
+ describe Ayadn::SetTimeline do
142
+ before do
143
+ init_stubs
144
+ end
145
+
146
+ describe "#" do
147
+ it "creates a default value" do
148
+ %w{directed html show_source show_symbols show_real_name show_date show_spinner show_debug}.each do |meth|
149
+ command = meth.to_sym
150
+ Ayadn::SetTimeline.new.send(command, 'true')
151
+ expect(Ayadn::Settings.options[:timeline][command]).to eq true
152
+ printed = capture_stderr do
153
+ expect(lambda {Ayadn::SetTimeline.new.send(command, 'yolo')}).to raise_error(SystemExit)
154
+ end
155
+ expect(printed).to include 'You have to submit valid items'
156
+ end
157
+ ['deleted', 'annotations'].each do |meth|
158
+ command = meth.to_sym
159
+ printed = capture_stderr do
160
+ expect(lambda {Ayadn::SetTimeline.new.send(command, 'false')}).to raise_error(SystemExit)
161
+ end
162
+ expect(printed).to include 'This parameter is not modifiable'
163
+ end
93
164
  end
94
165
  end
166
+
95
167
  after do
96
168
  File.delete('spec/mock/ayadn.log')
97
169
  end
@@ -101,21 +173,22 @@ describe Ayadn::SetCounts do
101
173
  before do
102
174
  init_stubs
103
175
  end
104
- describe "#validate" do
105
- it "validates a correct count value" do
106
- count = Ayadn::SetCounts.new.validate('1')
107
- expect(count).to eq 1
108
- end
109
- it "validates a correct count value" do
110
- count = Ayadn::SetCounts.new.validate('200')
111
- expect(count).to eq 200
112
- end
113
- it "raises error if incorrect count value" do
114
- printed = capture_stderr do
115
- expect(lambda {Ayadn::SetCounts.new.validate('201')}).to raise_error(SystemExit)
176
+
177
+ describe "#" do
178
+ it "creates a default value" do
179
+ %w{default unified global checkins conversations photos trending mentions convo posts messages search whoreposted whostarred whatstarred files}.each do |meth|
180
+ command = meth.to_sym
181
+ Ayadn::SetCounts.new.send(command, '199')
182
+ expect(Ayadn::Settings.options[:counts][command]).to eq 199
183
+ printed = capture_stderr do
184
+ expect(lambda {Ayadn::SetCounts.new.send(command, '333')}).to raise_error(SystemExit)
185
+ end
186
+ expect(printed).to include 'This paramater must be an integer between 1 and 200'
116
187
  end
117
- expect(printed).to include 'This paramater must be an integer between 1 and 200'
118
188
  end
189
+ end
190
+
191
+ describe "#validate" do
119
192
  it "raises error if incorrect count value" do
120
193
  printed = capture_stderr do
121
194
  expect(lambda {Ayadn::SetCounts.new.validate('0')}).to raise_error(SystemExit)
@@ -138,27 +211,30 @@ describe Ayadn::SetBackup do
138
211
  before do
139
212
  init_stubs
140
213
  end
141
- describe "#validate" do
142
- it "validates a correct boolean" do
143
- value = Ayadn::SetBackup.new.validate('1')
144
- expect(value).to eq true
145
- end
146
- it "validates a correct boolean" do
147
- value = Ayadn::SetBackup.new.validate('true')
148
- expect(value).to eq true
149
- end
150
- it "validates a correct boolean" do
151
- value = Ayadn::SetBackup.new.validate('TrUe')
152
- expect(value).to eq true
214
+
215
+ describe "#auto_save_sent_posts" do
216
+ it "creates a default value" do
217
+ expect(Ayadn::Settings.options[:backup][:auto_save_sent_posts]).to eq false
218
+ Ayadn::SetBackup.new.auto_save_sent_posts('1')
219
+ expect(Ayadn::Settings.options[:backup][:auto_save_sent_posts]).to eq true
153
220
  end
154
- it "validates a correct boolean" do
155
- value = Ayadn::SetBackup.new.validate('false')
156
- expect(value).to eq false
221
+ end
222
+ describe "#auto_save_sent_messages" do
223
+ it "creates a default value" do
224
+ expect(Ayadn::Settings.options[:backup][:auto_save_sent_messages]).to eq false
225
+ Ayadn::SetBackup.new.auto_save_sent_messages('True')
226
+ expect(Ayadn::Settings.options[:backup][:auto_save_sent_messages]).to eq true
157
227
  end
158
- it "validates a correct boolean" do
159
- value = Ayadn::SetBackup.new.validate('fAlsE')
160
- expect(value).to eq false
228
+ end
229
+ describe "#auto_save_lists" do
230
+ it "creates a default value" do
231
+ expect(Ayadn::Settings.options[:backup][:auto_save_lists]).to eq false
232
+ Ayadn::SetBackup.new.auto_save_lists('YES')
233
+ expect(Ayadn::Settings.options[:backup][:auto_save_lists]).to eq true
161
234
  end
235
+ end
236
+
237
+ describe "#validate" do
162
238
  it "validates a correct boolean" do
163
239
  value = Ayadn::SetBackup.new.validate('0')
164
240
  expect(value).to eq false
@@ -174,3 +250,98 @@ describe Ayadn::SetBackup do
174
250
  File.delete('spec/mock/ayadn.log')
175
251
  end
176
252
  end
253
+
254
+ describe Ayadn::SetMovie do
255
+ before do
256
+ init_stubs
257
+ end
258
+ describe "#hashtag" do
259
+ it "creates a new hashtag default" do
260
+ expect(Ayadn::Settings.options[:movie][:hashtag]).to eq 'nowwatching'
261
+ Ayadn::SetMovie.new.hashtag('yolo')
262
+ expect(Ayadn::Settings.options[:movie][:hashtag]).to eq 'yolo'
263
+ end
264
+ end
265
+ after do
266
+ File.delete('spec/mock/ayadn.log')
267
+ end
268
+ end
269
+
270
+ describe Ayadn::SetTVShow do
271
+ before do
272
+ init_stubs
273
+ end
274
+ describe "#hashtag" do
275
+ it "creates a new hashtag default" do
276
+ expect(Ayadn::Settings.options[:tvshow][:hashtag]).to eq 'nowwatching'
277
+ Ayadn::SetTVShow.new.hashtag('yolo')
278
+ expect(Ayadn::Settings.options[:tvshow][:hashtag]).to eq 'yolo'
279
+ end
280
+ end
281
+ after do
282
+ File.delete('spec/mock/ayadn.log')
283
+ end
284
+ end
285
+
286
+ describe Ayadn::SetNiceRank do
287
+ before do
288
+ init_stubs
289
+ end
290
+ describe "#threshold" do
291
+ it "creates a new threshold default" do
292
+ expect(Ayadn::Settings.options[:nicerank][:threshold]).to eq 2.1
293
+ Ayadn::SetNiceRank.new.threshold('3')
294
+ expect(Ayadn::Settings.options[:nicerank][:threshold]).to eq 3
295
+ Ayadn::SetNiceRank.new.threshold('3.2')
296
+ expect(Ayadn::Settings.options[:nicerank][:threshold]).to eq 3.2
297
+ printed = capture_stderr do
298
+ expect(lambda {Ayadn::SetNiceRank.new.threshold('6')}).to raise_error(SystemExit)
299
+ end
300
+ expect(printed).to include 'Please enter a value between 0.1 and 3.5, example: 2.1'
301
+ printed = capture_stderr do
302
+ expect(lambda {Ayadn::SetNiceRank.new.threshold('yolo')}).to raise_error(SystemExit)
303
+ end
304
+ expect(printed).to include 'Please enter a value between 0.1 and 3.5, example: 2.1'
305
+ end
306
+ end
307
+ describe "#filter" do
308
+ it "creates a new filter default" do
309
+ expect(Ayadn::Settings.options[:nicerank][:filter]).to eq true
310
+ Ayadn::SetNiceRank.new.filter('false')
311
+ expect(Ayadn::Settings.options[:nicerank][:filter]).to eq false
312
+ Ayadn::SetNiceRank.new.filter('1')
313
+ expect(Ayadn::Settings.options[:nicerank][:filter]).to eq true
314
+ printed = capture_stderr do
315
+ expect(lambda {Ayadn::SetNiceRank.new.filter('6')}).to raise_error(SystemExit)
316
+ end
317
+ expect(printed).to include "You have to submit valid items. See 'ayadn -sg' for a list of valid parameters and values."
318
+ end
319
+ end
320
+ describe "#filter_unranked" do
321
+ it "creates a new filter_unranked default" do
322
+ expect(Ayadn::Settings.options[:nicerank][:filter_unranked]).to eq false
323
+ Ayadn::SetNiceRank.new.filter_unranked('true')
324
+ expect(Ayadn::Settings.options[:nicerank][:filter_unranked]).to eq true
325
+ Ayadn::SetNiceRank.new.filter_unranked('0')
326
+ expect(Ayadn::Settings.options[:nicerank][:filter_unranked]).to eq false
327
+ printed = capture_stderr do
328
+ expect(lambda {Ayadn::SetNiceRank.new.filter_unranked('yolo')}).to raise_error(SystemExit)
329
+ end
330
+ expect(printed).to include "You have to submit valid items. See 'ayadn -sg' for a list of valid parameters and values."
331
+ end
332
+ end
333
+ describe "#cache" do
334
+ it "creates a new cache default" do
335
+ expect(Ayadn::Settings.options[:nicerank][:cache]).to eq 48
336
+ Ayadn::SetNiceRank.new.cache('72.4')
337
+ expect(Ayadn::Settings.options[:nicerank][:cache]).to eq 72
338
+ printed = capture_stderr do
339
+ expect(lambda {Ayadn::SetNiceRank.new.cache('200')}).to raise_error(SystemExit)
340
+ end
341
+ expect(printed).to include "Please enter a number of hours between 1 and 168"
342
+ end
343
+ end
344
+ after do
345
+ File.delete('spec/mock/ayadn.log')
346
+ end
347
+ end
@@ -51,21 +51,125 @@ describe Ayadn::View do
51
51
  end
52
52
 
53
53
  let(:stream) { JSON.parse(File.read("spec/mock/stream.json")) }
54
+ let(:list) { JSON.parse(File.read("spec/mock/fwr_@ayadn.json")) }
55
+ let(:int) { JSON.parse(File.read("spec/mock/int.json")) }
56
+ let(:files) { JSON.parse(File.read("spec/mock/files.json")) }
57
+ let(:user_e) { JSON.parse(File.read("spec/mock/@ericd.json")) }
58
+ let(:users) { {"007"=>["bond", "James Bond", true, true], "666"=>["mrtest", "Mr Test", false, false]} }
59
+
60
+ # describe "#show_list_reposted" do
61
+ # before do
62
+ # Ayadn::NiceRank.stub(:from_ids).and_return([{}])
63
+ # end
64
+ # it "outputs the reposters list" do
65
+ # printed = capture_stdout do
66
+ # Ayadn::View.new.show_list_reposted(list[0]['data'], 123456)
67
+ # end
68
+ # expect(printed).to include *['Joel Timmins', 'Donny Davis', 'Nicolas Maumont', '95.41', 'reposted post']
69
+ # end
70
+ # end
71
+
72
+ # describe "#show_list_starred" do
73
+ # before do
74
+ # Ayadn::NiceRank.stub(:from_ids).and_return([{}])
75
+ # end
76
+ # it "outputs the starred list" do
77
+ # printed = capture_stdout do
78
+ # Ayadn::View.new.show_list_starred(list[0]['data'], 123456)
79
+ # end
80
+ # expect(printed).to include *['Joel Timmins', 'Donny Davis', 'Nicolas Maumont', '95.41', 'starred post']
81
+ # end
82
+ # end
83
+
84
+ # describe "#show_list_followings" do
85
+ # before do
86
+ # Ayadn::NiceRank.stub(:from_ids).and_return([{}])
87
+ # end
88
+ # it "outputs the followings list" do
89
+ # printed = capture_stdout do
90
+ # Ayadn::View.new.show_list_followings(users, '@bond')
91
+ # end
92
+ # expect(printed).to include *['List of users', 'is following', '0.83']
93
+ # end
94
+ # end
95
+
96
+ # describe "#show_list_followers" do
97
+ # before do
98
+ # Ayadn::NiceRank.stub(:from_ids).and_return([{}])
99
+ # end
100
+ # it "outputs the followers list" do
101
+ # printed = capture_stdout do
102
+ # Ayadn::View.new.show_list_followers(users, '@bond')
103
+ # end
104
+ # expect(printed).to include *['List of users following', '0.83']
105
+ # end
106
+ # end
107
+
108
+ # describe "#show_list_muted" do
109
+ # before do
110
+ # Ayadn::NiceRank.stub(:from_ids).and_return([{}])
111
+ # end
112
+ # it "outputs the muted list" do
113
+ # printed = capture_stdout do
114
+ # Ayadn::View.new.show_list_muted(users)
115
+ # end
116
+ # expect(printed).to include *['List of users you muted', '0.83']
117
+ # end
118
+ # end
119
+
120
+ # describe "#show_list_blocked" do
121
+ # before do
122
+ # Ayadn::NiceRank.stub(:from_ids).and_return([{}])
123
+ # end
124
+ # it "outputs the blocked list" do
125
+ # printed = capture_stdout do
126
+ # Ayadn::View.new.show_list_blocked(users)
127
+ # end
128
+ # expect(printed).to include *['List of users you blocked', '0.83']
129
+ # end
130
+ # end
131
+
132
+ describe "#show_interactions" do
133
+ it "outputs the interactions list" do
134
+ printed = capture_stdout do
135
+ Ayadn::View.new.show_interactions(int['data'])
136
+ end
137
+ expect(printed).to include *['2013-11-02 17:15:08', 'followed you']
138
+ end
139
+ end
140
+
141
+ describe "#show_files_list" do
142
+ it "outputs the files list" do
143
+ printed = capture_stdout do
144
+ Ayadn::View.new.show_files_list(files)
145
+ end
146
+ expect(printed).to include *['2014-08-31 15:41:41', 'png', '969', '512', 'w2xvwKNf2']
147
+ end
148
+ end
54
149
 
55
150
  describe "#show_posts" do
56
151
  it 'outputs the stream' do
57
152
  printed = capture_stdout do
58
- Ayadn::View.new.show_posts(stream['data'], {})
153
+ Ayadn::View.new.show_posts(stream['data'])
59
154
  end
60
155
  expect(printed).to include "23184500"
61
156
  expect(printed).to include "Backer of the Day"
62
157
  end
63
158
  end
64
159
 
160
+ describe "#show_raw" do
161
+ it 'outputs the raw stream' do
162
+ printed = capture_stdout do
163
+ Ayadn::View.new.show_raw(stream['data'][0])
164
+ end
165
+ expect(printed).to include '"created_at": "2013-05-19T22:33:57Z"'
166
+ end
167
+ end
168
+
65
169
  describe "#show_simple_post" do
66
170
  it 'outputs one post' do
67
171
  printed = capture_stdout do
68
- Ayadn::View.new.show_simple_post([stream['data'][0]], {})
172
+ Ayadn::View.new.show_simple_post([stream['data'][0]])
69
173
  end
70
174
  expect(printed).to include "23187443"
71
175
  expect(printed).to include "Julia Cory"
@@ -75,15 +179,13 @@ describe Ayadn::View do
75
179
  describe "#show_posts_with_index" do
76
180
  it 'outputs the indexed stream' do
77
181
  printed = capture_stdout do
78
- Ayadn::View.new.show_posts_with_index(stream['data'], {}, {})
182
+ Ayadn::View.new.show_posts_with_index(stream['data'])
79
183
  end
80
184
  expect(printed).to include "001"
81
185
  expect(printed).to include "Backer of the Day"
82
186
  end
83
187
  end
84
188
 
85
- let(:user_e) { JSON.parse(File.read("spec/mock/@ericd.json")) }
86
-
87
189
  describe "#show_userinfos" do
88
190
  it "outputs user info" do
89
191
  printed = capture_stdout do