feedlr 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +22 -0
  5. data/.yardopts +5 -0
  6. data/Gemfile +32 -0
  7. data/Guardfile +7 -0
  8. data/LICENSE.md +16 -0
  9. data/README.md +85 -0
  10. data/Rakefile +10 -0
  11. data/feedlr.gemspec +27 -0
  12. data/lib/feedlr.rb +34 -0
  13. data/lib/feedlr/base.rb +4 -0
  14. data/lib/feedlr/client.rb +60 -0
  15. data/lib/feedlr/collection.rb +15 -0
  16. data/lib/feedlr/error.rb +79 -0
  17. data/lib/feedlr/gateway/categories.rb +36 -0
  18. data/lib/feedlr/gateway/entries.rb +40 -0
  19. data/lib/feedlr/gateway/evernote.rb +37 -0
  20. data/lib/feedlr/gateway/facebook.rb +28 -0
  21. data/lib/feedlr/gateway/feeds.rb +26 -0
  22. data/lib/feedlr/gateway/markers.rb +195 -0
  23. data/lib/feedlr/gateway/microsoft.rb +30 -0
  24. data/lib/feedlr/gateway/mixes.rb +29 -0
  25. data/lib/feedlr/gateway/opml.rb +26 -0
  26. data/lib/feedlr/gateway/preferences.rb +25 -0
  27. data/lib/feedlr/gateway/profile.rb +25 -0
  28. data/lib/feedlr/gateway/search.rb +41 -0
  29. data/lib/feedlr/gateway/shorten.rb +17 -0
  30. data/lib/feedlr/gateway/streams.rb +42 -0
  31. data/lib/feedlr/gateway/subscriptions.rb +43 -0
  32. data/lib/feedlr/gateway/tags.rb +88 -0
  33. data/lib/feedlr/gateway/topics.rb +43 -0
  34. data/lib/feedlr/gateway/twitter.rb +29 -0
  35. data/lib/feedlr/mapper.rb +25 -0
  36. data/lib/feedlr/rate_limit.rb +21 -0
  37. data/lib/feedlr/request.rb +148 -0
  38. data/lib/feedlr/success.rb +5 -0
  39. data/lib/feedlr/version.rb +15 -0
  40. data/spec/cassettes/Feedlr_Gateway_Categories/_change_category_label/resoponds_with_hashie_object.yml +50 -0
  41. data/spec/cassettes/Feedlr_Gateway_Categories/_delete_category/resoponds_with_hashie_object.yml +50 -0
  42. data/spec/cassettes/Feedlr_Gateway_Categories/_user_categories/resoponds_with_hashie_object.yml +52 -0
  43. data/spec/cassettes/Feedlr_Gateway_Entries/_add_entry/resoponds_with_hashie_object.yml +52 -0
  44. data/spec/cassettes/Feedlr_Gateway_Entries/_user_entries/resoponds_with_hashie_object.yml +337 -0
  45. data/spec/cassettes/Feedlr_Gateway_Evernote/_add_to_evernote/resoponds_with_hashie_object.yml +50 -0
  46. data/spec/cassettes/Feedlr_Gateway_Evernote/_evernote_notebooks/resoponds_with_hashie_object.yml +51 -0
  47. data/spec/cassettes/Feedlr_Gateway_Evernote/_unlink_evernote/resoponds_with_hashie_object.yml +50 -0
  48. data/spec/cassettes/Feedlr_Gateway_Facebook/_facebook_suggestions/resoponds_with_hashie_object.yml +52 -0
  49. data/spec/cassettes/Feedlr_Gateway_Facebook/_unlink_facebook/resoponds_with_hashie_object.yml +50 -0
  50. data/spec/cassettes/Feedlr_Gateway_Feeds/_feeds/resoponds_with_hashie_object.yml +51 -0
  51. data/spec/cassettes/Feedlr_Gateway_Markers/_lastest_tagged_entries/resoponds_with_hashie_object.yml +52 -0
  52. data/spec/cassettes/Feedlr_Gateway_Markers/_mark_articles_as_read/resoponds_with_hashie_object.yml +50 -0
  53. data/spec/cassettes/Feedlr_Gateway_Markers/_mark_articles_as_unread/resoponds_with_hashie_object.yml +50 -0
  54. data/spec/cassettes/Feedlr_Gateway_Markers/_mark_categories_as_read/with_asOf_param/resoponds_with_hashie_object.yml +50 -0
  55. data/spec/cassettes/Feedlr_Gateway_Markers/_mark_categories_as_read/with_lastReadEntryId_param/resoponds_with_hashie_object.yml +50 -0
  56. data/spec/cassettes/Feedlr_Gateway_Markers/_mark_feeds_as_read/with_asOf_param/resoponds_with_hashie_object.yml +50 -0
  57. data/spec/cassettes/Feedlr_Gateway_Markers/_mark_feeds_as_read/with_lastReadEntryId_param/resoponds_with_hashie_object.yml +50 -0
  58. data/spec/cassettes/Feedlr_Gateway_Markers/_sync_read_counts/resoponds_with_hashie_object.yml +52 -0
  59. data/spec/cassettes/Feedlr_Gateway_Markers/_undo_mark_categories_as_read/resoponds_with_hashie_object.yml +50 -0
  60. data/spec/cassettes/Feedlr_Gateway_Markers/_undo_mark_feeds_as_read/resoponds_with_hashie_object.yml +50 -0
  61. data/spec/cassettes/Feedlr_Gateway_Markers/_user_unread_counts/resoponds_with_hashie_object.yml +52 -0
  62. data/spec/cassettes/Feedlr_Gateway_Microsoft/_add_to_onenote/resoponds_with_hashie_object.yml +52 -0
  63. data/spec/cassettes/Feedlr_Gateway_Microsoft/_unlink_microsoft/resoponds_with_hashie_object.yml +50 -0
  64. data/spec/cassettes/Feedlr_Gateway_Mixes/_stream_most_engaging/resoponds_with_hashie_object.yml +102 -0
  65. data/spec/cassettes/Feedlr_Gateway_Opml/_import_opml/resoponds_with_hashie_object.yml +63 -0
  66. data/spec/cassettes/Feedlr_Gateway_Opml/_user_opml/resoponds_with_hashie_object.yml +80 -0
  67. data/spec/cassettes/Feedlr_Gateway_Preferences/_preferences/resoponds_with_hashie_object.yml +52 -0
  68. data/spec/cassettes/Feedlr_Gateway_Preferences/_update_preferences/resoponds_with_hashie_object.yml +50 -0
  69. data/spec/cassettes/Feedlr_Gateway_Profile/_get_profile/resoponds_with_hashie_object.yml +54 -0
  70. data/spec/cassettes/Feedlr_Gateway_Profile/_profile/resoponds_with_hashie_object.yml +54 -0
  71. data/spec/cassettes/Feedlr_Gateway_Profile/_update_profile/resoponds_with_hashie_object.yml +54 -0
  72. data/spec/cassettes/Feedlr_Gateway_Search/_search_feeds/resoponds_with_hashie_object.yml +303 -0
  73. data/spec/cassettes/Feedlr_Gateway_Search/_search_stream/resoponds_with_hashie_object.yml +1941 -0
  74. data/spec/cassettes/Feedlr_Gateway_Shorten/_shorten/resoponds_with_hashie_object.yml +51 -0
  75. data/spec/cassettes/Feedlr_Gateway_Streams/_stream_entries_contents/resoponds_with_hashie_object.yml +1150 -0
  76. data/spec/cassettes/Feedlr_Gateway_Streams/_stream_entries_ids/resoponds_with_hashie_object.yml +51 -0
  77. data/spec/cassettes/Feedlr_Gateway_Subscriptions/_add_subscription/resoponds_with_hashie_object.yml +53 -0
  78. data/spec/cassettes/Feedlr_Gateway_Subscriptions/_create_subscription/resoponds_with_hashie_object.yml +51 -0
  79. data/spec/cassettes/Feedlr_Gateway_Subscriptions/_delete_subscription/resoponds_with_hashie_object.yml +50 -0
  80. data/spec/cassettes/Feedlr_Gateway_Subscriptions/_update_subscription/resoponds_with_hashie_object.yml +51 -0
  81. data/spec/cassettes/Feedlr_Gateway_Subscriptions/_user_subscriptions/resoponds_with_hashie_object.yml +57 -0
  82. data/spec/cassettes/Feedlr_Gateway_Tags/_change_tag_label/resoponds_with_hashie_object.yml +50 -0
  83. data/spec/cassettes/Feedlr_Gateway_Tags/_delete_tags/resoponds_with_hashie_object.yml +50 -0
  84. data/spec/cassettes/Feedlr_Gateway_Tags/_get_tags/resoponds_with_hashie_object.yml +50 -0
  85. data/spec/cassettes/Feedlr_Gateway_Tags/_tag_entries/resoponds_with_hashie_object.yml +50 -0
  86. data/spec/cassettes/Feedlr_Gateway_Tags/_untag_entries/resoponds_with_hashie_object.yml +50 -0
  87. data/spec/cassettes/Feedlr_Gateway_Tags/_user_tags/resoponds_with_hashie_object.yml +50 -0
  88. data/spec/cassettes/Feedlr_Gateway_Topics/_add_topic/resoponds_with_hashie_object.yml +50 -0
  89. data/spec/cassettes/Feedlr_Gateway_Topics/_delete_topic/resoponds_with_hashie_object.yml +50 -0
  90. data/spec/cassettes/Feedlr_Gateway_Topics/_update_topic/resoponds_with_hashie_object.yml +50 -0
  91. data/spec/cassettes/Feedlr_Gateway_Topics/_user_topics/resoponds_with_hashie_object.yml +50 -0
  92. data/spec/cassettes/Feedlr_Gateway_Twitter/_twitter_suggestions/resoponds_with_hashie_object.yml +50 -0
  93. data/spec/cassettes/Feedlr_Gateway_Twitter/_unlink_twitter/resoponds_with_hashie_object.yml +50 -0
  94. data/spec/feedly/base_spec.rb +10 -0
  95. data/spec/feedly/client_spec.rb +49 -0
  96. data/spec/feedly/collection_spec.rb +21 -0
  97. data/spec/feedly/error_spec.rb +59 -0
  98. data/spec/feedly/feedly_spec.rb +54 -0
  99. data/spec/feedly/gateway/categories_spec.rb +59 -0
  100. data/spec/feedly/gateway/entries_spec.rb +67 -0
  101. data/spec/feedly/gateway/evernote_spec.rb +60 -0
  102. data/spec/feedly/gateway/facebook_spec.rb +36 -0
  103. data/spec/feedly/gateway/feeds_spec.rb +36 -0
  104. data/spec/feedly/gateway/markers_spec.rb +295 -0
  105. data/spec/feedly/gateway/microsoft_spec.rb +40 -0
  106. data/spec/feedly/gateway/mixes_spec.rb +27 -0
  107. data/spec/feedly/gateway/opml_spec.rb +57 -0
  108. data/spec/feedly/gateway/preferences_spec.rb +41 -0
  109. data/spec/feedly/gateway/profile_spec.rb +40 -0
  110. data/spec/feedly/gateway/search_spec.rb +43 -0
  111. data/spec/feedly/gateway/shorten_spec.rb +27 -0
  112. data/spec/feedly/gateway/streams_spec.rb +44 -0
  113. data/spec/feedly/gateway/subscriptions_spec.rb +87 -0
  114. data/spec/feedly/gateway/tags_spec.rb +129 -0
  115. data/spec/feedly/gateway/topics_spec.rb +77 -0
  116. data/spec/feedly/gateway/twitter_spec.rb +37 -0
  117. data/spec/feedly/mapper_spec.rb +25 -0
  118. data/spec/feedly/rate_limit_spec.rb +41 -0
  119. data/spec/feedly/request_spec.rb +74 -0
  120. data/spec/feedly/success_spec.rb +7 -0
  121. data/spec/feedly/version_spec.rb +9 -0
  122. data/spec/helper.rb +52 -0
  123. metadata +319 -0
@@ -0,0 +1,40 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Gateway::Profile, vcr: { record: :new_episodes } do
4
+ let(:client) do
5
+ Feedlr::Client.new(sandbox: true, oauth_access_token: access_token)
6
+ end
7
+
8
+ describe '#profile' do
9
+
10
+ it 'sends a get request' do
11
+ stub = stub_request(:get, 'http://sandbox.feedly.com/v3/profile')
12
+
13
+ client.user_profile
14
+ expect(stub).to have_been_requested
15
+ end
16
+
17
+ it 'resoponds with hashie object' do
18
+ subject = client.user_profile
19
+ expect(subject.familyName).to eq('al Habache')
20
+ expect(subject.twitterConnected).to eq(false)
21
+ end
22
+ end
23
+
24
+ describe '#update_profile' do
25
+ let(:profile) { { gender: 'female', fullName: 'Best lady' } }
26
+ it 'sends a post request' do
27
+ stub = stub_request(:post, 'http://sandbox.feedly.com/v3/profile')
28
+ .with(body: MultiJson.dump(profile))
29
+ client.update_profile(profile)
30
+ expect(stub).to have_been_requested
31
+ end
32
+
33
+ it 'resoponds with hashie object' do
34
+ subject = client.update_profile(profile)
35
+ expect(subject.gender).to eq('female')
36
+ expect(subject.fullName).to eq('Best lady')
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,43 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Gateway::Search, vcr: { record: :new_episodes } do
4
+ let(:client) do
5
+ Feedlr::Client.new(sandbox: true, oauth_access_token: access_token)
6
+ end
7
+ let(:query) { 'technology' }
8
+ let(:options) { { n: '30' } }
9
+ describe '#search_feeds' do
10
+ it 'sends a get request' do
11
+ stub = stub_request(:get, 'http://sandbox.feedly.com/v3/search/feeds')
12
+ .with(query: { 'q' => query }.merge(options))
13
+ client.search_feeds(query, options)
14
+ expect(stub).to have_been_requested
15
+ end
16
+
17
+ it 'resoponds with hashie object' do
18
+ subject = client.search_feeds(query, options)
19
+ expect(subject.hint).to eq('Technology')
20
+ expect(subject.results.size).to be >= 5
21
+ end
22
+ end
23
+
24
+ describe '#search_stream' do
25
+ let(:stream) do
26
+ 'user/96cc52b7-a17f-4ce0-9b38-de1b6f08f156/category/Entreprenuership'
27
+ end
28
+
29
+ it 'sends a get request' do
30
+ stub = stub_request(:get, 'http://sandbox.feedly.com/v3/search/contents')
31
+ .with(query: { q: query, streamId: stream }.merge(options))
32
+
33
+ client.search_stream(stream, query, options)
34
+ expect(stub).to have_been_requested
35
+ end
36
+
37
+ it 'resoponds with hashie object' do
38
+ subject = client.search_stream(stream, query, options)
39
+ expect(subject.items.size).to be >= 5
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,27 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Gateway::Shorten, vcr: { record: :new_episodes } do
4
+ let(:client) do
5
+ Feedlr::Client.new(sandbox: true, oauth_access_token: access_token)
6
+ end
7
+
8
+ describe '#shorten' do
9
+ let(:entry_id) do
10
+ 'k3wM4lkt2uyzklIaZG/piLCFwWpRsuSz4luWQLHP0YY=_142814c6526:338b:2190d777'
11
+ end
12
+
13
+ it 'sends a get request' do
14
+ stub = stub_request(:get, 'http://sandbox.feedly.com/v3/shorten/entries/'\
15
+ "#{CGI.escape(entry_id)}")
16
+ client.shorten_entry(entry_id)
17
+ expect(stub).to have_been_requested
18
+ end
19
+
20
+ it 'resoponds with hashie object' do
21
+ subject = client.shorten_entry(entry_id)
22
+ expect(subject.entryId).to eq(entry_id)
23
+ expect(subject.via).to eq('Feedlr sandbox client')
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,44 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Gateway::Streams, vcr: { record: :new_episodes } do
4
+ let(:client) do
5
+ Feedlr::Client.new(sandbox: true, oauth_access_token: access_token)
6
+ end
7
+
8
+ let(:stream) do
9
+ 'user/96cc52b7-a17f-4ce0-9b38-de1b6f08f156/category/Entreprenuership'
10
+ end
11
+
12
+ let(:options) { { count: '30', unreadOnly: 'true' } }
13
+
14
+ describe '#stream_entries_ids' do
15
+ it 'sends a get request' do
16
+ stub = stub_request(:get, 'http://sandbox.feedly.com/v3/streams/'\
17
+ "#{CGI.escape(stream)}/ids")
18
+ .with(query: options)
19
+ client.stream_entries_ids(stream, options)
20
+ expect(stub).to have_been_requested
21
+ end
22
+
23
+ it 'resoponds with hashie object' do
24
+ subject = client.stream_entries_ids(stream, options)
25
+ expect(subject.ids.size).to be >= 5
26
+ end
27
+ end
28
+
29
+ describe '#stream_entries_contents' do
30
+ it 'sends a get request' do
31
+ stub = stub_request(:get, 'http://sandbox.feedly.com/v3/streams/'\
32
+ "#{CGI.escape(stream)}/contents").with(query: options)
33
+
34
+ client.stream_entries_contents(stream, options)
35
+ expect(stub).to have_been_requested
36
+ end
37
+
38
+ it 'resoponds with hashie object' do
39
+ subject = client.stream_entries_contents(stream, options)
40
+ expect(subject.items.size).to be >= 5
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,87 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Gateway::Subscriptions, vcr: { record: :new_episodes } do
4
+ let(:client) do
5
+ Feedlr::Client.new(sandbox: true, oauth_access_token: access_token)
6
+ end
7
+
8
+ describe '#user_subscriptions' do
9
+
10
+ it 'sends a get request' do
11
+ stub = stub_request(:get, 'http://sandbox.feedly.com/v3/subscriptions')
12
+ .to_return(body: '{ }')
13
+ client.user_subscriptions
14
+ expect(stub).to have_been_requested
15
+ end
16
+
17
+ it 'resoponds with hashie object' do
18
+ subject = client.user_subscriptions
19
+ expect(subject.size).to be > 2
20
+ expect(subject.first.title).to eq('TechCrunch')
21
+ end
22
+ end
23
+
24
+ describe '#add_subscription' do
25
+ let(:subscription) do
26
+ { id: 'feed/http://feeds.feedburner.com/design-milk',
27
+ title: 'Design Milk', categories: [
28
+ { id: 'user/96cc52b7-a17f-4ce0-9b38-\
29
+ de1b6f08f156/category/Design',
30
+ label: 'Design' },
31
+ { id: 'user/96cc52b7-a17f-4ce0-9b38-\
32
+ de1b6f08f156/category/Art',
33
+ label: 'Art' }] }
34
+ end
35
+ it 'sends a post request' do
36
+ stub = stub_request(:post, 'http://sandbox.feedly.com/v3/subscriptions')
37
+ .with(body: MultiJson.dump(subscription)).to_return(body: '{ }')
38
+ client.add_subscription(subscription)
39
+ expect(stub).to have_been_requested
40
+ end
41
+
42
+ it 'resoponds with hashie object' do
43
+ subject = client.add_subscription(subscription)
44
+ expect(subject).to be_a(Feedlr::Success)
45
+ end
46
+ end
47
+
48
+ describe '#update_subscription' do
49
+ let(:subscription) do
50
+ { id: 'feed/http://feeds.feedburner.com/design-milk',
51
+ title: 'Design Milk', categories: [
52
+ { id: 'user/96cc52b7-a17f-4ce0-9b38-\
53
+ de1b6f08f156/category/Design',
54
+ label: 'Design' },
55
+ { id: 'user/96cc52b7-a17f-4ce0-9b38-\
56
+ de1b6f08f156/category/Art',
57
+ label: 'Art' }] }
58
+ end
59
+ it 'sends a post request' do
60
+ stub = stub_request(:post, 'http://sandbox.feedly.com/v3/subscriptions')
61
+ .with(body: MultiJson.dump(subscription))
62
+ client.update_subscription(subscription)
63
+ expect(stub).to have_been_requested
64
+ end
65
+
66
+ it 'resoponds with hashie object' do
67
+ subject = client.update_subscription(subscription)
68
+ expect(subject).to be_a(Feedlr::Success)
69
+ end
70
+ end
71
+
72
+ describe '#delete_subscription' do
73
+ let(:subscription_id) { 'feed/http://css-tricks.com/feed/' }
74
+ it 'sends a delete request' do
75
+ stub = stub_request(:delete, 'http://sandbox.feedly.com/v3/'\
76
+ "subscriptions/#{CGI.escape(subscription_id)}")
77
+ client.delete_subscription(subscription_id)
78
+ expect(stub).to have_been_requested
79
+ end
80
+
81
+ it 'resoponds with hashie object' do
82
+ subject = client.delete_subscription(subscription_id)
83
+ expect(subject).to be_a(Feedlr::Success)
84
+ end
85
+ end
86
+
87
+ end
@@ -0,0 +1,129 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Gateway::Tags, vcr: { record: :new_episodes } do
4
+ let(:client) do
5
+ Feedlr::Client.new(sandbox: true, oauth_access_token: access_token)
6
+ end
7
+
8
+ let(:tags_ids) do
9
+ ['user/96cc52b7-a17f-4ce0-9b38-de1b6f08f156/tag/Amazon',
10
+ 'user/96cc52b7-a17f-4ce0-9b38-de1b6f08f156/tag/Mobile']
11
+ end
12
+
13
+ let(:tag_id) { tags_ids.first }
14
+
15
+ let(:entries_ids) do
16
+ ['k3wM4lkt2uyzklIaZG/piLCFwWpRsuSz4luWQLHP0YY=_142814c6526:338b:2190d777']
17
+ end
18
+
19
+ describe '#user_tags' do
20
+ it 'sends a get request' do
21
+ stub = stub_request(:get, 'http://sandbox.feedly.com/v3/tags')
22
+ .to_return(body: '{ }')
23
+ client.user_tags
24
+ expect(stub).to have_been_requested
25
+ end
26
+
27
+ it 'resoponds with hashie object' do
28
+ subject = client.user_tags
29
+ expect(subject.size).to be >= 2
30
+ expect(subject.first.label).to eq('Amazon')
31
+ end
32
+ end
33
+
34
+ describe '#tag_entry' do
35
+
36
+ it 'calls tag_entries' do
37
+ allow(client).to receive(:tag_entries)
38
+ expect(client).to receive(:tag_entries)
39
+ .with([entries_ids.first], tags_ids)
40
+ client.tag_entry(entries_ids.first, tags_ids)
41
+ end
42
+
43
+ end
44
+
45
+ describe '#tag_entries' do
46
+ it 'sends a put request' do
47
+ tags_query = tags_ids.map { |t| CGI.escape(t) }.join(',')
48
+ stub = stub_request(:put,
49
+ "http://sandbox.feedly.com/v3/tags/#{tags_query}")
50
+ .with(body: MultiJson.dump(entryIds: entries_ids))
51
+
52
+ client.tag_entries(entries_ids, tags_ids)
53
+ expect(stub).to have_been_requested
54
+ end
55
+
56
+ it 'resoponds with hashie object' do
57
+ subject = client.tag_entries(entries_ids, tags_ids)
58
+ expect(subject).to be_a(Feedlr::Success)
59
+ end
60
+ end
61
+
62
+ describe '#untag_entry' do
63
+ it 'calls untag_entries' do
64
+ allow(client).to receive(:untag_entries)
65
+ expect(client).to receive(:untag_entries)
66
+ .with([entries_ids.first], tags_ids)
67
+ client.untag_entry(entries_ids.first, tags_ids)
68
+ end
69
+
70
+ end
71
+
72
+ describe '#untag_entries' do
73
+
74
+ it 'sends a delete request' do
75
+ tags_query = tags_ids.map { |t| CGI.escape(t) }.join(',')
76
+ entries_query = entries_ids.map { |t| CGI.escape(t) }.join(',')
77
+ stub = stub_request(:delete, 'http://sandbox.feedly.com/v3/tags/'\
78
+ "#{tags_query}/#{entries_query}")
79
+ client.untag_entries(entries_ids, tags_ids)
80
+ expect(stub).to have_been_requested
81
+ end
82
+
83
+ it 'resoponds with hashie object' do
84
+ subject = client.untag_entries(entries_ids, tags_ids)
85
+ expect(subject).to be_a(Feedlr::Success)
86
+ end
87
+ end
88
+
89
+ describe '#change_tag_label' do
90
+ let(:new_label) { 'testing' }
91
+ it 'sends a post request' do
92
+ stub = stub_request(:post, 'http://sandbox.feedly.com/v3/tags/'\
93
+ "#{CGI.escape(tag_id)}").with(body: MultiJson.dump(label: new_label))
94
+
95
+ client.change_tag_label(tag_id, new_label)
96
+ expect(stub).to have_been_requested
97
+ end
98
+
99
+ it 'resoponds with hashie object' do
100
+ subject = client.change_tag_label(tag_id, new_label)
101
+ expect(subject).to be_a(Feedlr::Success)
102
+ end
103
+ end
104
+
105
+ describe '#delete_tag' do
106
+
107
+ it 'calls delete_tags' do
108
+ allow(client).to receive(:delete_tags)
109
+ expect(client).to receive(:delete_tags).with([tag_id])
110
+ client.delete_tag(tag_id)
111
+ end
112
+ end
113
+
114
+ describe '#delete_tags' do
115
+ it 'sends a delete request' do
116
+ tags_query = tags_ids.map { |t| CGI.escape(t) }.join(',')
117
+ stub = stub_request(:delete, 'http://sandbox.feedly.com/v3/tags/'\
118
+ "#{tags_query}").to_return(body: '{ }')
119
+ client.delete_tags(tags_ids)
120
+ expect(stub).to have_been_requested
121
+ end
122
+
123
+ it 'resoponds with hashie object' do
124
+ subject = client.delete_tags(tags_ids)
125
+ expect(subject).to be_a(Feedlr::Success)
126
+ end
127
+ end
128
+
129
+ end
@@ -0,0 +1,77 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Gateway::Topics, vcr: { record: :new_episodes } do
4
+ let(:client) do
5
+ Feedlr::Client.new(sandbox: true, oauth_access_token: access_token)
6
+ end
7
+
8
+ describe '#user_topics' do
9
+ it 'sends a get request' do
10
+ stub = stub_request(:get, 'http://sandbox.feedly.com/v3/topics')
11
+
12
+ client.user_topics
13
+ expect(stub).to have_been_requested
14
+ end
15
+
16
+ it 'resoponds with hashie object' do
17
+ subject = client.user_topics
18
+ expect(subject.size).to be >= 1
19
+ end
20
+ end
21
+
22
+ describe '#add_topic' do
23
+ let(:topic) do
24
+ { id: 'user/96cc52b7-a17f-4ce0-9b38-de1b6f08f156/topic/business',
25
+ interest: 'high' }
26
+ end
27
+ it 'sends a post request' do
28
+ stub = stub_request(:post, 'http://sandbox.feedly.com/v3/topics')
29
+ .with(body: MultiJson.dump(topic))
30
+ client.add_topic(topic)
31
+ expect(stub).to have_been_requested
32
+ end
33
+
34
+ it 'resoponds with hashie object' do
35
+ subject = client.add_topic(topic)
36
+ expect(subject).to be_a(Feedlr::Success)
37
+ end
38
+ end
39
+
40
+ describe '#update_topic' do
41
+ let(:topic) do
42
+ { id: 'user/96cc52b7-a17f-4ce0-9b38-de1b6f08f156/topic/business',
43
+ interest: 'medium' }
44
+ end
45
+ it 'sends a post request' do
46
+ stub = stub_request(:post, 'http://sandbox.feedly.com/v3/topics')
47
+ .with(body: MultiJson.dump(topic))
48
+ client.update_topic(topic)
49
+ expect(stub).to have_been_requested
50
+ end
51
+
52
+ it 'resoponds with hashie object' do
53
+ subject = client.update_topic(topic)
54
+ expect(subject).to be_a(Feedlr::Success)
55
+ end
56
+ end
57
+
58
+ describe '#delete_topic' do
59
+ let(:topic_id) do
60
+ 'user/96cc52b7-a17f-4ce0-9b38-de1b6f08f156/topic/business'
61
+ end
62
+ it 'sends a delete request' do
63
+ stub = stub_request(:delete,
64
+ 'http://sandbox.feedly.com/v3/topics/'\
65
+ "#{CGI.escape(topic_id)}")
66
+
67
+ client.delete_topic(topic_id)
68
+ expect(stub).to have_been_requested
69
+ end
70
+
71
+ it 'resoponds with hashie object' do
72
+ subject = client.delete_topic(topic_id)
73
+ expect(subject).to be_a(Feedlr::Success)
74
+ end
75
+ end
76
+
77
+ end