ayadn 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,12 +17,16 @@ describe Ayadn::Workers do
17
17
  Ayadn::Logs.stub(:rec).and_return("logged")
18
18
  Ayadn::Databases.stub(:blacklist).and_return("blacklist")
19
19
  Ayadn::Databases.stub(:users).and_return("users")
20
+ Ayadn::Databases.stub(:get_post_from_index).and_return({id: 3312})
21
+ Ayadn::Databases.stub(:get_index_length).and_return(50)
20
22
  @workers = Ayadn::Workers.new
21
23
  end
22
24
 
23
25
  let(:data) { JSON.parse(File.read("spec/mock/stream.json")) }
24
26
  let(:checkins) { JSON.parse(File.read("spec/mock/checkins.json")) }
25
27
  let(:regex_post) { JSON.parse(File.read("spec/mock/regex.json")) }
28
+ let(:users_list) { JSON.parse(File.read("spec/mock/fwr_@ayadn.json")) }
29
+ let(:rest) {Ayadn::CNX = double} #verbose in RSpec output, but useful
26
30
 
27
31
  describe "#build_posts" do
28
32
  it "builds posts hash from stream" do
@@ -52,6 +56,27 @@ describe Ayadn::Workers do
52
56
  end
53
57
  end
54
58
 
59
+ describe "#all_but_me" do
60
+ it "gets rid of 'me' and adds arobase if needed to other usernames" do
61
+ names = @workers.all_but_me(['yolo', '@james', 'me'])
62
+ expect(names).to eq ['@yolo', '@james']
63
+ end
64
+ end
65
+
66
+ describe "#get_real_post_id" do
67
+ it "gets real post id" do
68
+ id = @workers.get_real_post_id(8)
69
+ expect(id).to eq 3312
70
+ end
71
+ end
72
+
73
+ describe "#links_from_posts" do
74
+ it "extract links" do
75
+ links = @workers.links_from_posts(data)
76
+ expect(links).to eq ["http://feed.500px.com/~r/500px-best/~3/c2tMPEJVf6I/61517259", "https://app.net/b/m6bk3", "http://bit.ly/1cr16vM", "http://feed.500px.com/~r/500px-best/~3/i4uhLN-4rd4/61484745", "http://www.newscientist.com/article/dn25068-wikipediasize-maths-proof-too-big-for-humans-to-check.html#.UwTuA3gRq8M", "http://news.ycombinator.com/item?id=7264886", "http://ift.tt/1d0TA7I", "http://feed.500px.com/~r/500px-best/~3/hFi3AUnh_u8/61493427", "http://Experiment.com", "http://priceonomics.com/how-microryza-acquired-the-domain-experimentcom/", "http://news.ycombinator.com/item?id=7265540", "http://feeds.popsci.com/c/34567/f/632419/s/374c6496/sc/38/l/0L0Spopsci0N0Carticle0Cscience0Ccat0Ebites0Eare0Elinked0Edepression/story01.htm?utm_medium=App.net&utm_source=PourOver", "http://ift.tt/1mtTrU9"]
77
+ end
78
+ end
79
+
55
80
  describe "#extract_hashtags" do
56
81
  it "extracts hashtags" do
57
82
  tags = @workers.extract_hashtags(data['data'][0])
@@ -66,6 +91,15 @@ describe Ayadn::Workers do
66
91
  end
67
92
  end
68
93
 
94
+ describe "#extract_users" do
95
+ it "extracts users" do
96
+ usr = @workers.extract_users(users_list[0])
97
+ expect(usr["52985"]).to eq ["schmidt_fu", "Florian Schmidt", false, false]
98
+ expect(usr["185581"]).to eq ["aya_tests", "@ericd's tests account", nil, nil]
99
+ expect(usr["69904"]).to eq ["ericd", "Eric Dejonckheere", true, true]
100
+ end
101
+ end
102
+
69
103
  describe "#extract_checkins" do
70
104
  it "extracts checkins" do
71
105
  posts = @workers.build_posts(checkins['data'])
@@ -82,52 +116,64 @@ describe Ayadn::Workers do
82
116
  end
83
117
  end
84
118
 
85
- # let(:list) { {"007"=>["bond", "James Bond", true, true], "666"=>["mrtest", "Mr Test", false, false]} }
86
-
87
- # describe "#build_followers_list" do
88
- # it 'builds the followers table list' do
89
- # printed = capture_stdout do
90
- # puts @workers.build_followers_list(list, "@test")
91
- # end
92
- # expect(printed).to include "@test"
93
- # expect(printed).to include "@bond"
94
- # expect(printed).to include "Mr Test"
95
- # end
96
- # end
97
-
98
- # describe "#build_followings_list" do
99
- # it 'builds the followings table list' do
100
- # printed = capture_stdout do
101
- # puts @workers.build_followings_list(list, "@test")
102
- # end
103
- # #expect(printed).to include "+~~~~"
104
- # expect(printed).to include "@test"
105
- # expect(printed).to include "@bond"
106
- # expect(printed).to include "Mr Test"
107
- # end
108
- # end
109
-
110
- # describe "#build_muted_list" do
111
- # it 'builds the muted table list' do
112
- # printed = capture_stdout do
113
- # puts @workers.build_muted_list(list)
114
- # end
115
- # #expect(printed).to include "+----"
116
- # expect(printed).to include "@bond"
117
- # expect(printed).to include "Mr Test"
118
- # end
119
- # end
120
-
121
- # describe "#build_blocked_list" do
122
- # it 'builds the blocked table list' do
123
- # printed = capture_stdout do
124
- # puts @workers.build_blocked_list(list)
125
- # end
126
- # #expect(printed).to include "+----"
127
- # expect(printed).to include "@bond"
128
- # expect(printed).to include "Mr Test"
129
- # end
130
- # end
119
+ let(:list) { {"007"=>["bond", "James Bond", true, true], "666"=>["mrtest", "Mr Test", false, false]} }
120
+
121
+ describe "#build_followers_list" do
122
+ before do
123
+ rest.stub(:get)
124
+ end
125
+ it 'builds the followers table list' do
126
+ printed = capture_stdout do
127
+ puts @workers.build_followers_list(list, "@test")
128
+ end
129
+ expect(printed).to include "@test"
130
+ expect(printed).to include "@bond"
131
+ expect(printed).to include "Mr Test"
132
+ end
133
+ end
134
+
135
+ describe "#build_followings_list" do
136
+ before do
137
+ rest.stub(:get)
138
+ end
139
+ it 'builds the followings table list' do
140
+ printed = capture_stdout do
141
+ puts @workers.build_followings_list(list, "@test")
142
+ end
143
+ #expect(printed).to include "+~~~~"
144
+ expect(printed).to include "@test"
145
+ expect(printed).to include "@bond"
146
+ expect(printed).to include "Mr Test"
147
+ end
148
+ end
149
+
150
+ describe "#build_muted_list" do
151
+ before do
152
+ rest.stub(:get)
153
+ end
154
+ it 'builds the muted table list' do
155
+ printed = capture_stdout do
156
+ puts @workers.build_muted_list(list)
157
+ end
158
+ #expect(printed).to include "+----"
159
+ expect(printed).to include "@bond"
160
+ expect(printed).to include "Mr Test"
161
+ end
162
+ end
163
+
164
+ describe "#build_blocked_list" do
165
+ before do
166
+ rest.stub(:get)
167
+ end
168
+ it 'builds the blocked table list' do
169
+ printed = capture_stdout do
170
+ puts @workers.build_blocked_list(list)
171
+ end
172
+ #expect(printed).to include "+----"
173
+ expect(printed).to include "@bond"
174
+ expect(printed).to include "Mr Test"
175
+ end
176
+ end
131
177
 
132
178
  describe "#add_arobase_if_missing" do
133
179
  it 'adds @ to username' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ayadn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dejonckheere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-02 00:00:00.000000000 Z
11
+ date: 2014-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -303,10 +303,14 @@ files:
303
303
  - spec/mock/aliases.db
304
304
  - spec/mock/blacklist.db
305
305
  - spec/mock/bookmarks.db
306
+ - spec/mock/channels.json
306
307
  - spec/mock/checkins.json
308
+ - spec/mock/files.json
307
309
  - spec/mock/fwr_@ayadn.json
308
310
  - spec/mock/index.db
311
+ - spec/mock/int.json
309
312
  - spec/mock/nicerank.db
313
+ - spec/mock/nicerank.json
310
314
  - spec/mock/nicerank.log
311
315
  - spec/mock/pagination.db
312
316
  - spec/mock/posted.json
@@ -314,11 +318,13 @@ files:
314
318
  - spec/mock/stream.json
315
319
  - spec/mock/users.db
316
320
  - spec/spec_helper.rb
321
+ - spec/unit/annotations_spec.rb
317
322
  - spec/unit/api_spec.rb
318
323
  - spec/unit/blacklistworkers_spec.rb
319
324
  - spec/unit/databases_spec.rb
320
325
  - spec/unit/descriptions_spec.rb
321
326
  - spec/unit/endpoints_spec.rb
327
+ - spec/unit/nicerank_spec.rb
322
328
  - spec/unit/post_spec.rb
323
329
  - spec/unit/set_spec.rb
324
330
  - spec/unit/status_spec.rb
@@ -356,10 +362,14 @@ test_files:
356
362
  - spec/mock/aliases.db
357
363
  - spec/mock/blacklist.db
358
364
  - spec/mock/bookmarks.db
365
+ - spec/mock/channels.json
359
366
  - spec/mock/checkins.json
367
+ - spec/mock/files.json
360
368
  - spec/mock/fwr_@ayadn.json
361
369
  - spec/mock/index.db
370
+ - spec/mock/int.json
362
371
  - spec/mock/nicerank.db
372
+ - spec/mock/nicerank.json
363
373
  - spec/mock/nicerank.log
364
374
  - spec/mock/pagination.db
365
375
  - spec/mock/posted.json
@@ -367,11 +377,13 @@ test_files:
367
377
  - spec/mock/stream.json
368
378
  - spec/mock/users.db
369
379
  - spec/spec_helper.rb
380
+ - spec/unit/annotations_spec.rb
370
381
  - spec/unit/api_spec.rb
371
382
  - spec/unit/blacklistworkers_spec.rb
372
383
  - spec/unit/databases_spec.rb
373
384
  - spec/unit/descriptions_spec.rb
374
385
  - spec/unit/endpoints_spec.rb
386
+ - spec/unit/nicerank_spec.rb
375
387
  - spec/unit/post_spec.rb
376
388
  - spec/unit/set_spec.rb
377
389
  - spec/unit/status_spec.rb