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,10 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Base do
4
+
5
+ describe '#is_a?' do
6
+ it 'should be subclass of Hashie::Mash' do
7
+ expect(Feedlr::Base.new(a: 1)).to be_a(Hashie::Mash)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,49 @@
1
+ require 'helper'
2
+ require 'logger'
3
+
4
+ describe Feedlr::Client do
5
+
6
+ describe '#sandbox' do
7
+ it 'should default to Feedlr.sandbox if not set' do
8
+ Feedlr.configure do |c|
9
+ c.sandbox = false
10
+ c.logger = nil
11
+ end
12
+ client = Feedlr::Client.new
13
+ expect(client.sandbox).to eq(Feedlr.sandbox)
14
+ end
15
+
16
+ it 'should have a value when set' do
17
+ client = Feedlr::Client.new(sandbox: true)
18
+ expect(client.sandbox).to eq(true)
19
+ end
20
+ end
21
+
22
+ describe '#oauth_access_token' do
23
+ it 'should default to Feedlr.oauth_access_token if not set' do
24
+ Feedlr.configure { |c| c.oauth_access_token = 'test' }
25
+ client = Feedlr::Client.new
26
+ expect(client.oauth_access_token).to eq(Feedlr.oauth_access_token)
27
+ end
28
+
29
+ it 'should be have a value when set' do
30
+ client = Feedlr::Client.new(oauth_access_token: 'new_test')
31
+ expect(client.oauth_access_token).to eq('new_test')
32
+ end
33
+ end
34
+
35
+ describe '#logger' do
36
+ it 'should default to Feedlr.logger if not set' do
37
+ Feedlr.configure { |c| c.logger = Logger.new(STDOUT) }
38
+ client = Feedlr::Client.new
39
+ expect(client.logger).to eq(Feedlr.logger)
40
+ end
41
+
42
+ it 'should be have a value when set' do
43
+ logger = Logger.new(STDOUT)
44
+ client = Feedlr::Client.new(logger: logger)
45
+ expect(client.logger).to eq(logger)
46
+ end
47
+ end
48
+
49
+ end
@@ -0,0 +1,21 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Collection do
4
+
5
+ describe '::new' do
6
+ it 'should have Feedlr::Base elements when the elements are hashes' do
7
+ collection = Feedlr::Collection.new([{ a: 1 }, { b: 2 }])
8
+ expect(collection.first).to be_a(Feedlr::Base)
9
+ end
10
+ it 'should have normal elements when the elements are not hashes' do
11
+ collection = Feedlr::Collection.new([1, { z: 5 }])
12
+ expect(collection.first).to be_a(Integer)
13
+ end
14
+ end
15
+
16
+ describe '#is_a?' do
17
+ it 'should be subclass of Array' do
18
+ expect(Feedlr::Collection.new([{ a: 1 }])).to be_an(Array)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,59 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Error do
4
+ let(:client) { Feedlr::Client.new(sandbox: true) }
5
+ let(:feed_id) { 'feed/http://feeds.engadget.com/weblogsinc/engadget' }
6
+ let(:error) { 'something wrong' }
7
+ describe '#message' do
8
+ it 'returns the error message' do
9
+ error = Feedlr::Error.new('something wrong')
10
+ expect(error.message).to eq('something wrong')
11
+ end
12
+ end
13
+
14
+ describe '#rate_limit' do
15
+ it 'returns a rate limit object' do
16
+ error = Feedlr::Error.new('execution expired')
17
+ expect(error.rate_limit).to be_a Feedlr::RateLimit
18
+ end
19
+ end
20
+
21
+ Feedlr::Error.errors.each do |status, exception|
22
+ context "when HTTP status is #{ status}" do
23
+ it "raises #{ exception}" do
24
+ stub_request(:post, 'http://sandbox.feedly.com/v3/feeds/.mget')
25
+ .to_return(status: status, body: '{}')
26
+ expect { client.feed(feed_id) }.to raise_error(exception)
27
+ end
28
+ end
29
+ end
30
+
31
+ describe '::parse_error' do
32
+ context 'when body is a hash and has errorMessage' do
33
+ it 'returns error status and body errorMessage' do
34
+ body = { 'errorMessage' => error }
35
+ status = '400'
36
+ result = Feedlr::Error.send(:parse_error, status, body)
37
+ expect(result).to eq("Error #{status} - #{body['errorMessage']}")
38
+ end
39
+ end
40
+ context 'when body is a hash and has no errorMessage' do
41
+ it 'returns error status and body errorMessage' do
42
+ body = { 'noErrorMessage' => error }
43
+ status = '400'
44
+ result = Feedlr::Error.send(:parse_error, status, body)
45
+ expect(result).to eq("Error #{status}")
46
+ end
47
+ end
48
+ context 'when body is a not hash' do
49
+ it 'returns error status and body errorMessage' do
50
+ body = error
51
+ status = '400'
52
+ result = Feedlr::Error.send(:parse_error, status, body)
53
+ expect(result).to eq("Error #{status} - #{body}")
54
+ end
55
+ end
56
+
57
+ end
58
+
59
+ end
@@ -0,0 +1,54 @@
1
+ require 'helper'
2
+ require 'logger'
3
+
4
+ describe Feedlr do
5
+ let(:logger) { Logger.new(STDOUT) }
6
+
7
+ after(:each) do
8
+ Feedlr.oauth_access_token = nil
9
+ Feedlr.sandbox = nil
10
+ Feedlr.logger = nil
11
+ end
12
+
13
+ describe '::sandbox' do
14
+ it 'should be in production mode if not set' do
15
+ expect(Feedlr.sandbox).to eq(false)
16
+ end
17
+
18
+ it 'should be in sandbox mode if set' do
19
+ Feedlr.configure { |c| c.sandbox = true }
20
+ expect(Feedlr.sandbox).to eq(true)
21
+ end
22
+ end
23
+
24
+ it 'should be able to set the oAuth access token,' \
25
+ 'sandbox and logger' do
26
+ Feedlr.oauth_access_token = 'oauth_access_token'
27
+ Feedlr.sandbox = true
28
+ Feedlr.logger = logger
29
+
30
+ expect(Feedlr.oauth_access_token).to eq('oauth_access_token')
31
+ expect(Feedlr.sandbox).to eq(true)
32
+ expect(Feedlr.logger).to eq(logger)
33
+ end
34
+
35
+ describe '::configure' do
36
+ it 'should be able to set the oAuth access token,' \
37
+ 'sandbox and logger via a configure block' do
38
+ Feedlr.configure do |config|
39
+ config.oauth_access_token = 'oauth_access_token'
40
+ config.sandbox = true
41
+ config.logger = logger
42
+ end
43
+
44
+ expect(Feedlr.oauth_access_token).to eq('oauth_access_token')
45
+ expect(Feedlr.sandbox).to eq(true)
46
+ expect(Feedlr.logger).to eq(logger)
47
+ end
48
+
49
+ it 'should return true' do
50
+ res = Feedlr.configure {}
51
+ expect(res).to be_true
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,59 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Gateway::Categories, vcr: { record: :new_episodes } do
4
+ let(:client) do
5
+ Feedlr::Client.new(sandbox: true,
6
+ oauth_access_token: access_token)
7
+ end
8
+
9
+ describe '#user_categories' do
10
+ it 'sends a get request' do
11
+ stub = stub_request(:get, 'http://sandbox.feedly.com/v3/categories')
12
+ client.user_categories
13
+ expect(stub).to have_been_requested
14
+ end
15
+
16
+ it 'resoponds with hashie object' do
17
+ subject = client.user_categories
18
+ expect(subject.size).to be >= 2
19
+ expect(subject.first.label).to eq('Design')
20
+ end
21
+ end
22
+
23
+ describe '#change_category_label' do
24
+ let(:category_id) do
25
+ 'user/96cc52b7-a17f-4ce0-9b38-de1b6f08f156/category/Kool'
26
+ end
27
+ let(:new_label) { 'testing' }
28
+ it 'sends a post request' do
29
+ stub = stub_request(:post, 'http://sandbox.feedly.com/v3/categories/'\
30
+ "#{CGI.escape(category_id)}")
31
+ .with(body: MultiJson.dump(label: new_label))
32
+ client.change_category_label(category_id, new_label)
33
+ expect(stub).to have_been_requested
34
+ end
35
+
36
+ it 'resoponds with hashie object' do
37
+ subject = client.change_category_label(category_id, new_label)
38
+ expect(subject).to be_a(Feedlr::Success)
39
+ end
40
+ end
41
+
42
+ describe '#delete_category' do
43
+ let(:category_id) do
44
+ 'user/96cc52b7-a17f-4ce0-9b38-de1b6f08f156/category/Tech'
45
+ end
46
+ it 'sends a delete request' do
47
+ stub = stub_request(:delete, 'http://sandbox.feedly.com/v3/categories/'\
48
+ "#{CGI.escape(category_id)}")
49
+ client.delete_category(category_id)
50
+ expect(stub).to have_been_requested
51
+ end
52
+
53
+ it 'resoponds with hashie object' do
54
+ subject = client.delete_category(category_id)
55
+ expect(subject).to be_a(Feedlr::Success)
56
+ end
57
+ end
58
+
59
+ end
@@ -0,0 +1,67 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Gateway::Entries, 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_entry' do
9
+ let(:entry_id) do
10
+ 'k3wM4lkt2uyzklIaZG/piLCFwWpRsuSz4luWQLHP0YY=_142814c6526:338b:2190d777'
11
+ end
12
+
13
+ it 'calls entries' do
14
+ allow(client).to receive(:user_entries).and_return([1])
15
+ expect(client).to receive(:user_entries).with([entry_id])
16
+ client.user_entry(entry_id)
17
+ end
18
+
19
+ end
20
+
21
+ describe '#user_entries' do
22
+ let(:entries_ids) do
23
+ ['k3wM4lkt2uyzklIaZG/piLCFwWpRsuSz4luWQLHP0YY=_142814c6526:338b:2190d777',
24
+ 'IUiZhV1EuO2ZMzIrc2Ak6NlhGjboZ+Yk0rJ8=_14605b9efb5:7a2b:aec60bc9']
25
+ end
26
+ let(:options) { { continuation: nil } }
27
+ it 'sends a post request' do
28
+ stub = stub_request(:post, 'http://sandbox.feedly.com/v3/entries/.mget')
29
+ .with(body: MultiJson.dump(continuation: options[:continuation],
30
+ ids: entries_ids))
31
+ client.user_entries(entries_ids)
32
+ expect(stub).to have_been_requested
33
+ end
34
+
35
+ it 'resoponds with hashie object' do
36
+ subject = client.user_entries(entries_ids)
37
+ expect(subject.size).to be >= 1
38
+ expect(subject.first.author).to eq('Caroline Williamson')
39
+ end
40
+ end
41
+
42
+ describe '#add_entry' do
43
+ let(:entry) do
44
+ { title: 'NBCs reviled sci-fi drama Heroes may get a second lease',
45
+ author: 'Nathan Ingraham',
46
+ content: { direction: 'ltr', content: '...html content user wants to' \
47
+ 'associate with this entry..' },
48
+ tags: [{ id: 'user/96cc52b7-a17f-4ce0-9b38-de1b6f08f156/tag/Mobile' }],
49
+ alternate: [{ type: 'text/html',
50
+ href: 'http://www.theverge.com/2013/4/17/4236096/nbc-' \
51
+ 'heroes-may-get-a-second-lease-on-life-on-xbox-live' }] }
52
+ end
53
+ it 'sends a post request' do
54
+ stub = stub_request(:post, 'http://sandbox.feedly.com/v3/entries')
55
+ .with(body: MultiJson.dump(entry))
56
+ .to_return(body: '{ }')
57
+ client.add_entry(entry)
58
+ expect(stub).to have_been_requested
59
+ end
60
+
61
+ it 'resoponds with hashie object' do
62
+ subject = client.add_entry(entry)
63
+ expect(subject).to be
64
+ end
65
+ end
66
+
67
+ end
@@ -0,0 +1,60 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Gateway::Evernote, 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 '#unlink_evernote' do
9
+ it 'sends a delete request' do
10
+ stub = stub_request(:delete, 'http://sandbox.feedly.com/v3/evernote/auth')
11
+
12
+ client.unlink_evernote
13
+ expect(stub).to have_been_requested
14
+ end
15
+
16
+ it 'resoponds with hashie object' do
17
+ subject = client.unlink_evernote
18
+ expect(subject).to be_a(Feedlr::Success)
19
+ end
20
+ end
21
+
22
+ describe '#evernote_notebooks' do
23
+ it 'sends a get request' do
24
+ stub = stub_request(:get,
25
+ 'http://sandbox.feedly.com/v3/evernote/notebooks')
26
+
27
+ client.evernote_notebooks
28
+ expect(stub).to have_been_requested
29
+ end
30
+
31
+ it 'resoponds with hashie object' do
32
+ subject = client.evernote_notebooks
33
+ expect(subject.notebooks.size).to be >= 1
34
+ end
35
+ end
36
+
37
+
38
+ describe '#add_to_evernote' do
39
+ let(:entry) do
40
+ { notebookName: 'feedly notebook', comment: 'user comment',
41
+ url: 'http://techcrunch.com/2014/03/05/evernote-adds-handwriting'\
42
+ '-to-its-android-app/',
43
+ notebookType: 'personal',
44
+ notebookGuid: 'bc1815a0-0a56-46aa-9dca-4c8a53a4eb42',
45
+ tags: %w(tag1 tag2) }
46
+ end
47
+ it 'sends a get request' do
48
+ stub = stub_request(:post, 'http://sandbox.feedly.com/v3/evernote/note')
49
+ .with(body: MultiJson.dump(entry))
50
+ client.add_to_evernote(entry)
51
+ expect(stub).to have_been_requested
52
+ end
53
+
54
+ it 'resoponds with hashie object' do
55
+ subject = client.add_to_evernote(entry)
56
+ expect(subject).to be_a(Feedlr::Success)
57
+ end
58
+ end
59
+
60
+ end
@@ -0,0 +1,36 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Gateway::Facebook, vcr: { record: :new_episodes } do
4
+ let(:client) do
5
+ Feedlr::Client.new(sandbox: true, oauth_access_token: access_token)
6
+ end
7
+ describe '#unlink_facebook' do
8
+
9
+ it 'sends a delete request' do
10
+ stub = stub_request(:delete, 'http://sandbox.feedly.com/v3/facebook/auth')
11
+
12
+ client.unlink_facebook
13
+ expect(stub).to have_been_requested
14
+ end
15
+
16
+ it 'resoponds with hashie object' do
17
+ subject = client.unlink_facebook
18
+ expect(subject).to be_a(Feedlr::Success)
19
+ end
20
+ end
21
+
22
+ describe '#facebook_suggestions' do
23
+ it 'sends a get request' do
24
+ stub = stub_request(:get, 'http://sandbox.feedly.com/v3/facebook/'\
25
+ 'suggestions')
26
+ client.facebook_suggestions
27
+ expect(stub).to have_been_requested
28
+ end
29
+
30
+ it 'resoponds with hashie object' do
31
+ subject = client.facebook_suggestions
32
+ expect(subject.size).to be >= 1
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,36 @@
1
+ require 'helper'
2
+
3
+ describe Feedlr::Gateway::Feeds, vcr: { record: :new_episodes } do
4
+ let(:client) { Feedlr::Client.new(sandbox: true) }
5
+
6
+ describe '#feed' do
7
+ let(:feed_id) { 'feed/http://feeds.engadget.com/weblogsinc/engadget' }
8
+
9
+ it 'calls feeds' do
10
+ allow(client).to receive(:feeds).and_return([1])
11
+ expect(client).to receive(:feeds).with([feed_id])
12
+ client.feed(feed_id)
13
+ end
14
+ end
15
+
16
+ describe '#feeds' do
17
+ let(:feeds_ids) do
18
+ ['feed/http://feeds.engadget.com/weblogsinc/engadget',
19
+ 'feed/http://www.yatzer.com/feed/index.php']
20
+ end
21
+
22
+ it 'sends a post request' do
23
+ stub = stub_request(:post, 'http://sandbox.feedly.com/v3/feeds/.mget')
24
+ .with(body: MultiJson.dump(feeds_ids))
25
+ client.feeds(feeds_ids)
26
+ expect(stub).to have_been_requested
27
+ end
28
+
29
+ it 'resoponds with hashie object' do
30
+ subject = client.feeds(feeds_ids)
31
+ expect(subject.size).to eq(2)
32
+ expect(subject.first.website).to be_instance_of String
33
+ end
34
+ end
35
+
36
+ end