yt-andrewroth 0.25.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. data/.gitignore +27 -0
  2. data/.rspec +3 -0
  3. data/.travis.yml +9 -0
  4. data/.yardopts +5 -0
  5. data/CHANGELOG.md +732 -0
  6. data/Gemfile +4 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.md +489 -0
  9. data/Rakefile +11 -0
  10. data/YOUTUBE_IT.md +835 -0
  11. data/bin/yt +30 -0
  12. data/gemfiles/Gemfile.activesupport-3.x +4 -0
  13. data/gemfiles/Gemfile.activesupport-4.x +4 -0
  14. data/lib/yt.rb +21 -0
  15. data/lib/yt/actions/base.rb +32 -0
  16. data/lib/yt/actions/delete.rb +19 -0
  17. data/lib/yt/actions/delete_all.rb +32 -0
  18. data/lib/yt/actions/insert.rb +42 -0
  19. data/lib/yt/actions/list.rb +139 -0
  20. data/lib/yt/actions/modify.rb +37 -0
  21. data/lib/yt/actions/patch.rb +19 -0
  22. data/lib/yt/actions/update.rb +19 -0
  23. data/lib/yt/associations/has_attribute.rb +55 -0
  24. data/lib/yt/associations/has_authentication.rb +214 -0
  25. data/lib/yt/associations/has_many.rb +22 -0
  26. data/lib/yt/associations/has_one.rb +22 -0
  27. data/lib/yt/associations/has_reports.rb +320 -0
  28. data/lib/yt/collections/advertising_options_sets.rb +34 -0
  29. data/lib/yt/collections/annotations.rb +62 -0
  30. data/lib/yt/collections/assets.rb +58 -0
  31. data/lib/yt/collections/authentications.rb +47 -0
  32. data/lib/yt/collections/base.rb +62 -0
  33. data/lib/yt/collections/channels.rb +31 -0
  34. data/lib/yt/collections/claim_histories.rb +34 -0
  35. data/lib/yt/collections/claims.rb +56 -0
  36. data/lib/yt/collections/content_details.rb +30 -0
  37. data/lib/yt/collections/content_owner_details.rb +34 -0
  38. data/lib/yt/collections/content_owners.rb +32 -0
  39. data/lib/yt/collections/device_flows.rb +23 -0
  40. data/lib/yt/collections/file_details.rb +30 -0
  41. data/lib/yt/collections/ids.rb +27 -0
  42. data/lib/yt/collections/live_streaming_details.rb +30 -0
  43. data/lib/yt/collections/ownerships.rb +34 -0
  44. data/lib/yt/collections/partnered_channels.rb +28 -0
  45. data/lib/yt/collections/players.rb +30 -0
  46. data/lib/yt/collections/playlist_items.rb +53 -0
  47. data/lib/yt/collections/playlists.rb +28 -0
  48. data/lib/yt/collections/policies.rb +28 -0
  49. data/lib/yt/collections/ratings.rb +23 -0
  50. data/lib/yt/collections/references.rb +46 -0
  51. data/lib/yt/collections/related_playlists.rb +43 -0
  52. data/lib/yt/collections/reports.rb +161 -0
  53. data/lib/yt/collections/resources.rb +57 -0
  54. data/lib/yt/collections/resumable_sessions.rb +51 -0
  55. data/lib/yt/collections/snippets.rb +27 -0
  56. data/lib/yt/collections/statistics_sets.rb +30 -0
  57. data/lib/yt/collections/statuses.rb +27 -0
  58. data/lib/yt/collections/subscribed_channels.rb +46 -0
  59. data/lib/yt/collections/subscribers.rb +33 -0
  60. data/lib/yt/collections/subscriptions.rb +50 -0
  61. data/lib/yt/collections/user_infos.rb +36 -0
  62. data/lib/yt/collections/video_categories.rb +35 -0
  63. data/lib/yt/collections/videos.rb +137 -0
  64. data/lib/yt/config.rb +54 -0
  65. data/lib/yt/errors/forbidden.rb +13 -0
  66. data/lib/yt/errors/missing_auth.rb +81 -0
  67. data/lib/yt/errors/no_items.rb +13 -0
  68. data/lib/yt/errors/request_error.rb +74 -0
  69. data/lib/yt/errors/server_error.rb +13 -0
  70. data/lib/yt/errors/unauthorized.rb +50 -0
  71. data/lib/yt/models/account.rb +216 -0
  72. data/lib/yt/models/advertising_options_set.rb +38 -0
  73. data/lib/yt/models/annotation.rb +132 -0
  74. data/lib/yt/models/asset.rb +111 -0
  75. data/lib/yt/models/asset_metadata.rb +38 -0
  76. data/lib/yt/models/asset_snippet.rb +46 -0
  77. data/lib/yt/models/authentication.rb +83 -0
  78. data/lib/yt/models/base.rb +32 -0
  79. data/lib/yt/models/channel.rb +302 -0
  80. data/lib/yt/models/claim.rb +156 -0
  81. data/lib/yt/models/claim_event.rb +67 -0
  82. data/lib/yt/models/claim_history.rb +29 -0
  83. data/lib/yt/models/configuration.rb +70 -0
  84. data/lib/yt/models/content_detail.rb +65 -0
  85. data/lib/yt/models/content_owner.rb +48 -0
  86. data/lib/yt/models/content_owner_detail.rb +18 -0
  87. data/lib/yt/models/description.rb +58 -0
  88. data/lib/yt/models/device_flow.rb +16 -0
  89. data/lib/yt/models/file_detail.rb +21 -0
  90. data/lib/yt/models/id.rb +9 -0
  91. data/lib/yt/models/iterator.rb +16 -0
  92. data/lib/yt/models/live_streaming_detail.rb +23 -0
  93. data/lib/yt/models/match_policy.rb +34 -0
  94. data/lib/yt/models/ownership.rb +75 -0
  95. data/lib/yt/models/player.rb +18 -0
  96. data/lib/yt/models/playlist.rb +218 -0
  97. data/lib/yt/models/playlist_item.rb +112 -0
  98. data/lib/yt/models/policy.rb +36 -0
  99. data/lib/yt/models/policy_rule.rb +124 -0
  100. data/lib/yt/models/rating.rb +37 -0
  101. data/lib/yt/models/reference.rb +172 -0
  102. data/lib/yt/models/resource.rb +136 -0
  103. data/lib/yt/models/resumable_session.rb +52 -0
  104. data/lib/yt/models/right_owner.rb +58 -0
  105. data/lib/yt/models/snippet.rb +50 -0
  106. data/lib/yt/models/statistics_set.rb +26 -0
  107. data/lib/yt/models/status.rb +32 -0
  108. data/lib/yt/models/subscription.rb +38 -0
  109. data/lib/yt/models/timestamp.rb +13 -0
  110. data/lib/yt/models/url.rb +90 -0
  111. data/lib/yt/models/user_info.rb +26 -0
  112. data/lib/yt/models/video.rb +630 -0
  113. data/lib/yt/models/video_category.rb +12 -0
  114. data/lib/yt/request.rb +278 -0
  115. data/lib/yt/version.rb +3 -0
  116. data/spec/collections/claims_spec.rb +30 -0
  117. data/spec/collections/playlist_items_spec.rb +44 -0
  118. data/spec/collections/playlists_spec.rb +27 -0
  119. data/spec/collections/policies_spec.rb +30 -0
  120. data/spec/collections/references_spec.rb +30 -0
  121. data/spec/collections/reports_spec.rb +30 -0
  122. data/spec/collections/subscriptions_spec.rb +25 -0
  123. data/spec/collections/videos_spec.rb +43 -0
  124. data/spec/errors/forbidden_spec.rb +10 -0
  125. data/spec/errors/missing_auth_spec.rb +24 -0
  126. data/spec/errors/no_items_spec.rb +10 -0
  127. data/spec/errors/request_error_spec.rb +44 -0
  128. data/spec/errors/server_error_spec.rb +10 -0
  129. data/spec/errors/unauthorized_spec.rb +10 -0
  130. data/spec/models/account_spec.rb +138 -0
  131. data/spec/models/annotation_spec.rb +180 -0
  132. data/spec/models/asset_spec.rb +20 -0
  133. data/spec/models/channel_spec.rb +127 -0
  134. data/spec/models/claim_event_spec.rb +62 -0
  135. data/spec/models/claim_history_spec.rb +27 -0
  136. data/spec/models/claim_spec.rb +211 -0
  137. data/spec/models/configuration_spec.rb +44 -0
  138. data/spec/models/content_detail_spec.rb +45 -0
  139. data/spec/models/content_owner_detail_spec.rb +6 -0
  140. data/spec/models/description_spec.rb +94 -0
  141. data/spec/models/file_detail_spec.rb +13 -0
  142. data/spec/models/live_streaming_detail_spec.rb +6 -0
  143. data/spec/models/ownership_spec.rb +59 -0
  144. data/spec/models/player_spec.rb +13 -0
  145. data/spec/models/playlist_item_spec.rb +120 -0
  146. data/spec/models/playlist_spec.rb +138 -0
  147. data/spec/models/policy_rule_spec.rb +63 -0
  148. data/spec/models/policy_spec.rb +41 -0
  149. data/spec/models/rating_spec.rb +12 -0
  150. data/spec/models/reference_spec.rb +249 -0
  151. data/spec/models/request_spec.rb +163 -0
  152. data/spec/models/resource_spec.rb +57 -0
  153. data/spec/models/right_owner_spec.rb +71 -0
  154. data/spec/models/snippet_spec.rb +13 -0
  155. data/spec/models/statistics_set_spec.rb +13 -0
  156. data/spec/models/status_spec.rb +13 -0
  157. data/spec/models/subscription_spec.rb +30 -0
  158. data/spec/models/url_spec.rb +78 -0
  159. data/spec/models/video_category_spec.rb +21 -0
  160. data/spec/models/video_spec.rb +669 -0
  161. data/spec/requests/as_account/account_spec.rb +125 -0
  162. data/spec/requests/as_account/authentications_spec.rb +139 -0
  163. data/spec/requests/as_account/channel_spec.rb +259 -0
  164. data/spec/requests/as_account/channels_spec.rb +18 -0
  165. data/spec/requests/as_account/playlist_item_spec.rb +56 -0
  166. data/spec/requests/as_account/playlist_spec.rb +244 -0
  167. data/spec/requests/as_account/resource_spec.rb +18 -0
  168. data/spec/requests/as_account/thumbnail.jpg +0 -0
  169. data/spec/requests/as_account/video.mp4 +0 -0
  170. data/spec/requests/as_account/video_spec.rb +408 -0
  171. data/spec/requests/as_content_owner/account_spec.rb +25 -0
  172. data/spec/requests/as_content_owner/advertising_options_set_spec.rb +15 -0
  173. data/spec/requests/as_content_owner/asset_spec.rb +20 -0
  174. data/spec/requests/as_content_owner/channel_spec.rb +1934 -0
  175. data/spec/requests/as_content_owner/claim_history_spec.rb +20 -0
  176. data/spec/requests/as_content_owner/content_owner_spec.rb +241 -0
  177. data/spec/requests/as_content_owner/match_policy_spec.rb +17 -0
  178. data/spec/requests/as_content_owner/ownership_spec.rb +25 -0
  179. data/spec/requests/as_content_owner/playlist_spec.rb +782 -0
  180. data/spec/requests/as_content_owner/video_spec.rb +1239 -0
  181. data/spec/requests/as_server_app/channel_spec.rb +74 -0
  182. data/spec/requests/as_server_app/playlist_item_spec.rb +30 -0
  183. data/spec/requests/as_server_app/playlist_spec.rb +53 -0
  184. data/spec/requests/as_server_app/video_spec.rb +58 -0
  185. data/spec/requests/as_server_app/videos_spec.rb +40 -0
  186. data/spec/requests/unauthenticated/video_spec.rb +22 -0
  187. data/spec/spec_helper.rb +20 -0
  188. data/spec/support/fail_matcher.rb +15 -0
  189. data/spec/support/global_hooks.rb +48 -0
  190. data/yt.gemspec +32 -0
  191. metadata +416 -0
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/asset'
3
+
4
+ describe Yt::Asset do
5
+ subject(:asset) { Yt::Asset.new data: data }
6
+
7
+ describe '#id' do
8
+ context 'given fetching a asset returns an id' do
9
+ let(:data) { {"id"=>"A123456789012345"} }
10
+ it { expect(asset.id).to eq 'A123456789012345' }
11
+ end
12
+ end
13
+
14
+ describe '#type' do
15
+ context 'given fetching a asset returns an type' do
16
+ let(:data) { {"type"=>"web"} }
17
+ it { expect(asset.type).to eq 'web' }
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,127 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/channel'
3
+
4
+ describe Yt::Channel do
5
+ subject(:channel) { Yt::Channel.new attrs }
6
+
7
+ describe '#title' do
8
+ context 'given a snippet with a title' do
9
+ let(:attrs) { {snippet: {"title"=>"Fullscreen"}} }
10
+ it { expect(channel.title).to eq 'Fullscreen' }
11
+ end
12
+
13
+ context 'given a snippet without a title' do
14
+ let(:attrs) { {snippet: {}} }
15
+ it { expect(channel.title).to eq '' }
16
+ end
17
+ end
18
+
19
+ describe '#description' do
20
+ context 'given a snippet with a description' do
21
+ let(:attrs) { {snippet: {"description"=>"A cool channel."}} }
22
+ it { expect(channel.description).to eq 'A cool channel.' }
23
+ end
24
+
25
+ context 'given a snippet without a description' do
26
+ let(:attrs) { {snippet: {}} }
27
+ it { expect(channel.description).to eq '' }
28
+ end
29
+ end
30
+
31
+ describe '#thumbnail_url' do
32
+ context 'given a snippet with thumbnails' do
33
+ let(:attrs) { {snippet: {"thumbnails"=>{
34
+ "default"=>{"url"=> "http://example.com/88x88.jpg"},
35
+ "medium"=>{"url"=> "http://example.com/240x240.jpg"},
36
+ }}} }
37
+ it { expect(channel.thumbnail_url).to eq 'http://example.com/88x88.jpg' }
38
+ it { expect(channel.thumbnail_url 'default').to eq 'http://example.com/88x88.jpg' }
39
+ it { expect(channel.thumbnail_url :default).to eq 'http://example.com/88x88.jpg' }
40
+ it { expect(channel.thumbnail_url :medium).to eq 'http://example.com/240x240.jpg' }
41
+ it { expect(channel.thumbnail_url :high).to be_nil }
42
+ end
43
+
44
+ context 'given a snippet without thumbnails' do
45
+ let(:attrs) { {snippet: {}} }
46
+ it { expect(channel.thumbnail_url).to be_nil }
47
+ end
48
+ end
49
+
50
+ describe '#published_at' do
51
+ context 'given a snippet with a timestamp' do
52
+ let(:attrs) { {snippet: {"publishedAt"=>"2014-04-22T19:14:49.000Z"}} }
53
+ it { expect(channel.published_at.year).to be 2014 }
54
+ end
55
+ end
56
+
57
+ describe '#comment_count' do
58
+ context 'given a video with comments' do
59
+ let(:attrs) { {statistics: {"commentCount"=>"33"}} }
60
+ it { expect(channel.comment_count).to be 33 }
61
+ end
62
+ end
63
+
64
+ describe '#video_count' do
65
+ context 'given a video with videos' do
66
+ let(:attrs) { {statistics: {"videoCount"=>"42"}} }
67
+ it { expect(channel.video_count).to be 42 }
68
+ end
69
+ end
70
+
71
+ describe '#subscriber_count' do
72
+ context 'given a video with subscribers' do
73
+ let(:attrs) { {statistics: {"subscriberCount"=>"12"}} }
74
+ it { expect(channel.subscriber_count).to be 12 }
75
+ end
76
+ end
77
+
78
+ describe '#subscriber_count_visible?' do
79
+ context 'given a video with publicly visible subscribers' do
80
+ let(:attrs) { {statistics: {"hiddenSubscriberCount"=>false}} }
81
+ it { expect(channel).to be_subscriber_count_visible }
82
+ end
83
+
84
+ context 'given a video with hidden subscribers' do
85
+ let(:attrs) { {statistics: {"hiddenSubscriberCount"=>true}} }
86
+ it { expect(channel).not_to be_subscriber_count_visible }
87
+ end
88
+ end
89
+
90
+ describe '#content_owner' do
91
+ context 'given a content_owner_detail with a content owner' do
92
+ let(:attrs) { {content_owner_details: {"contentOwner"=>"FullScreen"}} }
93
+ it { expect(channel.content_owner).to eq 'FullScreen' }
94
+ end
95
+
96
+ context 'given a content_owner_detail without a content owner' do
97
+ let(:attrs) { {content_owner_details: {}} }
98
+ it { expect(channel.content_owner).to be_nil }
99
+ end
100
+ end
101
+
102
+ describe '#linked_at' do
103
+ context 'given a content_owner_detail with a timeLinked' do
104
+ let(:attrs) { {content_owner_details: {"timeLinked"=>"2014-04-22T19:14:49.000Z"}} }
105
+ it { expect(channel.linked_at.year).to be 2014 }
106
+ end
107
+
108
+ context 'given a content_owner_detail with a timeLinked' do
109
+ let(:attrs) { {content_owner_details: {}} }
110
+ it { expect(channel.linked_at).to be_nil }
111
+ end
112
+ end
113
+
114
+ describe '#snippet' do
115
+ context 'given fetching a channel returns a snippet' do
116
+ let(:attrs) { {snippet: {"title"=>"Fullscreen"}} }
117
+ it { expect(channel.snippet).to be_a Yt::Snippet }
118
+ end
119
+ end
120
+
121
+ describe '#status' do
122
+ context 'given fetching a channel returns a status' do
123
+ let(:attrs) { {status: {"privacyStatus"=>"public"}} }
124
+ it { expect(channel.status).to be_a Yt::Status }
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/claim_event'
3
+
4
+ describe Yt::ClaimEvent do
5
+ subject(:claim_event) { Yt::ClaimEvent.new data: data }
6
+
7
+ describe '#time' do
8
+ context 'given fetching a claim_event returns a time' do
9
+ let(:data) { {"time"=>"2015-04-08T21:52:13.000Z"} }
10
+ it { expect(claim_event.time).to be_a Time }
11
+ end
12
+ end
13
+
14
+ describe '#type' do
15
+ context 'given fetching a claim_event returns a type' do
16
+ let(:data) { {"type"=>"claim_create"} }
17
+ it { expect(claim_event.type).to eq 'claim_create' }
18
+ end
19
+ end
20
+
21
+ describe '#source_type' do
22
+ context 'given fetching a claim_event returns a source_type' do
23
+ let(:data) { {'source'=>{'type' => 'cms_user'}} }
24
+ it { expect(claim_event.source_type).to eq 'cms_user' }
25
+ end
26
+ end
27
+
28
+ describe '#source_content_owner_id' do
29
+ context 'given fetching a claim_event returns a source_content_owner_id' do
30
+ let(:data) { {'source'=>{'contentOwnerId' => 'C1234'}} }
31
+ it { expect(claim_event.source_content_owner_id).to eq 'C1234' }
32
+ end
33
+ end
34
+
35
+ describe '#source_user_email' do
36
+ context 'given fetching a claim_event returns a source_user_email' do
37
+ let(:data) { {'source'=>{'userEmail' => 'email@fullscreen.net'}} }
38
+ it { expect(claim_event.source_user_email).to eq 'email@fullscreen.net' }
39
+ end
40
+ end
41
+
42
+ describe '#dispute_reason' do
43
+ context 'given fetching a claim_event returns a dispute_reason' do
44
+ let(:data) { {'typeDetails'=>{'disputeReason' => 'fair_use'}} }
45
+ it { expect(claim_event.dispute_reason).to eq 'fair_use' }
46
+ end
47
+ end
48
+
49
+ describe '#dispute_notes' do
50
+ context 'given fetching a claim_event returns dispute_notes' do
51
+ let(:data) { {'typeDetails'=>{'disputeNotes' => 'User entered notes here.'}} }
52
+ it { expect(claim_event.dispute_notes).to eq 'User entered notes here.' }
53
+ end
54
+ end
55
+
56
+ describe '#update_status' do
57
+ context 'given fetching a claim_event returns an update_status' do
58
+ let(:data) { {'typeDetails'=>{'updateStatus' => 'active'}} }
59
+ it { expect(claim_event.update_status).to eq 'active' }
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/claim_history'
3
+
4
+ describe Yt::ClaimHistory do
5
+ subject(:claim_history) { Yt::ClaimHistory.new data: data }
6
+
7
+ describe '#id' do
8
+ context 'given fetching claim_history with an id' do
9
+ let(:data) { {"id"=>"acbd1234"}}
10
+ it { expect(claim_history.id).to eq "acbd1234" }
11
+ end
12
+ end
13
+
14
+ describe '#uploader_channel_id' do
15
+ context 'given fetching claim_history with an uploader_channel_id' do
16
+ let(:data) { {"uploaderChannelId"=>"C1234"}}
17
+ it { expect(claim_history.uploader_channel_id).to eq "C1234" }
18
+ end
19
+ end
20
+
21
+ describe '#events' do
22
+ context 'given fetching claim_history with associated events' do
23
+ let(:data) { {"event"=>[{"time"=>"2015-03-21T21:35:42.000Z"},{"time"=>"2015-03-21T21:35:42.000Z"}]} }
24
+ it { expect(claim_history.events.size).to eq 2 }
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,211 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/claim'
3
+
4
+ describe Yt::Claim do
5
+ subject(:claim) { Yt::Claim.new data: data }
6
+
7
+ describe '#id' do
8
+ context 'given fetching a claim returns an id' do
9
+ let(:data) { {"id"=>"aBcD1EfGHIk"} }
10
+ it { expect(claim.id).to eq 'aBcD1EfGHIk' }
11
+ end
12
+ end
13
+
14
+ describe '#asset_id' do
15
+ context 'given fetching a claim returns an assetId' do
16
+ let(:data) { {"assetId"=>"A123456789012601"} }
17
+ it { expect(claim.asset_id).to eq 'A123456789012601' }
18
+ end
19
+ end
20
+
21
+ describe '#video_id' do
22
+ context 'given fetching a claim returns an videoId' do
23
+ let(:data) { {"videoId"=>"MESycYJytkU"} }
24
+ it { expect(claim.video_id).to eq 'MESycYJytkU' }
25
+ end
26
+ end
27
+
28
+ describe '#status' do
29
+ context 'given fetching a claim returns a status' do
30
+ let(:data) { {"status"=>"active"} }
31
+ it { expect(claim.status).to eq 'active' }
32
+ end
33
+ end
34
+
35
+ describe '#active?' do
36
+ context 'given fetching a claim returns an active status' do
37
+ let(:data) { {"status"=>"active"} }
38
+ it { expect(claim).to be_active }
39
+ end
40
+
41
+ context 'given fetching a claim does not return an active status' do
42
+ let(:data) { {"status"=>"unknown"} }
43
+ it { expect(claim).not_to be_active }
44
+ end
45
+ end
46
+
47
+ describe '#appealed?' do
48
+ context 'given fetching a claim returns an appealed status' do
49
+ let(:data) { {"status"=>"appealed"} }
50
+ it { expect(claim).to be_appealed }
51
+ end
52
+
53
+ context 'given fetching a claim does not return an appealed status' do
54
+ let(:data) { {"status"=>"unknown"} }
55
+ it { expect(claim).not_to be_appealed }
56
+ end
57
+ end
58
+
59
+ describe '#disputed?' do
60
+ context 'given fetching a claim returns an disputed status' do
61
+ let(:data) { {"status"=>"disputed"} }
62
+ it { expect(claim).to be_disputed }
63
+ end
64
+
65
+ context 'given fetching a claim does not return an disputed status' do
66
+ let(:data) { {"status"=>"unknown"} }
67
+ it { expect(claim).not_to be_disputed }
68
+ end
69
+ end
70
+
71
+ describe '#inactive?' do
72
+ context 'given fetching a claim returns an inactive status' do
73
+ let(:data) { {"status"=>"inactive"} }
74
+ it { expect(claim).to be_inactive }
75
+ end
76
+
77
+ context 'given fetching a claim does not return an inactive status' do
78
+ let(:data) { {"status"=>"unknown"} }
79
+ it { expect(claim).not_to be_inactive }
80
+ end
81
+ end
82
+
83
+ describe '#pending?' do
84
+ context 'given fetching a claim returns an pending status' do
85
+ let(:data) { {"status"=>"pending"} }
86
+ it { expect(claim).to be_pending }
87
+ end
88
+
89
+ context 'given fetching a claim does not return an pending status' do
90
+ let(:data) { {"status"=>"unknown"} }
91
+ it { expect(claim).not_to be_pending }
92
+ end
93
+ end
94
+
95
+ describe '#potential?' do
96
+ context 'given fetching a claim returns an potential status' do
97
+ let(:data) { {"status"=>"potential"} }
98
+ it { expect(claim).to be_potential }
99
+ end
100
+
101
+ context 'given fetching a claim does not return an potential status' do
102
+ let(:data) { {"status"=>"unknown"} }
103
+ it { expect(claim).not_to be_potential }
104
+ end
105
+ end
106
+
107
+ describe '#takedown?' do
108
+ context 'given fetching a claim returns an takedown status' do
109
+ let(:data) { {"status"=>"takedown"} }
110
+ it { expect(claim).to be_takedown }
111
+ end
112
+
113
+ context 'given fetching a claim does not return an takedown status' do
114
+ let(:data) { {"status"=>"unknown"} }
115
+ it { expect(claim).not_to be_takedown }
116
+ end
117
+ end
118
+
119
+ describe '#has_unknown_status?' do
120
+ context 'given fetching a claim returns an unknown status' do
121
+ let(:data) { {"status"=>"unknown"} }
122
+ it { expect(claim).to have_unknown_status }
123
+ end
124
+
125
+ context 'given fetching a claim does not return an unknown status' do
126
+ let(:data) { {"status"=>"active"} }
127
+ it { expect(claim).not_to have_unknown_status }
128
+ end
129
+ end
130
+
131
+ describe '#content_type' do
132
+ context 'given fetching a claim returns a content type' do
133
+ let(:data) { {"contentType"=>"audio"} }
134
+ it { expect(claim.content_type).to eq 'audio' }
135
+ end
136
+ end
137
+
138
+ describe '#audio?' do
139
+ context 'given fetching a claim returns an audio content type' do
140
+ let(:data) { {"contentType"=>"audio"} }
141
+ it { expect(claim).to be_audio }
142
+ end
143
+
144
+ context 'given fetching a claim does not return an audio content type' do
145
+ let(:data) { {"contentType"=>"audiovisual"} }
146
+ it { expect(claim).not_to be_audio }
147
+ end
148
+ end
149
+
150
+ describe '#video?' do
151
+ context 'given fetching a claim returns an video content type' do
152
+ let(:data) { {"contentType"=>"video"} }
153
+ it { expect(claim).to be_video }
154
+ end
155
+
156
+ context 'given fetching a claim does not return an video content type' do
157
+ let(:data) { {"contentType"=>"audiovisual"} }
158
+ it { expect(claim).not_to be_video }
159
+ end
160
+ end
161
+
162
+ describe '#audiovisual?' do
163
+ context 'given fetching a claim returns an audiovisual content type' do
164
+ let(:data) { {"contentType"=>"audiovisual"} }
165
+ it { expect(claim).to be_audiovisual }
166
+ end
167
+
168
+ context 'given fetching a claim does not return an audiovisual content type' do
169
+ let(:data) { {"contentType"=>"audio"} }
170
+ it { expect(claim).not_to be_audiovisual }
171
+ end
172
+ end
173
+
174
+ describe '#created_at' do
175
+ context 'given fetching a claim returns a creation timestamp' do
176
+ let(:data) { {"timeCreated"=>"2014-04-22T19:14:49.000Z"} }
177
+ it { expect(claim.created_at.year).to be 2014 }
178
+ end
179
+ end
180
+
181
+ describe '#block_outside_ownership?' do
182
+ context 'given fetching a claim returns blockOutsideOwnership true' do
183
+ let(:data) { {"blockOutsideOwnership"=>true} }
184
+ it { expect(claim.block_outside_ownership?).to be true }
185
+ end
186
+
187
+ context 'given fetching a claim returns blockOutsideOwnership false' do
188
+ let(:data) { {"blockOutsideOwnership"=>false} }
189
+ it { expect(claim.block_outside_ownership?).to be false }
190
+ end
191
+ end
192
+
193
+ describe '#match_reference_id' do
194
+ context 'given fetching a claim returns matchInfo' do
195
+ let(:data) { {"matchInfo"=>{"referenceId"=>"0r3JDtcRLuQ"}} }
196
+ it { expect(claim.match_reference_id).to eq "0r3JDtcRLuQ" }
197
+ end
198
+ end
199
+
200
+ describe '#third_party?' do
201
+ context 'given fetching a claim returns thirdPartyClaim true' do
202
+ let(:data) { {"thirdPartyClaim"=>true} }
203
+ it { expect(claim.third_party?).to be true }
204
+ end
205
+
206
+ context 'given fetching a claim returns thirdPartyClaim true' do
207
+ let(:data) { {"thirdPartyClaim"=>false} }
208
+ it { expect(claim.third_party?).to be false }
209
+ end
210
+ end
211
+ end