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.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +6 -0
  6. data/Gemfile.lock +51 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +114 -0
  9. data/Rakefile +2 -0
  10. data/da_face.gemspec +27 -0
  11. data/lib/da_face/api/adapter.rb +42 -0
  12. data/lib/da_face/api/adapters/base.rb +59 -0
  13. data/lib/da_face/api/adapters/em_http_request_adapter.rb +8 -0
  14. data/lib/da_face/api/adapters/excon_adapter.rb +33 -0
  15. data/lib/da_face/api/core.rb +0 -0
  16. data/lib/da_face/api/push.rb +77 -0
  17. data/lib/da_face/api/push_log.rb +11 -0
  18. data/lib/da_face/api/push_log_entry.rb +15 -0
  19. data/lib/da_face/api/push_subscription.rb +141 -0
  20. data/lib/da_face/configuration.rb +11 -0
  21. data/lib/da_face/datasift/da_object.rb +35 -0
  22. data/lib/da_face/datasift/demographic.rb +12 -0
  23. data/lib/da_face/datasift/errors.rb +9 -0
  24. data/lib/da_face/datasift/interaction.rb +33 -0
  25. data/lib/da_face/datasift/language.rb +14 -0
  26. data/lib/da_face/datasift/link.rb +34 -0
  27. data/lib/da_face/datasift/links.rb +38 -0
  28. data/lib/da_face/datasift/parser.rb +35 -0
  29. data/lib/da_face/datasift/salience.rb +16 -0
  30. data/lib/da_face/datasift/twitter.rb +46 -0
  31. data/lib/da_face/datasift/twitter_delete_notification.rb +16 -0
  32. data/lib/da_face/datasift/twitter_user_status.rb +37 -0
  33. data/lib/da_face/errors.rb +7 -0
  34. data/lib/da_face/twitter/parser.rb +16 -0
  35. data/lib/da_face/twitter/tweet.rb +49 -0
  36. data/lib/da_face/twitter/user.rb +55 -0
  37. data/lib/da_face/utilities.rb +41 -0
  38. data/lib/da_face/version.rb +3 -0
  39. data/lib/da_face.rb +69 -0
  40. data/spec/da_face/api/adapter_spec.rb +58 -0
  41. data/spec/da_face/api/adapters/base_spec.rb +125 -0
  42. data/spec/da_face/api/push_log_spec.rb +34 -0
  43. data/spec/da_face/api/push_spec.rb +108 -0
  44. data/spec/da_face/api/push_subscription_spec.rb +220 -0
  45. data/spec/da_face/configuration_spec.rb +15 -0
  46. data/spec/da_face/datasift/da_object_spec.rb +191 -0
  47. data/spec/da_face/datasift/demographic_spec.rb +30 -0
  48. data/spec/da_face/datasift/interaction_spec.rb +93 -0
  49. data/spec/da_face/datasift/language_spec.rb +45 -0
  50. data/spec/da_face/datasift/link_spec.rb +80 -0
  51. data/spec/da_face/datasift/links_spec.rb +70 -0
  52. data/spec/da_face/datasift/parser_spec.rb +5 -0
  53. data/spec/da_face/datasift/salience_spec.rb +33 -0
  54. data/spec/da_face/datasift/twitter_delete_notification_spec.rb +45 -0
  55. data/spec/da_face/datasift/twitter_spec.rb +56 -0
  56. data/spec/da_face/datasift/twitter_user_status_spec.rb +36 -0
  57. data/spec/da_face/twitter/parser_spec.rb +16 -0
  58. data/spec/da_face/twitter/tweet_spec.rb +77 -0
  59. data/spec/da_face/twitter/user_spec.rb +116 -0
  60. data/spec/da_face/utilities_spec.rb +74 -0
  61. data/spec/da_face_spec.rb +120 -0
  62. data/spec/fixtures/api_responses/get_subscriptions.json +26 -0
  63. data/spec/fixtures/api_responses/log.json +126 -0
  64. data/spec/fixtures/api_responses/validate_success.json +4 -0
  65. data/spec/fixtures/demographic/simple.json +5 -0
  66. data/spec/fixtures/interaction/simple.json +28 -0
  67. data/spec/fixtures/interactions/collection.json +1 -0
  68. data/spec/fixtures/interactions/simple.json +102 -0
  69. data/spec/fixtures/language/simple.json +5 -0
  70. data/spec/fixtures/links/multiples.json +69 -0
  71. data/spec/fixtures/links/simple.json +65 -0
  72. data/spec/fixtures/links/simple_failing.json +65 -0
  73. data/spec/fixtures/notifications/delete.json +10 -0
  74. data/spec/fixtures/notifications/user_delete.json +16 -0
  75. data/spec/fixtures/notifications/user_protect.json +16 -0
  76. data/spec/fixtures/notifications/user_suspend.json +16 -0
  77. data/spec/fixtures/notifications/user_undelete.json +16 -0
  78. data/spec/fixtures/notifications/user_unprotect.json +16 -0
  79. data/spec/fixtures/notifications/user_unsuspend.json +16 -0
  80. data/spec/fixtures/salience/simple.json +5 -0
  81. data/spec/fixtures/twitter/retweet.json +70 -0
  82. data/spec/fixtures/twitter/simple.json +33 -0
  83. data/spec/integration/stress_spec.rb +16 -0
  84. data/spec/spec_helper.rb +23 -0
  85. data/spec/test_spec.rb +7 -0
  86. metadata +259 -0
@@ -0,0 +1,125 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaFace::Api::Adapters::Base do
4
+ before do
5
+ DaFace.configure do |config|
6
+ config.api_path_prefix = '/lolcat'
7
+ config.api_host = 'http://host.com'
8
+ config.user = 'lol'
9
+ config.api_key = 'cat'
10
+ end
11
+ end
12
+
13
+ it 'throws error if user is missing' do
14
+ DaFace.configuration.user = nil
15
+ expect(Proc.new{DaFace::Api::Adapters::Base.new}).to raise_error(DaFace::AdapterError)
16
+ end
17
+
18
+ it 'throws error if api_key is missing' do
19
+ DaFace.configuration.api_key = nil
20
+ expect(Proc.new{DaFace::Api::Adapters::Base.new}).to raise_error(DaFace::AdapterError)
21
+ end
22
+
23
+ describe '#default_headers' do
24
+ before do
25
+ @adapter = DaFace::Api::Adapters::Base.new
26
+ end
27
+
28
+ it 'constructs default header hash' do
29
+ headers = @adapter.default_headers
30
+
31
+ expect(headers.keys).to eq(['Authorization', 'Accept'])
32
+ expect(headers.values.compact.size).not_to eq(0)
33
+ end
34
+
35
+ it 'constructs post header hash' do
36
+ headers = @adapter.post_headers
37
+
38
+ expect(headers.keys).to eq(['Authorization', 'Accept', 'Content-Type'])
39
+ expect(headers.values.compact.size).not_to eq(0)
40
+ end
41
+
42
+ it 'constructs get header hash' do
43
+ headers = @adapter.get_headers
44
+
45
+ expect(headers.keys).to eq(['Authorization', 'Accept'])
46
+ expect(headers.values.compact.size).not_to eq(0)
47
+ end
48
+ end
49
+
50
+ describe '#host' do
51
+ before do
52
+ @adapter = DaFace::Api::Adapters::Base.new
53
+ end
54
+
55
+ it 'uses DaFace.configuration value' do
56
+ expect(@adapter.host).to eq(DaFace.configuration.api_host)
57
+ end
58
+ end
59
+
60
+ describe '#path_prefix' do
61
+ before do
62
+ @adapter = DaFace::Api::Adapters::Base.new
63
+ end
64
+
65
+ it 'uses DaFace.configuration value' do
66
+ expect(@adapter.path_prefix).to eq(DaFace.configuration.api_path_prefix)
67
+ end
68
+ end
69
+
70
+
71
+ describe '#user' do
72
+ before do
73
+ @adapter = DaFace::Api::Adapters::Base.new
74
+ end
75
+
76
+ it 'uses DaFace.configuration value' do
77
+ expect(@adapter.user).to eq(DaFace.configuration.user)
78
+ end
79
+ end
80
+
81
+
82
+ describe '#api_key' do
83
+ before do
84
+ @adapter = DaFace::Api::Adapters::Base.new
85
+ end
86
+
87
+ it 'uses DaFace.configuration value' do
88
+ expect(@adapter.api_key).to eq(DaFace.configuration.api_key)
89
+ end
90
+ end
91
+
92
+ describe '#api_path' do
93
+ before do
94
+ @adapter = DaFace::Api::Adapters::Base.new
95
+ end
96
+
97
+ it 'constructs base path for requests' do
98
+ expect(@adapter.api_path).to eq('http://host.com/lolcat')
99
+ end
100
+ end
101
+
102
+ describe '#api_auth_header' do
103
+ before do
104
+ @adapter = DaFace::Api::Adapters::Base.new
105
+ end
106
+
107
+ it 'constructs correct auth header' do
108
+ expect(@adapter.api_auth_header).to eq('lol:cat')
109
+ end
110
+ end
111
+
112
+ describe '#url_params' do
113
+ before do
114
+ @params = {:lol => 'lol', :cat => 'cat'}
115
+ @adapter = DaFace::Api::Adapters::Base.new
116
+ end
117
+
118
+ it 'parses params hash to uri params' do
119
+ expect(@adapter.url_params(@params)).to eq('?lol=lol&cat=cat')
120
+ end
121
+ end
122
+
123
+
124
+
125
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaFace::Api::PushLog do
4
+ before do
5
+ DaFace.configure do |config|
6
+ config.user = 'someone'
7
+ config.api_key = 'something'
8
+ end
9
+
10
+ fixture = json_fixture('api_responses/log.json')
11
+ # TODO Make this tool preetier (symbolize)
12
+ @log_data = DaFace::Api::Adapter.new.symbolize_keys(fixture.keys, fixture)
13
+ end
14
+ describe '#new' do
15
+ it 'creates a PushLog object' do
16
+ obj = DaFace::Api::PushLog.new @log_data
17
+
18
+ expect(obj.class).to eq(DaFace::Api::PushLog)
19
+ end
20
+ end
21
+
22
+ describe 'attributes' do
23
+ before do
24
+ @push_log = DaFace::Api::PushLog.new @log_data
25
+ end
26
+
27
+ it 'has required attributes' do
28
+ expect(@push_log.count).to eq(@log_data[:count])
29
+ expect(@push_log.entries.class).to eq(Array)
30
+ expect(@push_log.entries.size).not_to eq(0)
31
+ expect(@push_log.entries.map(&:class).uniq).to eq([DaFace::Api::PushLogEntry])
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,108 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaFace::Api::Push do
4
+ before do
5
+ DaFace.configure do |config|
6
+ config.api_path_prefix = '/lolcat'
7
+ config.api_host = 'http://host.com'
8
+ config.user = 'lol'
9
+ config.api_key = 'cat'
10
+ end
11
+ @adapter = DaFace::Api::Adapter.new
12
+ @excon_adapter = DaFace::Api::Adapters::ExconAdapter.new
13
+ @conn = Excon.new 'http://host.com/lolcat', :mock => true
14
+ allow(@excon_adapter).to receive(:connection).and_return(@conn)
15
+ allow(@adapter).to receive(:connection).and_return(@excon_adapter)
16
+ allow(DaFace::Api::Push).to receive(:connection).and_return(@adapter)
17
+ end
18
+
19
+ describe '.get' do
20
+ before do
21
+ Excon.stub({:path => '/push/get'},
22
+ {:body => json_fixture('api_responses/get_subscriptions.json').to_json, :status => 200})
23
+ end
24
+
25
+ it 'returns subscription list' do
26
+ data = DaFace::Api::Push.get
27
+ expect(data).not_to eq(nil)
28
+ expect(data.class).to eq(Hash)
29
+ end
30
+ end
31
+
32
+ describe '.log' do
33
+ before do
34
+ Excon.stub({:path => '/push/log?id=some_sub_id'},
35
+ {:body => json_fixture('api_responses/log.json').to_json, :status => 200})
36
+ end
37
+
38
+ it 'returns a log list' do
39
+ data = DaFace::Api::Push.log 'some_sub_id'
40
+ expect(data).not_to eq(nil)
41
+ expect(data[:log_entries].size).not_to eq(0)
42
+ end
43
+ end
44
+
45
+ describe '.stop' do
46
+ before do
47
+ Excon.stub({:path => '/push/stop'},
48
+ {:status => 200})
49
+ end
50
+
51
+ it 'returns true when stopping' do
52
+ data = DaFace::Api::Push.stop 'some_sub_id'
53
+ expect(data).not_to eq(nil)
54
+ expect(data).to eq(true)
55
+ end
56
+ end
57
+
58
+ describe '.pause' do
59
+ before do
60
+ Excon.stub({:path => '/push/pause'},
61
+ {:status => 200})
62
+ end
63
+
64
+ it 'returns true when pausing' do
65
+ data = DaFace::Api::Push.pause 'some_sub_id'
66
+ expect(data).not_to eq(nil)
67
+ expect(data).to eq(true)
68
+ end
69
+ end
70
+
71
+ describe '.resume' do
72
+ before do
73
+ Excon.stub({:path => '/push/resume'},
74
+ {:status => 200})
75
+ end
76
+
77
+ it 'returns true when resuming' do
78
+ data = DaFace::Api::Push.resume 'some_sub_id'
79
+ expect(data).not_to eq(nil)
80
+ expect(data).to eq(true)
81
+ end
82
+ end
83
+
84
+ describe '.validate' do
85
+ before do
86
+ Excon.stub({:path => '/push/validate'},
87
+ {:body => json_fixture('api_responses/validate_success.json').to_json, :status => 200})
88
+ end
89
+
90
+ it 'validates output_params' do
91
+ data = DaFace::Api::Push.validate :some_output => 'output'
92
+ expect(data).not_to eq(nil)
93
+ expect(data[:message]).to eq('Validated successfully')
94
+ end
95
+ end
96
+
97
+ describe '.create' do
98
+ before do
99
+ Excon.stub({:path => '/push/create'},
100
+ {:status => 200})
101
+ end
102
+
103
+ it 'creates a subscription in datasift' do
104
+ data = DaFace::Api::Push.create :some_sub => 'data'
105
+ expect(data).not_to eq(nil)
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,220 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaFace::Api::PushSubscription do
4
+ before do
5
+ @attrs = {
6
+ :id => "k3j452kl3j4h5kl23j45h2l34kjh5345",
7
+ :output_type => "http",
8
+ :name => "SomeName",
9
+ :created_at => 1412345259,
10
+ :user_id => 28949,
11
+ :hash => "1m2n3bm12n3b1n23bm1n2b3mn12b3m2n",
12
+ :hash_type => "stream",
13
+ :output_params => {
14
+ :max_size => 2097152,
15
+ :delivery_frequency => 0,
16
+ :url => "http =>//somewhere.com/data_receiver"
17
+ },
18
+ :status => "active",
19
+ :last_request => 1412597788,
20
+ :last_success => 1412597789,
21
+ :remaining_bytes => 100,
22
+ :lost_data => false,
23
+ :start => 1412345259,
24
+ :end => 1412347259
25
+ }
26
+ end
27
+
28
+ describe '#new' do
29
+ it 'creates a PushSubscription object' do
30
+ obj = DaFace::Api::PushSubscription.new @attrs
31
+
32
+ expect(obj.class).to eq(DaFace::Api::PushSubscription)
33
+ end
34
+
35
+ it 'creates enpty Pushsubscription' do
36
+ expect(Proc.new{DaFace::Api::PushSubscription.new}).not_to raise_error
37
+ end
38
+ end
39
+
40
+ describe 'attributes' do
41
+ before do
42
+ @subscription = DaFace::Api::PushSubscription.new @attrs
43
+ end
44
+
45
+ describe '#id' do
46
+ it 'is present' do
47
+ expect(@subscription.id).to eq(@attrs[:id])
48
+ end
49
+ end
50
+
51
+ describe '#name' do
52
+ it 'is present' do
53
+ expect(@subscription.name).to eq(@attrs[:name])
54
+ end
55
+ end
56
+
57
+ describe '#created_at' do
58
+ it 'is present' do
59
+ expect(@subscription.created_at).to eq(Time.at(@attrs[:created_at]))
60
+ end
61
+ end
62
+
63
+ describe '#user_id' do
64
+ it 'is present' do
65
+ expect(@subscription.hash).to eq(@attrs[:hash])
66
+ end
67
+ end
68
+
69
+ describe '#hash_type' do
70
+ it 'is present' do
71
+ expect(@subscription.hash_type).to eq(@attrs[:hash_type])
72
+ end
73
+ end
74
+
75
+ describe '#status' do
76
+ it 'is present' do
77
+ expect(@subscription.status).to eq(@attrs[:status])
78
+ end
79
+ end
80
+
81
+ describe '#last_request' do
82
+ it 'is present' do
83
+ expect(@subscription.last_request).to eq(Time.at(@attrs[:last_request]))
84
+ end
85
+ end
86
+
87
+ describe '#last_success' do
88
+ it 'is present' do
89
+ expect(@subscription.last_success).to eq(Time.at(@attrs[:last_success]))
90
+ end
91
+ end
92
+
93
+ describe '#remaining_bytes' do
94
+ it 'is present' do
95
+ expect(@subscription.remaining_bytes).to eq(@attrs[:remaining_bytes])
96
+ end
97
+ end
98
+
99
+ describe '#lost_data' do
100
+ it 'is present' do
101
+ expect(@subscription.lost_data).to eq(@attrs[:lost_data])
102
+ end
103
+ end
104
+
105
+ describe '#lost_data?' do
106
+ it 'returns same as #lost_data' do
107
+ expect(@subscription.lost_data?).to eq(@subscription.lost_data)
108
+ end
109
+ end
110
+
111
+ describe '#start' do
112
+ it 'is present' do
113
+ expect(@subscription.start).to eq(Time.at(@attrs[:start]))
114
+ end
115
+ end
116
+
117
+ describe '#end' do
118
+ it 'is present' do
119
+ expect(@subscription.end).to eq(Time.at(@attrs[:end]))
120
+ end
121
+ end
122
+
123
+ describe '#output_type' do
124
+ it 'is present' do
125
+ expect(@subscription.output_type).to eq(@attrs[:output_type])
126
+ end
127
+ end
128
+
129
+ describe '#output_params' do
130
+ it 'is present' do
131
+ expect(@subscription.output_params).to eq(@attrs[:output_params])
132
+ end
133
+ end
134
+ end
135
+
136
+ describe 'configs' do
137
+ before do
138
+ @attrs = {
139
+ :output_type => "http",
140
+ :name => "SomeName",
141
+ :hash => "l3k4j23k4jl23j42l3k4j2l3kj4k3j4l",
142
+ :output_params => {
143
+ :auth => {
144
+ :type => 'none'
145
+ },
146
+ :max_size => 2097152,
147
+ :delivery_frequency => 0,
148
+ :url => "http =>//someurl.com/someendpoint"
149
+ },
150
+ :start => 1412345259,
151
+ :end => 1412375259
152
+ }
153
+
154
+ @config = {
155
+ 'output_type' => 'http',
156
+ 'name' => 'SomeName',
157
+ 'hash' => 'l3k4j23k4jl23j42l3k4j2l3kj4k3j4l',
158
+ 'start' => 1412345259,
159
+ 'end' => 1412375259,
160
+ 'output_params.max_size' => 2097152,
161
+ 'output_params.delivery_frequency' => 0,
162
+ 'output_params.url' => "http =>//someurl.com/someendpoint",
163
+ 'output_params.auth.type' => 'none'
164
+ }
165
+
166
+ @output_params_config = {
167
+ 'output_params.max_size' => 2097152,
168
+ 'output_params.delivery_frequency' => 0,
169
+ 'output_params.url' => "http =>//someurl.com/someendpoint",
170
+ 'output_params.auth.type' => 'none'
171
+ }
172
+
173
+ @output_config = {
174
+ 'output_type' => 'http',
175
+ 'output_params.max_size' => 2097152,
176
+ 'output_params.delivery_frequency' => 0,
177
+ 'output_params.url' => "http =>//someurl.com/someendpoint",
178
+ 'output_params.auth.type' => 'none'
179
+ }
180
+
181
+
182
+ @subscription = DaFace::Api::PushSubscription.new @attrs
183
+ end
184
+
185
+ it 'generates config' do
186
+ expect(@subscription.generate_config).to eq(@config)
187
+ end
188
+
189
+ it 'generates output_params config' do
190
+ expect(@subscription.output_params_config).to eq(@output_params_config)
191
+ end
192
+
193
+ it 'generates output_config config' do
194
+ expect(@subscription.output_config).to eq(@output_config)
195
+ end
196
+
197
+ end
198
+
199
+ # describe '#validate' do
200
+ # before do
201
+ # @attrs = {
202
+ # :output_type => "http",
203
+ # :name => "SomeName",
204
+ # :hash => "fc79ca5fefdb54b72292db503d686257",
205
+ # :output_params => {
206
+ # :max_size => 2097152,
207
+ # :delivery_frequency => 0,
208
+ # :url => "http =>//someurl.com/someendpoint"
209
+ # },
210
+ # :start => 1412345259,
211
+ # :end => 1412375259
212
+ # }
213
+ # @subscription = DaFace::Api::PushSubscription.new @attrs
214
+ # end
215
+
216
+ # it 'validates against Datasift' do
217
+ # expect(@subscription.validate).to eq(true)
218
+ # end
219
+ # end
220
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaFace::Configuration do
4
+ describe '#new' do
5
+ it 'has the default values' do
6
+ config = DaFace::Configuration.new
7
+
8
+ expect(config.api_path_prefix).to eq('/v1')
9
+ expect(config.api_host).to eq('http://api.datasift.com')
10
+ expect(config.adapter_class).to eq(DaFace::Api::Adapters::ExconAdapter)
11
+ expect(config.user).to eq(nil)
12
+ expect(config.api_key).to eq(nil)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,191 @@
1
+ require 'spec_helper'
2
+
3
+ describe DaFace::Datasift::DaObject do
4
+ before do
5
+ @parser = DaFace::Datasift::Parser.new
6
+ fixture = json_fixture('interactions/simple.json')
7
+ @interaction_data = @parser.symbolize_keys(fixture.keys, fixture)
8
+ end
9
+
10
+ describe '#new' do
11
+ it 'creates a DaObject object' do
12
+ obj = DaFace::Datasift::DaObject.new @interaction_data
13
+
14
+ expect(obj.class).to eq(DaFace::Datasift::DaObject)
15
+ end
16
+
17
+ it 'creates empty DaObject' do
18
+ expect(Proc.new{DaFace::Datasift::DaObject.new}).not_to raise_error
19
+ end
20
+ end
21
+
22
+ describe 'attributes' do
23
+ before do
24
+ @da_object = DaFace::Datasift::DaObject.new @interaction_data
25
+ end
26
+
27
+ describe '#interaction' do
28
+ it 'is present' do
29
+ expect(@da_object.interaction).not_to eq(nil)
30
+ end
31
+ end
32
+
33
+ describe '#demographic' do
34
+ it 'is present' do
35
+ expect(@da_object.demographic).not_to eq(nil)
36
+ end
37
+ end
38
+
39
+ describe '#salience' do
40
+ it 'is present' do
41
+ expect(@da_object.salience).not_to eq(nil)
42
+ end
43
+ end
44
+
45
+ describe '#links' do
46
+ it 'is present' do
47
+ expect(@da_object.links).not_to eq(nil)
48
+ end
49
+ end
50
+
51
+ describe '#twitter' do
52
+ it 'is present' do
53
+ expect(@da_object.twitter).not_to eq(nil)
54
+ end
55
+ end
56
+
57
+ describe '#language' do
58
+ it 'is present' do
59
+ expect(@da_object.language).not_to eq(nil)
60
+ end
61
+ end
62
+
63
+ describe '#kind' do
64
+ it 'is present' do
65
+ expect(@da_object.kind).to eq(DaFace::Datasift::DaObject::TWITTER_INTERACTION)
66
+ end
67
+ end
68
+ end
69
+
70
+
71
+
72
+
73
+ context 'suspend message' do
74
+ before do
75
+ fixture = json_fixture('notifications/user_suspend.json')
76
+ @data = @parser.symbolize_keys(fixture.keys, fixture)
77
+ @da_object = DaFace::Datasift::DaObject.new @data
78
+ end
79
+
80
+ it 'creates a twitter user status message' do
81
+ expect(@da_object.twitter.class).to eq(DaFace::Datasift::TwitterUserStatus)
82
+ expect(@da_object.kind).to eq(DaFace::Datasift::DaObject::TWITTER_USER_NOTIFICATION)
83
+ end
84
+
85
+ it 'has proper status value' do
86
+ expect(@da_object.twitter.status).to eq(DaFace::Datasift::TwitterUserStatus::STATUS_SUSPEND)
87
+ end
88
+ end
89
+
90
+ context 'unsuspend message' do
91
+ before do
92
+ fixture = json_fixture('notifications/user_unsuspend.json')
93
+ @data = @parser.symbolize_keys(fixture.keys, fixture)
94
+ @da_object = DaFace::Datasift::DaObject.new @data
95
+ end
96
+
97
+ it 'creates a twitter user status message' do
98
+ expect(@da_object.twitter.class).to eq(DaFace::Datasift::TwitterUserStatus)
99
+ expect(@da_object.kind).to eq(DaFace::Datasift::DaObject::TWITTER_USER_NOTIFICATION)
100
+ end
101
+
102
+ it 'has proper status value' do
103
+ expect(@da_object.twitter.status).to eq(DaFace::Datasift::TwitterUserStatus::STATUS_UNSUSPEND)
104
+ end
105
+ end
106
+
107
+
108
+ context 'delete user message' do
109
+ before do
110
+ fixture = json_fixture('notifications/user_delete.json')
111
+ @data = @parser.symbolize_keys(fixture.keys, fixture)
112
+ @da_object = DaFace::Datasift::DaObject.new @data
113
+ end
114
+
115
+ it 'creates a twitter user status message' do
116
+ expect(@da_object.twitter.class).to eq(DaFace::Datasift::TwitterUserStatus)
117
+ expect(@da_object.kind).to eq(DaFace::Datasift::DaObject::TWITTER_USER_NOTIFICATION)
118
+ end
119
+
120
+ it 'has proper status value' do
121
+ expect(@da_object.twitter.status).to eq(DaFace::Datasift::TwitterUserStatus::STATUS_DELETE)
122
+ end
123
+ end
124
+
125
+ context 'undelete message' do
126
+ before do
127
+ fixture = json_fixture('notifications/user_undelete.json')
128
+ @data = @parser.symbolize_keys(fixture.keys, fixture)
129
+ @da_object = DaFace::Datasift::DaObject.new @data
130
+ end
131
+
132
+ it 'creates a twitter user status message' do
133
+ expect(@da_object.twitter.class).to eq(DaFace::Datasift::TwitterUserStatus)
134
+ expect(@da_object.kind).to eq(DaFace::Datasift::DaObject::TWITTER_USER_NOTIFICATION)
135
+ end
136
+
137
+ it 'has proper status value' do
138
+ expect(@da_object.twitter.status).to eq(DaFace::Datasift::TwitterUserStatus::STATUS_UNDELETE)
139
+ end
140
+ end
141
+
142
+ context 'protect message' do
143
+ before do
144
+ fixture = json_fixture('notifications/user_protect.json')
145
+ @data = @parser.symbolize_keys(fixture.keys, fixture)
146
+ @da_object = DaFace::Datasift::DaObject.new @data
147
+ end
148
+
149
+ it 'creates a twitter user status message' do
150
+ expect(@da_object.twitter.class).to eq(DaFace::Datasift::TwitterUserStatus)
151
+ expect(@da_object.kind).to eq(DaFace::Datasift::DaObject::TWITTER_USER_NOTIFICATION)
152
+ end
153
+
154
+ it 'has proper status value' do
155
+ expect(@da_object.twitter.status).to eq(DaFace::Datasift::TwitterUserStatus::STATUS_PROTECT)
156
+ end
157
+ end
158
+
159
+ context 'unprotect message' do
160
+ before do
161
+ fixture = json_fixture('notifications/user_unprotect.json')
162
+ @data = @parser.symbolize_keys(fixture.keys, fixture)
163
+ @da_object = DaFace::Datasift::DaObject.new @data
164
+ end
165
+
166
+ it 'creates a twitter user status message' do
167
+ expect(@da_object.twitter.class).to eq(DaFace::Datasift::TwitterUserStatus)
168
+ expect(@da_object.kind).to eq(DaFace::Datasift::DaObject::TWITTER_USER_NOTIFICATION)
169
+ end
170
+
171
+ it 'has proper status value' do
172
+ expect(@da_object.twitter.status).to eq(DaFace::Datasift::TwitterUserStatus::STATUS_UNPROTECT)
173
+ end
174
+ end
175
+
176
+
177
+
178
+ context 'delete message' do
179
+ before do
180
+ fixture = json_fixture('notifications/delete.json')
181
+ @data = @parser.symbolize_keys(fixture.keys, fixture)
182
+ @da_object = DaFace::Datasift::DaObject.new @data
183
+ end
184
+
185
+ it 'creates a twitter delete message' do
186
+ expect(@da_object.twitter.class).to eq(DaFace::Datasift::TwitterDeleteNotification)
187
+ expect(@da_object.kind).to eq(DaFace::Datasift::DaObject::TWITTER_DELETE_NOTIFICATION)
188
+ end
189
+ end
190
+
191
+ end