da_face 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +51 -0
- data/LICENSE.txt +22 -0
- data/README.md +114 -0
- data/Rakefile +2 -0
- data/da_face.gemspec +27 -0
- data/lib/da_face/api/adapter.rb +42 -0
- data/lib/da_face/api/adapters/base.rb +59 -0
- data/lib/da_face/api/adapters/em_http_request_adapter.rb +8 -0
- data/lib/da_face/api/adapters/excon_adapter.rb +33 -0
- data/lib/da_face/api/core.rb +0 -0
- data/lib/da_face/api/push.rb +77 -0
- data/lib/da_face/api/push_log.rb +11 -0
- data/lib/da_face/api/push_log_entry.rb +15 -0
- data/lib/da_face/api/push_subscription.rb +141 -0
- data/lib/da_face/configuration.rb +11 -0
- data/lib/da_face/datasift/da_object.rb +35 -0
- data/lib/da_face/datasift/demographic.rb +12 -0
- data/lib/da_face/datasift/errors.rb +9 -0
- data/lib/da_face/datasift/interaction.rb +33 -0
- data/lib/da_face/datasift/language.rb +14 -0
- data/lib/da_face/datasift/link.rb +34 -0
- data/lib/da_face/datasift/links.rb +38 -0
- data/lib/da_face/datasift/parser.rb +35 -0
- data/lib/da_face/datasift/salience.rb +16 -0
- data/lib/da_face/datasift/twitter.rb +46 -0
- data/lib/da_face/datasift/twitter_delete_notification.rb +16 -0
- data/lib/da_face/datasift/twitter_user_status.rb +37 -0
- data/lib/da_face/errors.rb +7 -0
- data/lib/da_face/twitter/parser.rb +16 -0
- data/lib/da_face/twitter/tweet.rb +49 -0
- data/lib/da_face/twitter/user.rb +55 -0
- data/lib/da_face/utilities.rb +41 -0
- data/lib/da_face/version.rb +3 -0
- data/lib/da_face.rb +69 -0
- data/spec/da_face/api/adapter_spec.rb +58 -0
- data/spec/da_face/api/adapters/base_spec.rb +125 -0
- data/spec/da_face/api/push_log_spec.rb +34 -0
- data/spec/da_face/api/push_spec.rb +108 -0
- data/spec/da_face/api/push_subscription_spec.rb +220 -0
- data/spec/da_face/configuration_spec.rb +15 -0
- data/spec/da_face/datasift/da_object_spec.rb +191 -0
- data/spec/da_face/datasift/demographic_spec.rb +30 -0
- data/spec/da_face/datasift/interaction_spec.rb +93 -0
- data/spec/da_face/datasift/language_spec.rb +45 -0
- data/spec/da_face/datasift/link_spec.rb +80 -0
- data/spec/da_face/datasift/links_spec.rb +70 -0
- data/spec/da_face/datasift/parser_spec.rb +5 -0
- data/spec/da_face/datasift/salience_spec.rb +33 -0
- data/spec/da_face/datasift/twitter_delete_notification_spec.rb +45 -0
- data/spec/da_face/datasift/twitter_spec.rb +56 -0
- data/spec/da_face/datasift/twitter_user_status_spec.rb +36 -0
- data/spec/da_face/twitter/parser_spec.rb +16 -0
- data/spec/da_face/twitter/tweet_spec.rb +77 -0
- data/spec/da_face/twitter/user_spec.rb +116 -0
- data/spec/da_face/utilities_spec.rb +74 -0
- data/spec/da_face_spec.rb +120 -0
- data/spec/fixtures/api_responses/get_subscriptions.json +26 -0
- data/spec/fixtures/api_responses/log.json +126 -0
- data/spec/fixtures/api_responses/validate_success.json +4 -0
- data/spec/fixtures/demographic/simple.json +5 -0
- data/spec/fixtures/interaction/simple.json +28 -0
- data/spec/fixtures/interactions/collection.json +1 -0
- data/spec/fixtures/interactions/simple.json +102 -0
- data/spec/fixtures/language/simple.json +5 -0
- data/spec/fixtures/links/multiples.json +69 -0
- data/spec/fixtures/links/simple.json +65 -0
- data/spec/fixtures/links/simple_failing.json +65 -0
- data/spec/fixtures/notifications/delete.json +10 -0
- data/spec/fixtures/notifications/user_delete.json +16 -0
- data/spec/fixtures/notifications/user_protect.json +16 -0
- data/spec/fixtures/notifications/user_suspend.json +16 -0
- data/spec/fixtures/notifications/user_undelete.json +16 -0
- data/spec/fixtures/notifications/user_unprotect.json +16 -0
- data/spec/fixtures/notifications/user_unsuspend.json +16 -0
- data/spec/fixtures/salience/simple.json +5 -0
- data/spec/fixtures/twitter/retweet.json +70 -0
- data/spec/fixtures/twitter/simple.json +33 -0
- data/spec/integration/stress_spec.rb +16 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/test_spec.rb +7 -0
- metadata +259 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DaFace::Datasift::Demographic do
|
|
4
|
+
describe '#new' do
|
|
5
|
+
before do
|
|
6
|
+
@data = json_fixture('demographic/simple.json')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'creates Demographic object' do
|
|
10
|
+
obj = DaFace::Datasift::Demographic.new @data
|
|
11
|
+
|
|
12
|
+
expect(obj.class).to eq(DaFace::Datasift::Demographic)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'creates empty Demographic' do
|
|
16
|
+
expect(Proc.new{DaFace::Datasift::Demographic.new}).not_to raise_error
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe 'attributes' do
|
|
21
|
+
before do
|
|
22
|
+
@data = json_fixture('demographic/simple.json')
|
|
23
|
+
@demographic = DaFace::Datasift::Demographic.new @data
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'has all attributes required' do
|
|
27
|
+
expect(@demographic.gender).to eq(@data['gender'])
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DaFace::Datasift::Interaction do
|
|
4
|
+
before do
|
|
5
|
+
@parser = DaFace::Datasift::Parser.new
|
|
6
|
+
fixture = json_fixture('interaction/simple.json')
|
|
7
|
+
@data = @parser.symbolize_keys(fixture.keys, fixture)
|
|
8
|
+
end
|
|
9
|
+
describe '#new' do
|
|
10
|
+
it 'creates Interaction object' do
|
|
11
|
+
obj = DaFace::Datasift::Interaction.new @data
|
|
12
|
+
|
|
13
|
+
expect(obj.class).to eq(DaFace::Datasift::Interaction)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'creates empty Interaction' do
|
|
17
|
+
expect(Proc.new{DaFace::Datasift::Interaction.new}).not_to raise_error
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe 'attributes' do
|
|
22
|
+
before do
|
|
23
|
+
@interaction = DaFace::Datasift::Interaction.new @data
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe '#author' do
|
|
27
|
+
it 'is present' do
|
|
28
|
+
expect(@interaction.author).to eq(@data[:author])
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe '#content' do
|
|
33
|
+
it 'is present' do
|
|
34
|
+
expect(@interaction.content).to eq(@data[:content])
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe '#created_at' do
|
|
39
|
+
it 'is present' do
|
|
40
|
+
expect(@interaction.created_at).to eq(Time.parse(@data[:created_at]))
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe '#id' do
|
|
45
|
+
it 'is present' do
|
|
46
|
+
expect(@interaction.id).to eq(@data[:id])
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe '#link' do
|
|
51
|
+
it 'is present' do
|
|
52
|
+
expect(@interaction.link).to eq(@data[:link])
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe '#received_at' do
|
|
57
|
+
it 'is present' do
|
|
58
|
+
expect(@interaction.received_at).to eq(Time.at(@data[:received_at]))
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe '#schema' do
|
|
63
|
+
it 'is present' do
|
|
64
|
+
expect(@interaction.schema).to eq(@data[:schema])
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe '#source' do
|
|
69
|
+
it 'is present' do
|
|
70
|
+
expect(@interaction.source).to eq(@data[:source])
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
describe '#type' do
|
|
75
|
+
it 'is present' do
|
|
76
|
+
expect(@interaction.type).to eq(@data[:type])
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe '#tags' do
|
|
81
|
+
it 'it is present' do
|
|
82
|
+
expect(@interaction.tags).to eq(@data[:tags])
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe '#tag_tree' do
|
|
87
|
+
it 'is present' do
|
|
88
|
+
expect(@interaction.tag_tree).to eq(@data[:tag_tree])
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DaFace::Datasift::Language do
|
|
4
|
+
before do
|
|
5
|
+
fixture = json_fixture('language/simple.json')
|
|
6
|
+
@parser = DaFace::Datasift::Parser.new
|
|
7
|
+
@data = @parser.symbolize_keys(fixture.keys, fixture)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe '#new' do
|
|
11
|
+
it 'creates Language object' do
|
|
12
|
+
obj = DaFace::Datasift::Language.new @data
|
|
13
|
+
|
|
14
|
+
expect(obj.class).to eq(DaFace::Datasift::Language)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'creates empty Language' do
|
|
18
|
+
expect(Proc.new{DaFace::Datasift::Language.new}).not_to raise_error
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe 'attributes' do
|
|
23
|
+
before do
|
|
24
|
+
@language = DaFace::Datasift::Language.new @data
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#confidence' do
|
|
28
|
+
it 'is present' do
|
|
29
|
+
expect(@language.confidence).to eq(@data[:confidence])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '#tag' do
|
|
34
|
+
it 'is present' do
|
|
35
|
+
expect(@language.tag).to eq(@data[:tag])
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '#tag_extended' do
|
|
40
|
+
it 'is present' do
|
|
41
|
+
expect(@language.tag_extended).to eq(@data[:tag_extended])
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DaFace::Datasift::Link do
|
|
4
|
+
before do
|
|
5
|
+
fixture = json_fixture('links/simple.json')
|
|
6
|
+
@parser = DaFace::Datasift::Parser.new
|
|
7
|
+
fixture = @parser.symbolize_keys(fixture.keys, fixture)
|
|
8
|
+
@single_link = DaFace::Datasift::Links.get_elements(fixture).first
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe '#new' do
|
|
12
|
+
it 'creates a Link object' do
|
|
13
|
+
obj = DaFace::Datasift::Link.new @single_link
|
|
14
|
+
|
|
15
|
+
expect(obj.class).to eq(DaFace::Datasift::Link)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'does not raise error if nothing is passed' do
|
|
19
|
+
expect(Proc.new{DaFace::Datasift::Link.new}).not_to raise_error
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe 'attributes' do
|
|
24
|
+
before do
|
|
25
|
+
@link = DaFace::Datasift::Link.new @single_link
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe '#code' do
|
|
29
|
+
it 'is present' do
|
|
30
|
+
expect(@link.code).to eq(@single_link[:code])
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe '#created_at' do
|
|
35
|
+
it 'is present' do
|
|
36
|
+
expect(@link.created_at).to eq(Time.parse(@single_link[:created_at]))
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe '#hops' do
|
|
41
|
+
it 'is present' do
|
|
42
|
+
expect(@link.hops.class).to eq(Array)
|
|
43
|
+
@link.hops.each do |hop|
|
|
44
|
+
expect(hop.kind_of?(URI)).to eq(true)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe '#meta' do
|
|
50
|
+
it 'is present' do
|
|
51
|
+
expect(@link.meta).to eq(@single_link[:meta])
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe '#normalized_url' do
|
|
56
|
+
it 'is present' do
|
|
57
|
+
expect(@link.normalized_url).to eq(URI(@single_link[:normalized_url]))
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe '#retweet_count' do
|
|
62
|
+
it 'is present' do
|
|
63
|
+
expect(@link.retweet_count).to eq(@single_link[:retweet_count])
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe '#title' do
|
|
68
|
+
it 'is present' do
|
|
69
|
+
expect(@link.title).to eq(@single_link[:title])
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe 'url' do
|
|
74
|
+
it 'is present' do
|
|
75
|
+
expect(@link.url.kind_of?(URI)).to eq(true)
|
|
76
|
+
expect(@link.url).to eq(URI(@single_link[:url]))
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DaFace::Datasift::Links do
|
|
4
|
+
describe '#new' do
|
|
5
|
+
before do
|
|
6
|
+
@data = json_fixture('links/simple.json')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'returns array of Link objects' do
|
|
10
|
+
obj = DaFace::Datasift::Links.new @data
|
|
11
|
+
|
|
12
|
+
expect(obj.class).to eq(DaFace::Datasift::Links)
|
|
13
|
+
obj.each do |o|
|
|
14
|
+
expect(o.class).to eq(DaFace::Datasift::Link)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'cereates empty Links' do
|
|
19
|
+
expect(Proc.new{DaFace::Datasift::Links.new}).not_to raise_error
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#get_values' do
|
|
24
|
+
before do
|
|
25
|
+
@hash = {
|
|
26
|
+
'key_1' => [1,2],
|
|
27
|
+
'key_2' => {'key_3' => [3,4]},
|
|
28
|
+
'key_4' => {'key_5' => {'key_6' => [5,6]}}
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
it 'returns specific elements of arrays inside the hash' do
|
|
32
|
+
new_hash = DaFace::Datasift::Links.get_values(0, @hash.keys, @hash)
|
|
33
|
+
|
|
34
|
+
expect(new_hash['key_1'].class).not_to eq(Array)
|
|
35
|
+
expect(new_hash['key_1']).to eq(1)
|
|
36
|
+
expect(new_hash['key_2'].class).to eq(Hash)
|
|
37
|
+
expect(new_hash['key_2']['key_3']).to eq(3)
|
|
38
|
+
expect(new_hash['key_4']['key_5']['key_6']).to eq(5)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '#get_elements' do
|
|
43
|
+
context 'for single link' do
|
|
44
|
+
before do
|
|
45
|
+
@data = json_fixture('links/simple.json')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'gets first (0) elements of embebbed arrays' do
|
|
49
|
+
hashed_links = DaFace::Datasift::Links.get_elements @data
|
|
50
|
+
|
|
51
|
+
expect(hashed_links.class).to eq(Array)
|
|
52
|
+
expect(hashed_links.size).to eq(1)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
context 'for multiples links' do
|
|
58
|
+
before do
|
|
59
|
+
@data = json_fixture('links/multiples.json')
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'gets first (0) elements of embebbed arrays' do
|
|
63
|
+
hashed_links = DaFace::Datasift::Links.get_elements @data
|
|
64
|
+
|
|
65
|
+
expect(hashed_links.class).to eq(Array)
|
|
66
|
+
expect(hashed_links.size).to eq(2)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DaFace::Datasift::Salience do
|
|
4
|
+
before do
|
|
5
|
+
@parser = DaFace::Datasift::Parser.new
|
|
6
|
+
fixture = json_fixture('salience/simple.json')
|
|
7
|
+
@data = @parser.symbolize_keys(fixture.keys, fixture)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe '#new' do
|
|
11
|
+
|
|
12
|
+
it 'creates Salience object' do
|
|
13
|
+
obj = DaFace::Datasift::Salience.new @data
|
|
14
|
+
|
|
15
|
+
expect(obj.class).to eq(DaFace::Datasift::Salience)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe 'attributes' do
|
|
20
|
+
before do
|
|
21
|
+
@salience = DaFace::Datasift::Salience.new @data
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'has all required attributes' do
|
|
25
|
+
expect(@salience.content).to eq(@data[:content])
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'returns sentiment value' do
|
|
29
|
+
expect(@salience.sentiment).to eq(@data[:content][:sentiment])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DaFace::Datasift::TwitterDeleteNotification do
|
|
4
|
+
before do
|
|
5
|
+
@parser = DaFace::Datasift::Parser.new
|
|
6
|
+
fixture = json_fixture('notifications/delete.json')
|
|
7
|
+
@delete_notification = @parser.symbolize_keys(fixture.keys, fixture)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe '#new' do
|
|
11
|
+
it 'creates a Notification object' do
|
|
12
|
+
obj = DaFace::Datasift::TwitterDeleteNotification.new @delete_notification
|
|
13
|
+
|
|
14
|
+
expect(obj.class).to eq(DaFace::Datasift::TwitterDeleteNotification)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'raise error when nothing is passed' do
|
|
18
|
+
expect(Proc.new{DaFace::Datasift::TwitterDeleteNotification.new}).to raise_error(DaFace::Datasift::BadTwitterDeleteNotification)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe 'attributes' do
|
|
23
|
+
before do
|
|
24
|
+
@notification = DaFace::Datasift::TwitterDeleteNotification.new @delete_notification
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#interaction_id' do
|
|
28
|
+
it 'is present' do
|
|
29
|
+
expect(@notification.interaction_id).to eq(@delete_notification[:interaction][:id])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '#interaction_type' do
|
|
34
|
+
it 'is present' do
|
|
35
|
+
expect(@notification.interaction_type).to eq(@delete_notification[:interaction][:type])
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '#tweet_id' do
|
|
40
|
+
it 'is present' do
|
|
41
|
+
expect(@notification.tweet_id).to eq(@delete_notification[:twitter][:id])
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DaFace::Datasift::Twitter do
|
|
4
|
+
before do
|
|
5
|
+
@parser = DaFace::Datasift::Parser.new
|
|
6
|
+
end
|
|
7
|
+
describe '#new' do
|
|
8
|
+
before do
|
|
9
|
+
fixture = json_fixture('twitter/simple.json')
|
|
10
|
+
@data = @parser.symbolize_keys(fixture.keys, fixture)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'creates a Twitter object' do
|
|
14
|
+
obj = DaFace::Datasift::Twitter.new @data
|
|
15
|
+
|
|
16
|
+
expect(obj.class).to eq(DaFace::Datasift::Twitter)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe 'attributes' do
|
|
21
|
+
context 'normal tweet' do
|
|
22
|
+
before do
|
|
23
|
+
fixture = json_fixture('twitter/simple.json')
|
|
24
|
+
@data = @parser.symbolize_keys(fixture.keys, fixture)
|
|
25
|
+
@twitter = DaFace::Datasift::Twitter.new @data
|
|
26
|
+
end
|
|
27
|
+
it 'has tweet information' do
|
|
28
|
+
expect(@twitter.tweet).not_to eq(nil)
|
|
29
|
+
expect(@twitter.retweeted).to eq(nil)
|
|
30
|
+
expect(@twitter.tweet.id).to eq(@data[:id].to_i)
|
|
31
|
+
expect(@twitter.retweet?).to eq(false)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
context 'retweet' do
|
|
36
|
+
before do
|
|
37
|
+
fixture = json_fixture('twitter/retweet.json')
|
|
38
|
+
@data = @parser.symbolize_keys(fixture.keys, fixture)
|
|
39
|
+
@twitter = DaFace::Datasift::Twitter.new @data
|
|
40
|
+
end
|
|
41
|
+
it 'has tweet and retweet information' do
|
|
42
|
+
expect(@twitter.tweet).not_to eq(nil)
|
|
43
|
+
expect(@twitter.retweeted).not_to eq(nil)
|
|
44
|
+
expect(@twitter.tweet.id).to eq(@data[:retweet][:id].to_i)
|
|
45
|
+
expect(@twitter.retweeted.id).to eq(@data[:retweeted][:id].to_i)
|
|
46
|
+
expect(@twitter.retweeted.id).not_to eq(@twitter.tweet.id)
|
|
47
|
+
expect(@twitter.retweet?).to eq(true)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DaFace::Datasift::TwitterUserStatus do
|
|
4
|
+
before do
|
|
5
|
+
@parser = DaFace::Datasift::Parser.new
|
|
6
|
+
fixture = json_fixture('notifications/user_suspend.json')['twitter']
|
|
7
|
+
@user_suspended = @parser.symbolize_keys(fixture.keys, fixture)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe '#new' do
|
|
11
|
+
it 'creates a twitter user status notification' do
|
|
12
|
+
obj = DaFace::Datasift::TwitterUserStatus.new @user_suspended
|
|
13
|
+
|
|
14
|
+
expect(obj.class).to eq(DaFace::Datasift::TwitterUserStatus)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe 'attributes' do
|
|
19
|
+
before do
|
|
20
|
+
@status = DaFace::Datasift::TwitterUserStatus.new @user_suspended
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#user_id' do
|
|
24
|
+
it 'is present' do
|
|
25
|
+
expect(@status.user_id).to eq(@user_suspended[:user][:id])
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '#status' do
|
|
30
|
+
it 'is present' do
|
|
31
|
+
expect(@status.status).to eq(DaFace::Datasift::TwitterUserStatus::STATUS_SUSPEND)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DaFace::Twitter::Parser do
|
|
4
|
+
before do
|
|
5
|
+
@data = json_fixture('twitter/simple.json')
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe '#new' do
|
|
9
|
+
it 'creates a Tweet and User object' do
|
|
10
|
+
obj = DaFace::Twitter::Parser.parse @data, false
|
|
11
|
+
|
|
12
|
+
expect(obj.class).to eq(DaFace::Twitter::Tweet)
|
|
13
|
+
expect(obj.user.class).to eq(DaFace::Twitter::User)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe DaFace::Twitter::Tweet do
|
|
4
|
+
before do
|
|
5
|
+
@parser = DaFace::Datasift::Parser.new
|
|
6
|
+
fixture = json_fixture('twitter/simple.json')
|
|
7
|
+
@data = @parser.symbolize_keys(fixture.keys, fixture)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe '#new' do
|
|
11
|
+
it 'creates a Tweet object' do
|
|
12
|
+
obj = DaFace::Twitter::Tweet.new @data
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe 'attributes' do
|
|
17
|
+
before do
|
|
18
|
+
@tweet = DaFace::Twitter::Tweet.new @data
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe '#id' do
|
|
22
|
+
it 'is present' do
|
|
23
|
+
expect(@tweet.id).to eq(@data[:id].to_i)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#id_str' do
|
|
28
|
+
it 'is present' do
|
|
29
|
+
expect(@tweet.id_str).to eq(@tweet.id.to_s)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '#created_at' do
|
|
34
|
+
it 'is present' do
|
|
35
|
+
expect(@tweet.created_at.class).to eq(Time)
|
|
36
|
+
expect(@tweet.created_at).to eq(Time.parse(@data[:created_at]))
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
describe '#lang' do
|
|
41
|
+
it 'is present' do
|
|
42
|
+
expect(@tweet.lang).to eq(@data[:lang])
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '#text' do
|
|
47
|
+
it 'is present' do
|
|
48
|
+
expect(@tweet.text).to eq(@data[:text])
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe '#source' do
|
|
53
|
+
it 'is present' do
|
|
54
|
+
expect(@tweet.source).to eq(@data[:source])
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe '#links' do
|
|
59
|
+
it 'is present' do
|
|
60
|
+
expect(@tweet.links.class).to eq(Array)
|
|
61
|
+
expect(@tweet.links.first).to eq(URI(@data[:links].first))
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe '#retweet?' do
|
|
66
|
+
it 'is present' do
|
|
67
|
+
expect(@tweet.retweet?).to eq(false)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe '#retweet_count' do
|
|
72
|
+
it 'is present' do
|
|
73
|
+
expect(@tweet.retweet_count).to eq(0)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|