fake_friends 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5159c5ac6e51192def23c97dd3df200b58422654
4
- data.tar.gz: a06642226fda12364617bbcee70f2ba2c839a20a
3
+ metadata.gz: aa126944bb6f960473714414b4cb44a87ed8deef
4
+ data.tar.gz: bc9568f7a519b8fd8f16585d12a60cc7953a2157
5
5
  SHA512:
6
- metadata.gz: 63557e8211a9989bcd04b22bc39c8e5a38378077769b7113dbe6728663b9224069f907d2a35842d02280005db4a566bed49da647215e824c5403de2430da4595
7
- data.tar.gz: f5cf11ef7c29b67e25b16b4653b3c5802f78909e169d90491f76574b7efb17b33fcb90c1eee750d3ebd0a9591ff999a675ce895f1b074de28ae9758d78310e70
6
+ metadata.gz: f4647bda8cbefc8938ccbb4bcf80b644784cfb4852bd041a6894ea1ed8c3c02d1bdcad310cf8e6dd1633740d4fd0e2d606c62ee9665032518109b9cb14ec8b19
7
+ data.tar.gz: 60ee89b9a857e5b7ca077cf18aee6be1f57256945e97296f81aa56e64f95cf562a5ccb8e649fbff36e59a79ce88afaefacf25507e5f37ca0350615f0280b2c7a
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --fail-fast
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source 'https://rubygems.org'
2
-
3
2
  gemspec
3
+
data/README.md CHANGED
@@ -1,24 +1,70 @@
1
1
  # FakeFriends
2
2
 
3
- A ruby gem for generating consistent fake user data (for demoing social networking apps.)
3
+ A simple [ruby gem](https://rubygems.org/gems/fake_friends) to generate consistent and realistic fake user data for demoing social networking apps (e.g., user names match their avatars, fake posts are pulled from actual Twitter posts rather than lorem text, etc).
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Add this line to your application's Gemfile: `gem 'fake_friends'`
8
8
 
9
- gem 'fake_friends'
9
+ And then execute: `$ bundle`
10
10
 
11
- And then execute:
11
+ Or install it yourself as: `$ gem install fake_friends`
12
12
 
13
- $ bundle
14
13
 
15
- Or install it yourself as:
14
+ ## The FakeFriend class
16
15
 
17
- $ gem install fake_friends
16
+ #### class methods
17
+ * `::gather(n)`
18
+ `n`: int (number of user objects to create)
19
+ * `::find_by(options)`
20
+ `options`: { `username:` string (twitter username) } or { `id:` int (from 1 to 101) }
21
+
22
+ #### instance methods
23
+ * `#username`
24
+ * `#name`
25
+ * `#description`
26
+ * `#avatar_url(size)`
27
+ `size`: requested size of image. Available in 128, 64, 48, and 24 px.
28
+ Returns a url to an image in the closest available size.
29
+ * `#url`
30
+ * `#posts`
18
31
 
19
32
  ## Usage
20
33
 
21
- TODO: Instructions on the way.
34
+ With `include FakeFriends` assumed, use
35
+
36
+ FakeFriend.gather(5)
37
+
38
+ to return an array of 5 `FakeFriend` objects.
39
+
40
+ user = FakeFriend.find_by(id: 5)
41
+
42
+ returns the fifth user in the library and assigns it to `user`.
43
+
44
+ `user.avatar_url(size)` pulls an avatar from uiFaces.com, where Twitter users have contributed their profile photos.
45
+ The available sizes (in pixels) are 128, 64, 48, and 24. The method will choose the image closest in size
46
+ to the requested `size`.
47
+
48
+ `user.url` returns a hash with an `:expanded` url (e.g. `http://www.google.com`) and a `:display` url (e.g. `google.com`).
49
+
50
+ `user.posts` returns an array of `user`'s status updates.
51
+
52
+
53
+ ## Data
54
+
55
+ The library currently holds 101 users with associated status updates. Associated image urls are generated from the username.
56
+
57
+ ## Source
58
+ Images come from user contributions on uiFaces.com.
59
+ Posts are non-retweet tweets from the associated twitter profiles (all public).
60
+
61
+ Many thanks to these users for their contributions.
62
+
63
+
64
+ ## Future work
65
+
66
+ A hundred users should be enough for most demoing needs, but a method to fetch new user
67
+ data right from the FakeFriends class may be added in future.
22
68
 
23
69
  ## Contributing
24
70
 
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+ task default: :spec
data/dev/usernames.yml CHANGED
@@ -1,202 +1,521 @@
1
1
  ---
2
2
  - idiot
3
- - lukasoppermann
4
- - claudioguglieri
3
+ - divya
5
4
  - mizko
6
- - jesseddy
7
- - lepinski
8
- - ryanAmurphy
9
- - mozato
10
- - nicklacke
5
+ - chadengle
6
+ - ManikRathee
7
+ - joshhemsley
8
+ - leemunroe
9
+ - joshaustin
10
+ - mutlu82
11
+ - soyjavi
12
+ - simobenso
13
+ - sindresorhus
14
+ - RobSterlini
15
+ - BillSKenney
16
+ - Chakintosh
17
+ - jayrobinson
18
+ - thierrykoblentz
19
+ - VinThomas
20
+ - victorerixon
21
+ - adellecharles
22
+ - nicolasfolliot
23
+ - linux29
24
+ - ahmetsulek
25
+ - ot
26
+ - alagoon
27
+ - markjenkins
28
+ - kennyadr
29
+ - chatyrko
30
+ - angelceballos
31
+ - gt
32
+ - mds
33
+ - syropian
34
+ - iamgarth
35
+ - calebogden
36
+ - roybarberuk
37
+ - malykhinv
38
+ - _victa
39
+ - ZacharyZorbas
40
+ - flashmurphy
41
+ - kushsolitary
42
+ - weglov
43
+ - Stievius
44
+ - RussellBishop
11
45
  - ChrisFarina78
12
- - lepetitogre
13
- - jpadilla_
14
- - mocabyte
15
- - sjoerd_dijkstra
46
+ - jedbridges
47
+ - BrianPurkiss
48
+ - traneblow
49
+ - anoff
50
+ - michaelmartinho
51
+ - commadelimited
16
52
  - snowshade
17
- - macvhustle
18
- - jitachi
19
- - _pedropinho
20
53
  - herrhaase
21
- - markwienands
22
- - meghanglass
23
- - gravityonmars
24
- - rizwanjavaid
25
- - gabrielvaldivia
26
- - ogvidius
27
- - alagoon
28
- - brianmaloney
29
- - mds
30
- - eugeneeweb
31
- - edmondyang
32
- - alek_djuric
33
- - poopsplat
34
- - Anotherdagou
35
- - Chakintosh
36
- - alexivanichkin
37
- - faridelnasire
38
- - meddeg
39
- - jordyvdboom
40
- - kolage
41
- - ormanclark
42
- - maiklam
43
- - hsinyo23
44
- - DesignerDusko
45
- - keryilmaz
54
+ - envex
55
+ - Skyhartman
56
+ - bublienko
57
+ - sgaurav_baghel
58
+ - ultragex
59
+ - ruzinav
60
+ - jarjan
61
+ - ariil
62
+ - igorgarybaldi
63
+ - marakasina
64
+ - areus
65
+ - fuck_you_two
66
+ - abdullindenis
67
+ - andyisonline
46
68
  - damenleeturks
47
- - jcarlosweb
69
+ - devankoshal
70
+ - GavicoInd
71
+ - baliomega
72
+ - joelhelin
73
+ - keryilmaz
74
+ - tomas_janousek
75
+ - garand
76
+ - kylefoundry
77
+ - jesseddy
78
+ - arindam_
79
+ - anatolinicolae
80
+ - sta1ex
81
+ - LucasPerdidao
82
+ - pmeissner
83
+ - shalt0ni
84
+ - plbabin
85
+ - operatino
86
+ - dpmachado
87
+ - sharvin
88
+ - chacky14
89
+ - timothycd
90
+ - swaplord
91
+ - AdamMarsBar
92
+ - Karimmove
93
+ - kanickairaj
94
+ - hugomano
95
+ - funwatercat
96
+ - krasnoukhov
97
+ - akmur
98
+ - shanehudson
99
+ - kaelifa
100
+ - g3d
101
+ - IsaryAmairani
102
+ - psdesignuk
103
+ - kudretkeskin
104
+ - felipecsl
105
+ - BryanHorsey
106
+ - irae
107
+ - borges_marcos
108
+ - souuf
109
+ - devinhalladay
110
+ - bassamology
111
+ - SULiik
112
+ - shaneIxD
48
113
  - petrangr
49
- - OskarLevinson
50
- - odaymashalla
51
- - devstrong
114
+ - dahparra
115
+ - noufalibrahim
116
+ - dmitriychuta
117
+ - h1brd
118
+ - Elt_n
119
+ - dhooyenga
120
+ - aroon_sharma
121
+ - mekal
122
+ - phillapier
123
+ - AM_Kn2
124
+ - d_nny_m_cher
125
+ - nateschulte
126
+ - djsherman
127
+ - davidhemphill
128
+ - antonyzotov
129
+ - xripunov
130
+ - mocabyte
131
+ - Silveredge9
132
+ - S0ufi4n3
133
+ - muringa
134
+ - daykiine
135
+ - gcmorley
136
+ - derienzo777
137
+ - adamnac
138
+ - adobi
139
+ - vovkasolovev
140
+ - scrapdnb
141
+ - jordyvdboom
142
+ - mcflydesign
143
+ - namankreative
144
+ - myastro
52
145
  - danro
53
- - dorinvancea
54
- - victorerixon
55
- - denykhoung
56
- - zainiafzan
57
- - rob_thomas10
58
- - WhatTheFerguson
59
- - BillSKenney
60
- - mufaddal_mw
61
- - ed_lea
62
- - Rafa3mil
63
- - mambows
146
+ - kkusaa
147
+ - victorDubugras
148
+ - ajaxy_ru
149
+ - chris_witko
150
+ - gaborenton
151
+ - victor_haydin
152
+ - plasticine
153
+ - BroumiYoussef
154
+ - chrisvanderkooi
155
+ - d_kobelyatsky
156
+ - artvavs
157
+ - nsamoylov
158
+ - prinzadi
159
+ - samuelkraft
160
+ - osmanince
161
+ - arpitnj
162
+ - ky
163
+ - beshur
164
+ - romanbulah
165
+ - sebashton
166
+ - rahmeen
167
+ - daniloc
168
+ - superoutman
169
+ - the_purplebunny
170
+ - marcoramires
171
+ - sokaniwaal
64
172
  - de_ascanio
65
- - nyeauls
66
- - SiskaFlaurensia
173
+ - perfectflow
174
+ - gseguin
175
+ - n3dmax
176
+ - maiklam
67
177
  - YoungCutlass
68
- - psdesignuk
69
- - yayteejay
70
- - ZanderSays
71
- - bluesix
72
- - leevigraham
178
+ - craigrcoles
179
+ - anthonysukow
180
+ - stevedesigner
181
+ - rob_thomas10
182
+ - jjsiii
183
+ - Talbi_ConSept
184
+ - martinansty
185
+ - hugocornejo
186
+ - r_oy
187
+ - naupintos
188
+ - vanchesz
189
+ - jcubic
190
+ - mtolokonnikov
191
+ - victorquinn
192
+ - sementiy
193
+ - gregsqueeb
194
+ - AlbertoCococi
195
+ - davidsasda
196
+ - lepinski
197
+ - macxim
198
+ - grahamkennery
199
+ - saulihirvi
200
+ - nerrsoft
201
+ - keyuri85
202
+ - _vojto
203
+ - safrankov
204
+ - lepetitogre
205
+ - moynihan
206
+ - kimcool
207
+ - lmjabreu
208
+ - klimmka
209
+ - antongenkin
210
+ - _scottburgess
211
+ - lisovsky
212
+ - jennyyo
213
+ - ninjad3m0
73
214
  - dotgridline
74
- - bassamology
75
215
  - uxpiper
76
- - mekal
77
- - simobenso
78
- - _scottburgess
79
- - stevedesigner
216
+ - derekcramer
217
+ - wesleytrankin
218
+ - mgonto
219
+ - iamkeithmason
220
+ - helderleal
221
+ - alessandroribe
222
+ - bluesix
223
+ - caspergrl
224
+ - yayteejay
225
+ - gauravjassal
226
+ - desastrozo
227
+ - bfrohs
228
+ - algunsanabria
229
+ - notbadart
230
+ - charlesrpratt
231
+ - carlosjgsousa
232
+ - dansowter
233
+ - nvkznemo
80
234
  - sur4dye
81
- - arjunchetna
82
- - davidsasda
83
- - yashi_el
84
- - jayrobinson
85
- - buryaknick
86
- - RussellBishop
87
- - andrewabogado
88
- - shanehudson
89
- - finchjke
90
- - chris_witko
91
- - IsaryAmairani
92
- - craigrcoles
93
- - kkusaa
94
- - ZacharyZorbas
95
- - jonkspr
96
- - iamjamie
97
- - jsngr
98
- - timothycd
99
- - borges_marcos
100
- - rahmeen
101
- - claudiu_cons
235
+ - nerdgr8
236
+ - cadikkara
237
+ - betraydan
102
238
  - wiljanslofstra
103
- - joshhemsley
104
- - decarola
105
- - ethanzhang
106
- - nastya_mane
107
- - bublienko
108
- - ralph_lam
109
- - divya
110
- - feliperibeiros
239
+ - tgormtx
240
+ - alexivanichkin
241
+ - edobene
242
+ - emmeffess
243
+ - terrorpixel
244
+ - zackeeler
111
245
  - psaikali
112
- - calvintennant
113
- - brampitoyo
114
- - calebogden
115
- - mdsisto
116
- - motherfuton
246
+ - matbeedotcom
247
+ - dnirmal
117
248
  - fran_mchamy
118
- - bu7921
119
- - prekesh
120
- - emmeffess
249
+ - billyroshan
250
+ - dmackerman
251
+ - bboy1895
252
+ - thierrymeier_
121
253
  - kojourin
122
- - sweetdelisa
123
- - sajtoo
124
- - chadengle
125
- - renatolz
126
- - fabioChannel
127
- - thibaud_be
128
- - phillapier
129
- - xripunov
130
- - JeffChausse
131
- - sgaurav_baghel
132
- - dpmachado
133
- - angelceballos
134
- - ntfblog
135
- - evil_trout
136
- - Mr_Stezz
254
+ - benjamin_knight
137
255
  - nckjrvs
138
- - andyisonline
139
- - paul_irish
140
- - marakasina
141
- - iamlouisbullock
142
- - renbyrd
143
- - saulihirvi
144
- - lukejones
145
- - muringa
146
- - michaelmartinho
147
- - zulsdesign
148
- - jjmpsp
149
- - temonehm
150
- - ultragex
151
- - areus
256
+ - andreas_pr
257
+ - joki4
258
+ - jacobbennett
259
+ - alterchuca
260
+ - omnizya
261
+ - andrewabogado
262
+ - 2fockus
263
+ - jffgrdnr
264
+ - Shriiiiimp
265
+ - mdsisto
266
+ - nicklacke
267
+ - marrimo
268
+ - buryaknick
269
+ - nicollerich
270
+ - ormanclark
271
+ - kevinsuttle
272
+ - dotmariusz
273
+ - karimartin
274
+ - jacksonlatka
275
+ - GhaidaZahran
276
+ - ryanAmurphy
277
+ - evil_trout
278
+ - eddywashere
279
+ - Pukhtoogle
280
+ - 24says
281
+ - dhoot_amit
282
+ - woodydotmx
283
+ - donjain
284
+ - WillsB3
285
+ - alan_zhang_
286
+ - ralph_lam
287
+ - marshallchen_
288
+ - eitarafa
289
+ - ProudDesigns
290
+ - hafeeskhan
291
+ - smenov
292
+ - markwienands
293
+ - txcx
294
+ - mufaddal_mw
295
+ - dnezkumar
296
+ - BenouarradeM
297
+ - dixchen
298
+ - thedjpetersen
299
+ - yesmeck
300
+ - bu7921
301
+ - bobwassermann
302
+ - rtyukmaev
303
+ - _pedropinho
304
+ - jay_wilburn
305
+ - jonkspr
306
+ - eugeneeweb
307
+ - apriendeau
308
+ - nastya_mane
152
309
  - salvafc
310
+ - finchjke
311
+ - ntfblog
312
+ - aviddayentonbay
313
+ - overra
314
+ - sweetdelisa
315
+ - lvovenok
316
+ - hsinyo23
317
+ - eyronn
318
+ - mrettenbacher
319
+ - prototype0ne
320
+ - alrra
321
+ - 5takdesign
322
+ - janilychen
323
+ - av4tar
324
+ - vkontakte7
325
+ - shekman
326
+ - jurayev2
327
+ - stubblr
328
+ - tomjrt
329
+ - VITOROFF
330
+ - vane290
331
+ - thibaud_be
332
+ - uxfox
333
+ - gasioshyn
334
+ - shafi_ps
335
+ - thomaztweets
336
+ - betson22
337
+ - ChrisPiechowicz
338
+ - ethanzhang
339
+ - siddhukrs
340
+ - shaanmkhan
341
+ - lukasoppermann
342
+ - BeStrangers
343
+ - brianmaloney
344
+ - RovaneDurso
345
+ - cyndymessah
346
+ - brampitoyo
347
+ - sodevious
348
+ - daniel_love
349
+ - rtaibah
350
+ - claudiu_cons
351
+ - daryl
352
+ - sjoerd_dijkstra
353
+ - eldelentes
354
+ - benpeck
355
+ - ShaunMoynihan
356
+ - danielhaim
357
+ - BhargavJoshee
358
+ - cmozzati
359
+ - CrafterSama
360
+ - gravityonmars
361
+ - SiskaFlaurensia
362
+ - rogie
363
+ - dbox
364
+ - benhowdle
365
+ - arjunchetna
366
+ - tiagocamargo
367
+ - tsnieman
368
+ - ThisIsJohnBrown
369
+ - zackkitzmiller
153
370
  - aaronbushnell
154
- - baliomega
155
- - dnezkumar
156
- - mtolokonnikov
371
+ - ZanderSays
372
+ - Anotherdagou
373
+ - Thibault_MARTIN
374
+ - temonehm
375
+ - zametniy
376
+ - timur_carpeev
377
+ - axelbouaziz
157
378
  - _mrdidi
158
- - grigy
159
- - helderleal
160
- - ninjad3m0
161
- - jayman
162
- - jacksonlatka
379
+ - ArtWorked
380
+ - thisincludes
381
+ - toodlenoodle
382
+ - ariona_rian
383
+ - zainiafzan
384
+ - antoniopratas
163
385
  - cacestgang
386
+ - caldhela
387
+ - vctrfrnndz
388
+ - _joshnh
389
+ - yashi_el
390
+ - zulsdesign
391
+ - walterstephanie
392
+ - bruno_mart
393
+ - alek_djuric
394
+ - sajtoo
395
+ - cibawoman
396
+ - WhatTheFerguson
397
+ - wrightmartin
398
+ - ryanleroux
399
+ - utroda
400
+ - ryanlfoster
401
+ - calvintennant
402
+ - cameronmoll
403
+ - ckor
404
+ - waqar_alamgir
405
+ - cbuchler
406
+ - jcarlosweb
407
+ - ibrahimmaro
408
+ - acoops_
409
+ - alexdraeth
410
+ - jacobseethaler
411
+ - itolmach
412
+ - michalva
413
+ - isaacpvl
414
+ - iamlouisbullock
415
+ - andrewpautler
416
+ - mikebeecham
417
+ - adn
164
418
  - imfine_thankyou
165
- - gilbertglee
166
- - nicollerich
167
- - LucasPerdidao
168
- - 2fockus
169
- - antongenkin
170
- - ky
171
- - BeStrangers
172
- - shalt0ni
419
+ - benefritz
420
+ - todd_coleman
421
+ - Alvaro_Nistal
422
+ - jayman
423
+ - JeffChausse
424
+ - AceEightofSpade
425
+ - mtthlm
426
+ - mikebusby
427
+ - rizwanjavaid
428
+ - tommyskott
429
+ - iamrvazquez
430
+ - lucamusolesi
431
+ - jitachi
432
+ - grigy
433
+ - MarkusOkur
434
+ - motherfuton
435
+ - KrasimirTsonev
436
+ - kolage
437
+ - moradtaleeb
438
+ - lewisflude
439
+ - mambows
440
+ - haibnu
441
+ - mozato
442
+ - mkalalang
443
+ - luhman
444
+ - laurium
445
+ - Mr_Stezz
446
+ - macvhustle
447
+ - iamjamie
448
+ - manspaugh
449
+ - HugoAlbonete
450
+ - leevigraham
451
+ - molovo
452
+ - jjmpsp
453
+ - hvillega
454
+ - JuliaYunLiu
455
+ - owlfurty
456
+ - meddeg
457
+ - devstrong
458
+ - max9xs
459
+ - matejsudar
460
+ - jwphillips
461
+ - dorinvancea
462
+ - lukejones
463
+ - mcmieras
464
+ - jpadilla_
173
465
  - pkhoosh
174
- - the_purplebunny
175
- - brianmacco
176
- - dvidsilva
177
- - sta1ex
178
- - CrafterSama
466
+ - jsngr
467
+ - paul_irish
468
+ - decarola
179
469
  - kirkouimet
180
- - djsherman
181
- - marshallchen_
182
- - flashmurphy
183
- - mkalalang
184
- - anoff
185
- - WillsB3
186
- - nimaa
187
- - andreas_pr
470
+ - dilbert4life
471
+ - pizzulata
472
+ - poopsplat
473
+ - KioG
474
+ - dvidsilva
475
+ - Djeje
476
+ - jonsuh
477
+ - kkbethi
478
+ - meghanglass
479
+ - odaymashalla
480
+ - Fitehal
481
+ - smharley
482
+ - blogonews_ru
483
+ - faridelnasire
484
+ - nonoesp
485
+ - fabioChannel
486
+ - gilbertglee
487
+ - ezeezegg
188
488
  - FreelanceNathan
189
- - alexdraeth
190
- - joki4
489
+ - NashVail
191
490
  - fffabs
192
- - dbox
193
- - hugocornejo
194
- - BhargavJoshee
195
- - charlesrpratt
196
- - lisovsky
197
- - antonyzotov
198
- - arpitnj
199
- - S0ufi4n3
200
- - mrettenbacher
201
- - g3d
202
- ---
491
+ - Fubaruba
492
+ - nyeauls
493
+ - gerwitz
494
+ - feliperibeiros
495
+ - nimaa
496
+ - filipeStorarri
497
+ - renatolz
498
+ - DesignerDusko
499
+ - denykhoung
500
+ - gabediaz
501
+ - desaiguddu
502
+ - Rafa3mil
503
+ - gabrielvaldivia
504
+ - redkeg
505
+ - razvantugui
506
+ - designer_dean
507
+ - ed_lea
508
+ - NastyaVZ
509
+ - rizwaniqbal
510
+ - prekesh
511
+ - neweravin
512
+ - furts
513
+ - ogvidius
514
+ - nhoizey
515
+ - garrettgee
516
+ - renbyrd
517
+ - PtiteNoli
518
+ - gabrielgm
519
+ - OskarLevinson
520
+ - edmondyang
521
+ ...
data/fake_friends.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  # spec.add_runtime_dependency "twitter", "~> 4.8.1"
24
24
 
25
25
  spec.add_development_dependency "twitter", "~> 4.8.1"
26
- # spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "rspec"
27
27
 
28
28
  spec.add_development_dependency "bundler", "~> 1.3"
29
29
  spec.add_development_dependency "rake"
data/lib/fake_friends.rb CHANGED
@@ -12,20 +12,21 @@ module FakeFriends
12
12
  # Friend.gather(n)
13
13
  # returns an array of n user objects
14
14
  def self.gather(n)
15
- users_to_create = FakeFriend.list.keys.sample(n)
16
- users_to_create.map{ |username| FakeFriend.new(username) }
15
+ raise ArgumentError, "Can only gather 1 to 101 FakeFriends" unless n.between?(1, 101)
16
+ users = FakeFriend.list.keys.sample(n)
17
+ users.map{ |username| FakeFriend.new(username) }
17
18
  end
18
19
 
19
20
  # FakeFriend.find_by(options)
20
21
  #
21
22
  # options <hash>
22
23
  # id: n <int>
23
- # position in the users list, 1-100
24
+ # position in the users list, 1-101
24
25
  #
25
26
  # username: str <string>
26
27
  # twitter username
27
28
  #
28
- # Example: FakeFriend.find_by(id: 100)
29
+ # Example: FakeFriend.find_by(id: 101)
29
30
  # => #<User:0x007ff0f286e2d8 ...>
30
31
  #
31
32
  # returns the requested user object
@@ -1,3 +1,3 @@
1
1
  module FalseFriends
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+ include FakeFriends
3
+
4
+ describe FakeFriend do
5
+
6
+ # it { should respond_to(:gather).with(1).argument }
7
+ # it { should respond_to(:find_by).with(1).argument }
8
+
9
+ describe "::gather" do
10
+
11
+ context "with valid input" do
12
+ let(:users){ FakeFriend.gather(5) }
13
+
14
+ it "returns an array of FakeFriends" do
15
+ expect(users).to be_an Array
16
+ expect(users).to be_composed_of FakeFriend
17
+ end
18
+
19
+ it "returns the requested number objects" do
20
+ expect(users.count).to be 5
21
+ end
22
+
23
+ it "does not return duplicates" do
24
+ expect(users.uniq.count).to be users.count
25
+ end
26
+ end
27
+
28
+ context "with invalid input" do
29
+ describe "with a negative number" do
30
+ it { expect { FakeFriend.gather(-1) }.to raise_error(ArgumentError) }
31
+ end
32
+ describe "with too high a number" do
33
+ it { expect { FakeFriend.gather(102) }.to raise_error(ArgumentError) }
34
+ end
35
+ end
36
+ end
37
+
38
+ describe "::find_by" do
39
+ context "with valid input (by id)" do
40
+ let(:user){ FakeFriend.find_by(id: 1) }
41
+
42
+ it "returns a FakeFriend" do
43
+ expect(user).to be_a FakeFriend
44
+ end
45
+
46
+ it "returns the correct FakeFriend" do
47
+ expect(user.name).to eq("Visual Idiot")
48
+ end
49
+ end
50
+
51
+ context "with valid input (by username)" do
52
+ let(:user){ FakeFriend.find_by(username: 'idiot') }
53
+
54
+ it "returns a FakeFriend" do
55
+ expect(user).to be_a FakeFriend
56
+ end
57
+
58
+ it "returns the correct FakeFriend" do
59
+ expect(user.name).to eq("Visual Idiot")
60
+ end
61
+ end
62
+
63
+ context "with invalid input" do
64
+ describe "with an invalid key" do
65
+ it { expect { FakeFriend.find_by(age: 50) }.to raise_error(ArgumentError) }
66
+ end
67
+ describe "with an invalid id" do
68
+ it { expect { FakeFriend.find_by(id: 102) }.to raise_error(ArgumentError) }
69
+ end
70
+ describe "with an invalid username" do
71
+ it { expect { FakeFriend.find_by(username: "invalid_username") }.to raise_error(ArgumentError) }
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,20 @@
1
+ require 'fake_friends'
2
+ require 'rspec/expectations'
3
+
4
+ RSpec.configure do |config|
5
+
6
+ config.expect_with :rspec do |c|
7
+ c.syntax = :expect
8
+ end
9
+
10
+ end
11
+
12
+ RSpec::Matchers.define :be_composed_of do |expected_type|
13
+ match do |actual|
14
+ actual.all?{|u| u.is_a? expected_type} == true
15
+ end
16
+
17
+ failure_message_for_should do |actual|
18
+ "expected that #{actual.class} would be composed of #{expected_type}s"
19
+ end
20
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fake_friends
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Romer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-26 00:00:00.000000000 Z
11
+ date: 2013-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: twitter
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.8.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -60,6 +74,7 @@ extensions: []
60
74
  extra_rdoc_files: []
61
75
  files:
62
76
  - .gitignore
77
+ - .rspec
63
78
  - Gemfile
64
79
  - LICENSE.txt
65
80
  - README.md
@@ -70,6 +85,8 @@ files:
70
85
  - lib/fake_friends.rb
71
86
  - lib/fake_friends/users.yml
72
87
  - lib/fake_friends/version.rb
88
+ - spec/fake_friends_spec.rb
89
+ - spec/spec_helper.rb
73
90
  homepage: http://github.com/jmromer/FakeFriends
74
91
  licenses:
75
92
  - MIT
@@ -95,4 +112,6 @@ signing_key:
95
112
  specification_version: 4
96
113
  summary: Generates fake users with consistent attributes, up to 30 from local dictionary,
97
114
  up to 100 pulling fresh data using the Twitter gem
98
- test_files: []
115
+ test_files:
116
+ - spec/fake_friends_spec.rb
117
+ - spec/spec_helper.rb