adn-reborn 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +8 -0
  4. data/CHANGELOG.md +34 -0
  5. data/Gemfile +8 -0
  6. data/Gemfile.lock +25 -0
  7. data/LICENSE +16 -0
  8. data/README.md +19 -0
  9. data/Rakefile +17 -0
  10. data/adn-reborn.gemspec +19 -0
  11. data/lib/adn-reborn/api/file.rb +36 -0
  12. data/lib/adn-reborn/api/filter.rb +10 -0
  13. data/lib/adn-reborn/api/message.rb +29 -0
  14. data/lib/adn-reborn/api/post.rb +51 -0
  15. data/lib/adn-reborn/api/response.rb +19 -0
  16. data/lib/adn-reborn/api/stream.rb +10 -0
  17. data/lib/adn-reborn/api/subscription.rb +11 -0
  18. data/lib/adn-reborn/api/token.rb +12 -0
  19. data/lib/adn-reborn/api/user.rb +19 -0
  20. data/lib/adn-reborn/api.rb +62 -0
  21. data/lib/adn-reborn/constants.rb +18 -0
  22. data/lib/adn-reborn/file.rb +62 -0
  23. data/lib/adn-reborn/message.rb +76 -0
  24. data/lib/adn-reborn/post.rb +76 -0
  25. data/lib/adn-reborn/recipes/broadcast_message_builder.rb +103 -0
  26. data/lib/adn-reborn/recipes.rb +5 -0
  27. data/lib/adn-reborn/user.rb +103 -0
  28. data/lib/adn-reborn/version.rb +9 -0
  29. data/lib/adn-reborn.rb +69 -0
  30. data/spec/adn-reborn/api/file_spec.rb +73 -0
  31. data/spec/adn-reborn/api/filter_spec.rb +9 -0
  32. data/spec/adn-reborn/api/message_spec.rb +73 -0
  33. data/spec/adn-reborn/api/post_spec.rb +147 -0
  34. data/spec/adn-reborn/api/response_spec.rb +13 -0
  35. data/spec/adn-reborn/api/stream_spec.rb +9 -0
  36. data/spec/adn-reborn/api/subscription_spec.rb +9 -0
  37. data/spec/adn-reborn/api/token_spec.rb +23 -0
  38. data/spec/adn-reborn/api/user_spec.rb +27 -0
  39. data/spec/adn-reborn/file_spec.rb +103 -0
  40. data/spec/adn-reborn/message_spec.rb +152 -0
  41. data/spec/adn-reborn/post_spec.rb +147 -0
  42. data/spec/adn-reborn/recipes/broadcast_message_builder_spec.rb +179 -0
  43. data/spec/adn-reborn/user_spec.rb +115 -0
  44. data/spec/adn-reborn_spec.rb +42 -0
  45. data/spec/fixtures/post.json +88 -0
  46. data/spec/fixtures/user.json +70 -0
  47. data/spec/spec_helper.rb +30 -0
  48. metadata +141 -0
@@ -0,0 +1,76 @@
1
+ # encoding: UTF-8
2
+
3
+ module ADNReborn
4
+ class Post
5
+ attr_accessor(
6
+ :id, :post_id, :text, :html, :source, :machine_only,
7
+ :reply_to, :thread_id, :canonical_url,
8
+ :num_replies, :num_reposts, :num_stars,
9
+ :annotations, :entities, :you_reposted,
10
+ :you_starred, :reposters, :starred_by
11
+ )
12
+
13
+ attr_writer :user, :created_at
14
+
15
+ def self.send_post(params)
16
+ result = ADNReborn::API::Post.create(params)
17
+ Post.new(result["data"])
18
+ end
19
+
20
+ def self.by_id(id)
21
+ result = ADNReborn::API::Post.by_id(id)
22
+ Post.new(result["data"])
23
+ end
24
+
25
+ def initialize(raw_post)
26
+ if raw_post.respond_to?(:each_pair)
27
+ set_values(raw_post)
28
+ post_id = id
29
+ else
30
+ post_id = raw_post
31
+ post_details = details
32
+ if post_details.has_key? "data"
33
+ set_values(post_details["data"])
34
+ end
35
+ end
36
+ end
37
+
38
+ def details
39
+ if id
40
+ value = self.instance_variables.map do |i|
41
+ [i.to_s.slice(1..-1), self.instance_variable_get(i)]
42
+ end
43
+ Hash[value]
44
+ else
45
+ ADNReborn::API::Post.by_id(post_id)
46
+ end
47
+ end
48
+
49
+ def created_at
50
+ DateTime.parse(@created_at)
51
+ end
52
+
53
+ def user
54
+ ADNReborn::User.new(@user)
55
+ end
56
+
57
+ def reply_to_post
58
+ result = ADNReborn::API::Post.by_id(reply_to)
59
+ ADNReborn.create_instance(result["data"], Post)
60
+ end
61
+
62
+ def replies(params = nil)
63
+ result = ADNReborn::API::Post.replies(id, params)
64
+ ADNReborn.create_collection(result["data"], Post)
65
+ end
66
+
67
+ def delete
68
+ result = ADNReborn::API::Post.delete(id)
69
+ ADNReborn.create_instance(result["data"], Post)
70
+ end
71
+
72
+ def set_values(values)
73
+ values.each_pair { |k, v| send("#{k}=", v) if respond_to?("#{k}=") }
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,103 @@
1
+ # encoding: UTF-8
2
+
3
+ module ADNReborn
4
+ module Recipes
5
+ class BroadcastMessageBuilder
6
+ attr_accessor :headline, :text, :read_more_link, :channel_id,
7
+ :parse_links, :parse_markdown_links, :photo, :attachment
8
+
9
+ def initialize(params = {})
10
+ if params.respond_to? :each_pair
11
+ params.each_pair do |k, v|
12
+ send("#{k}=", v) if respond_to?("#{k}=")
13
+ end
14
+ end
15
+
16
+ yield self if block_given?
17
+ end
18
+
19
+ def annotations
20
+ annotations = [
21
+ {
22
+ type: 'net.app.core.broadcast.message.metadata',
23
+ value: {
24
+ subject: self.headline
25
+ }
26
+ }
27
+ ]
28
+
29
+ if self.read_more_link
30
+ annotations << {
31
+ type: 'net.app.core.crosspost',
32
+ value: {
33
+ canonical_url: self.read_more_link
34
+ }
35
+ }
36
+ end
37
+
38
+ if self.photo
39
+ file = ADNReborn::File.upload_file(self.photo, {
40
+ type: 'net.app.adnrb.upload'
41
+ })
42
+
43
+
44
+ annotations << {
45
+ type: 'net.app.core.oembed',
46
+ value: {
47
+ "+net.app.core.file" => {
48
+ file_id: file.id,
49
+ file_token: file.file_token,
50
+ format: 'oembed',
51
+ }
52
+ }
53
+ }
54
+ end
55
+
56
+ if self.attachment
57
+ file = ADNReborn::File.upload_file(self.attachment, {
58
+ type: 'net.app.adnrb.upload'
59
+ })
60
+
61
+ annotations << {
62
+ type: 'net.app.core.attachments',
63
+ value: {
64
+ "+net.app.core.file_list" => [
65
+ {
66
+ file_id: file.id,
67
+ file_token: file.file_token,
68
+ format: 'metadata',
69
+ }
70
+ ]
71
+ }
72
+ }
73
+ end
74
+
75
+ annotations
76
+ end
77
+
78
+ def message
79
+ message = {
80
+ annotations: self.annotations,
81
+ entities: {
82
+ parse_links: !!(self.parse_links or self.parse_markdown_links),
83
+ parse_markdown_links: !!self.parse_markdown_links
84
+ }
85
+ }
86
+
87
+ if self.text
88
+ message[:text] = self.text
89
+ else
90
+ message[:machine_only] = true
91
+ end
92
+
93
+ message
94
+ end
95
+
96
+ def send
97
+ api_message = ADNReborn::API::Message.create(self.channel_id, self.message)
98
+
99
+ Message.new api_message["data"]
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: UTF-8
2
+
3
+ %w{broadcast_message_builder}.each do |f|
4
+ require_relative "recipes/#{f}"
5
+ end
@@ -0,0 +1,103 @@
1
+ # encoding: UTF-8
2
+
3
+ module ADNReborn
4
+ class User
5
+ attr_accessor(
6
+ :id, :user_id, :username, :name, :description,
7
+ :timezone, :locale, :avatar_image,
8
+ :cover_image, :type, :counts, :app_data,
9
+ :follows_you, :you_follow, :you_muted
10
+ )
11
+
12
+ attr_writer :created_at
13
+
14
+ def self.me
15
+ new ADNReborn::API::Token.current["user"]
16
+ end
17
+
18
+ def self.find(user_id)
19
+ new ADNReborn::API::User.retrieve(user_id)['data']
20
+ end
21
+
22
+ def initialize(user_data = {})
23
+ set_values(user_data)
24
+ end
25
+
26
+ def created_at
27
+ DateTime.parse(@created_at)
28
+ end
29
+
30
+ # Followers/Users
31
+
32
+ def follow(user)
33
+ result = ADNReborn::API.post("#{ADNReborn::API_ENDPOINT_USERS}/#{user.user_id}/follow")
34
+ ADNReborn.create_instance(result["data"], User)
35
+ end
36
+
37
+ def unfollow(user)
38
+ if user.valid_user?
39
+ result = ADNReborn::API.delete("#{ADNReborn::API_ENDPOINT_USERS}/#{user.user_id}/follow")
40
+ ADNReborn.create_instance(result["data"], User)
41
+ end
42
+ end
43
+
44
+ def followers
45
+ result = ADNReborn::API::User.followers(user_id)
46
+ ADNReborn.create_collection(result["data"], User)
47
+ end
48
+
49
+ def following
50
+ result = ADNReborn::API::User.following(user_id)
51
+ ADNReborn.create_collection(result["data"], User)
52
+ end
53
+
54
+ # Mute
55
+
56
+ def mute(user)
57
+ if user.valid_user?
58
+ result = ADNReborn::API.post("#{ADNReborn::API_ENDPOINT_USERS}/#{user.user_id}/mute")
59
+ ADNReborn.create_instance(result["data"], User)
60
+ end
61
+ end
62
+
63
+ def unmute(user)
64
+ if user.valid_user?
65
+ result = ADNReborn::API.delete("#{ADNReborn::API_ENDPOINT_USERS}/#{user.user_id}/mute")
66
+ ADNReborn.create_instance(result["data"], User)
67
+ end
68
+ end
69
+
70
+ def mute_list
71
+ result = ADNReborn.get("#{ADNReborn::API_ENDPOINT_USERS}/me/muted")
72
+ ADNReborn.create_collection(result["data"], User)
73
+ end
74
+
75
+ # Posts
76
+
77
+ def posts(params = nil)
78
+ result = ADNReborn::API::Post.by_user(user_id, params)
79
+ ADNReborn.create_collection(result["data"], Post)
80
+ end
81
+
82
+ def stream(params = nil)
83
+ result = ADNReborn::API::Post.stream(params)
84
+ ADNReborn.create_collection(result["data"], Post)
85
+ end
86
+
87
+ def mentions(params = nil)
88
+ result = ADNReborn::API::Post.mentioning_user(user_id, params)
89
+ ADNReborn.create_collection(result["data"], Post)
90
+ end
91
+
92
+ def valid_user?
93
+ !!user_id.match(/^\d+$/)
94
+ end
95
+
96
+ def set_values(values)
97
+ if values.respond_to? :each_pair
98
+ values.each_pair { |k, v| send("#{k}=", v) if respond_to?("#{k}=") }
99
+ self.user_id = id.to_s
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: UTF-8
2
+
3
+ module ADNReborn
4
+ MAJOR = 0
5
+ MINOR = 4
6
+ TINY = 1
7
+ VERSION = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+
data/lib/adn-reborn.rb ADDED
@@ -0,0 +1,69 @@
1
+
2
+ #
3
+ # ADNReborn - A simple and easy to use App.net Ruby library
4
+ #
5
+ # Copyright (c) 2016 trorornmn
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining
8
+ # a copy of this software and associated documentation files (the
9
+ # "Software"), to deal in the Software without restriction, including
10
+ # without limitation the rights to use, copy, modify, merge, publish,
11
+ # distribute, sublicense, and/or sell copies of the Software, and to
12
+ # permit persons to whom the Software is furnished to do so, subject to
13
+ # the following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be
16
+ # included in all copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+ #
26
+ # Copyright (c) 2012 Kishyr Ramdial
27
+ #
28
+ # Permission is hereby granted, free of charge, to any person obtaining
29
+ # a copy of this software and associated documentation files (the
30
+ # "Software"), to deal in the Software without restriction, including
31
+ # without limitation the rights to use, copy, modify, merge, publish,
32
+ # distribute, sublicense, and/or sell copies of the Software, and to
33
+ # permit persons to whom the Software is furnished to do so, subject to
34
+ # the following conditions:
35
+ #
36
+ # The above copyright notice and this permission notice shall be
37
+ # included in all copies or substantial portions of the Software.
38
+ #
39
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
40
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
41
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
42
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
43
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
44
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
45
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46
+
47
+ require 'uri'
48
+ require 'json'
49
+ require 'date'
50
+
51
+ %w{constants api file message post user version recipes}.each do |f|
52
+ require_relative "adn-reborn/#{f}"
53
+ end
54
+
55
+ module ADNReborn
56
+ Error = Class.new StandardError
57
+
58
+ class << self
59
+ attr_accessor :token
60
+ end
61
+
62
+ def self.create_instance(data, type)
63
+ type.new(data)
64
+ end
65
+
66
+ def self.create_collection(data, type)
67
+ data.map { |t| type.new(t) }
68
+ end
69
+ end
@@ -0,0 +1,73 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../../spec_helper'
4
+
5
+ describe ADNReborn::API::File do
6
+ subject { ADNReborn::API::File }
7
+
8
+ let(:base_path) { '/stream/0/files' }
9
+
10
+ let(:error_id) do
11
+ '6f5137beac6c4b9ea8dbec8e50aa9f38$32a85f1c22e98de98ea2ddabaf76c5ae'
12
+ end
13
+
14
+ let(:error_message) do
15
+ 'Call requires authentication: This view requires' +
16
+ ' authentication and no token was provided.'
17
+ end
18
+
19
+ let(:error_response) do
20
+ OpenStruct.new(:body => %Q{ {
21
+ "meta" : {
22
+ "code" : 401,
23
+ "error_id" : "#{error_id}",
24
+ "error_message" : "#{error_message}"
25
+ }}
26
+ })
27
+ end
28
+
29
+ describe "new" do
30
+ it "passes the file content in params to the API" do
31
+ args(:post_multipart) {
32
+ path, params = subject.create(__FILE__, { type: 'foo' })
33
+
34
+ path.must_equal base_path
35
+ params["content"].local_path.must_equal __FILE__
36
+ params["content"].content_type.must_equal "application/x-ruby"
37
+ params["metadata"].content_type.must_equal "application/json"
38
+
39
+ JSON.parse(params["metadata"].read).must_equal({"type" => 'foo'})
40
+ }
41
+ end
42
+
43
+ it 'retrieves error message correctly' do
44
+ ADNReborn::HTTP.stub(:request, error_response) do
45
+ error_call = lambda {subject.create(__FILE__, { foo: 'bar' })}
46
+ error_call.must_raise ADNReborn::API::Error
47
+
48
+ error = error_call.call rescue $!
49
+ error.message.must_equal error_message
50
+ end
51
+ end
52
+ end
53
+
54
+ describe "retrieve" do
55
+ it "retrieves the file" do
56
+ arg(:get) { subject.retrieve(8).must_equal base_path + "/8" }
57
+ end
58
+ end
59
+
60
+ describe "by_id" do
61
+ it "is just an alias for retrieve" do
62
+ subject.stub(:retrieve, 'bar') do
63
+ subject.by_id(4).must_equal 'bar'
64
+ end
65
+ end
66
+ end
67
+
68
+ describe "delete" do
69
+ it "deletes the file" do
70
+ arg(:delete) { subject.delete(5).must_equal base_path + "/5" }
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../../spec_helper'
4
+
5
+ describe ADNReborn::API::Filter do
6
+ subject { ADNReborn::API::Filter }
7
+
8
+ # Not Implemented Yet
9
+ end
@@ -0,0 +1,73 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../../spec_helper'
4
+
5
+ describe ADNReborn::API::Message do
6
+ subject { ADNReborn::API::Message }
7
+
8
+ let(:base_path) { '/stream/0/channels' }
9
+
10
+ let(:error_id) do
11
+ '6f5137beac6c4b9ea8dbec8e50aa9f38$32a85f1c22e98de98ea2ddabaf76c5ae'
12
+ end
13
+
14
+ let(:error_message) do
15
+ 'Call requires authentication: This view requires' +
16
+ ' authentication and no token was provided.'
17
+ end
18
+
19
+ let(:error_response) {
20
+ OpenStruct.new(:body =>
21
+ %Q{ { "meta" : {
22
+ "code" : 401,
23
+ "error_id" : "#{error_id}",
24
+ "error_message" : "#{error_message}"
25
+ }}
26
+ })
27
+ }
28
+
29
+ describe "new" do
30
+ it "messages the passed in params to the API" do
31
+ args(:post) {
32
+ path, params = subject.create(1, { foo: 'bar' })
33
+
34
+ path.must_equal base_path + '/1/messages'
35
+ params.must_equal foo: 'bar'
36
+ }
37
+ end
38
+
39
+ it 'retrieves error message correctly' do
40
+ ADNReborn::HTTP.stub(:request, error_response) do
41
+ error_call = lambda {subject.create(1, { foo: 'bar' })}
42
+ error_call.must_raise ADNReborn::API::Error
43
+
44
+ error = error_call.call rescue $!
45
+ error.message.must_equal error_message
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "retrieve" do
51
+ it "retrieves the message" do
52
+ arg(:get) {
53
+ subject.retrieve(8, 22).must_equal base_path + "/8/messages/22"
54
+ }
55
+ end
56
+ end
57
+
58
+ describe "by_id" do
59
+ it "is just an alias for retrieve" do
60
+ subject.stub(:retrieve, 'bar') do
61
+ subject.by_id(4, 456).must_equal 'bar'
62
+ end
63
+ end
64
+ end
65
+
66
+ describe "delete" do
67
+ it "deletes the message" do
68
+ arg(:delete) {
69
+ subject.delete(5, 77).must_equal base_path + "/5/messages/77"
70
+ }
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,147 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../../spec_helper'
4
+
5
+ describe ADNReborn::API::Post do
6
+ subject { ADNReborn::API::Post }
7
+
8
+ let(:base_path) { '/stream/0/posts' }
9
+
10
+ let(:error_message) do
11
+ 'Call requires authentication: This view requires' +
12
+ ' authentication and no token was provided.'
13
+ end
14
+
15
+ let(:error_id) do
16
+ "6f5137beac6c4b9ea8dbec8e50aa9f38$32a85f1c22e98de98ea2ddabaf76c5ae"
17
+ end
18
+
19
+ let(:error_response) do
20
+ OpenStruct.new(:body => %Q{ {
21
+ "meta" : {
22
+ "code" : 401,
23
+ "error_id" : "#{error_id}",
24
+ "error_message" : "#{error_message}"
25
+ }}
26
+ })
27
+ end
28
+
29
+ describe "new" do
30
+ it "posts the passed in params to the API" do
31
+ args(:post) {
32
+ path, params = subject.create({ foo: 'bar' })
33
+
34
+ path.must_equal base_path
35
+ params.must_equal foo: 'bar'
36
+ }
37
+ end
38
+
39
+ it 'retrieves error message correctly' do
40
+ ADNReborn::HTTP.stub(:request, error_response) do
41
+ error_call = lambda {subject.create({ foo: 'bar' })}
42
+ error_call.must_raise ADNReborn::API::Error
43
+
44
+ error = error_call.call rescue $!
45
+ error.message.must_equal error_message
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "retrieve" do
51
+ it "retrieves the post" do
52
+ arg(:get) {
53
+ subject.retrieve(22).must_equal base_path + "/22"
54
+ }
55
+ end
56
+ end
57
+
58
+ describe "by_id" do
59
+ it "is just an alias for retrieve" do
60
+ subject.stub(:retrieve, 'bar') do
61
+ subject.by_id(456).must_equal 'bar'
62
+ end
63
+ end
64
+ end
65
+
66
+ describe "delete" do
67
+ it "deletes the post" do
68
+ arg(:delete) {
69
+ subject.delete(77).must_equal base_path + "/77"
70
+ }
71
+ end
72
+ end
73
+
74
+ describe "replies" do
75
+ it "returns replies by post id" do
76
+ args(:get) {
77
+ path, params = subject.replies(33, 'foo')
78
+
79
+ path.must_equal base_path + "/33/replies"
80
+ params.must_equal 'foo'
81
+ }
82
+ end
83
+ end
84
+
85
+ describe "by_user" do
86
+ it "returns posts by user" do
87
+ args(:get) {
88
+ path, params = subject.by_user(33, 'bar')
89
+
90
+ path.must_equal "/stream/0/users/33/posts"
91
+ params.must_equal 'bar'
92
+ }
93
+ end
94
+ end
95
+
96
+ describe "mentioning_user" do
97
+ it "returns posts mentioning user" do
98
+ args(:get) {
99
+ path, params = subject.mentioning_user(22, 'baz')
100
+
101
+ path.must_equal "/stream/0/users/22/mentions"
102
+ params.must_equal 'baz'
103
+ }
104
+ end
105
+ end
106
+
107
+ describe "stream" do
108
+ it "retrieves the stream" do
109
+ args(:get) {
110
+ subject.stream('foo').must_equal [base_path + "/stream", 'foo']
111
+ }
112
+ end
113
+ end
114
+
115
+ describe "global_stream" do
116
+ it "retrieves the global stream" do
117
+ args(:get) {
118
+ path, params = subject.global_stream('bar')
119
+
120
+ path.must_equal base_path + "/stream/global"
121
+ params.must_equal 'bar'
122
+ }
123
+ end
124
+ end
125
+
126
+ describe "unified_stream" do
127
+ it "retrieves the unified stream" do
128
+ args(:get) {
129
+ path, params = subject.unified_stream('baz')
130
+
131
+ path.must_equal base_path + "/stream/unified"
132
+ params.must_equal 'baz'
133
+ }
134
+ end
135
+ end
136
+
137
+ describe "by_hashtag" do
138
+ it "retrieves posts by hashtag" do
139
+ args(:get) {
140
+ path, params = subject.by_hashtag('ruby', 'foo')
141
+
142
+ path.must_equal base_path + "/tag/ruby"
143
+ params.must_equal 'foo'
144
+ }
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../../spec_helper'
4
+
5
+ describe ADNReborn::API::Response do
6
+
7
+ subject { ADNReborn::API::Response }
8
+
9
+ it "currently checks a hash-like response for errors" do
10
+ subject.new("meta" => {"code" => 400}).has_error?.must_equal true
11
+ subject.new("meta" => {"code" => 200}).has_error?.must_equal false
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../../spec_helper'
4
+
5
+ describe ADNReborn::API::Stream do
6
+ subject { ADNReborn::API::Stream }
7
+
8
+ # Not Implemented Yet
9
+ end