adn 0.0.1 → 0.3.2
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.
- data/.gitignore +6 -5
- data/.travis.yml +7 -0
- data/Gemfile +6 -3
- data/Gemfile.lock +18 -0
- data/README.md +54 -17
- data/Rakefile +23 -1
- data/adn.gemspec +13 -13
- data/lib/adn/api/filter.rb +10 -0
- data/lib/adn/api/post.rb +47 -0
- data/lib/adn/api/response.rb +13 -0
- data/lib/adn/api/stream.rb +10 -0
- data/lib/adn/api/subscription.rb +11 -0
- data/lib/adn/api/token.rb +12 -0
- data/lib/adn/api/user.rb +23 -0
- data/lib/adn/api.rb +45 -0
- data/lib/adn/constants.rb +14 -0
- data/lib/adn/post.rb +62 -0
- data/lib/adn/user.rb +109 -0
- data/lib/adn/version.rb +8 -2
- data/lib/adn.rb +52 -3
- data/spec/adn/api/filter_spec.rb +9 -0
- data/spec/adn/api/post_spec.rb +103 -0
- data/spec/adn/api/response_spec.rb +13 -0
- data/spec/adn/api/stream_spec.rb +9 -0
- data/spec/adn/api/subscription_spec.rb +9 -0
- data/spec/adn/api/token_spec.rb +21 -0
- data/spec/adn/api/user_spec.rb +35 -0
- data/spec/adn/post_spec.rb +146 -0
- data/spec/adn/user_spec.rb +117 -0
- data/spec/adn_spec.rb +40 -0
- data/spec/fixtures/post.json +88 -0
- data/spec/fixtures/user.json +54 -0
- data/spec/spec_helper.rb +30 -0
- metadata +56 -11
- data/LICENSE +0 -22
@@ -0,0 +1,103 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative '../../spec_helper'
|
4
|
+
|
5
|
+
describe ADN::API::Post do
|
6
|
+
subject { ADN::API::Post }
|
7
|
+
|
8
|
+
let(:base_path) { '/stream/0/posts' }
|
9
|
+
|
10
|
+
describe "new" do
|
11
|
+
it "posts the passed in params to the API" do
|
12
|
+
args(:post) {
|
13
|
+
path, params = subject.create({ foo: 'bar' })
|
14
|
+
|
15
|
+
path.must_equal base_path
|
16
|
+
params.must_equal foo: 'bar'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "retrieve" do
|
22
|
+
it "retrieves the post" do
|
23
|
+
arg(:get) { subject.retrieve(22).must_equal base_path + "/22" }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "by_id" do
|
28
|
+
it "is just an alias for retrieve" do
|
29
|
+
subject.stub(:retrieve, 'bar') do
|
30
|
+
subject.by_id(456).must_equal 'bar'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "delete" do
|
36
|
+
it "deletes the post" do
|
37
|
+
arg(:delete) { subject.delete(77).must_equal base_path + "/77" }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "replies" do
|
42
|
+
it "returns replies by post id" do
|
43
|
+
args(:get) {
|
44
|
+
path, params = subject.replies(33, 'foo')
|
45
|
+
|
46
|
+
path.must_equal base_path + "/33/replies"
|
47
|
+
params.must_equal 'foo'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "by_user" do
|
53
|
+
it "returns posts by user" do
|
54
|
+
args(:get) {
|
55
|
+
path, params = subject.by_user(33, 'bar')
|
56
|
+
|
57
|
+
path.must_equal "/stream/0/users/33/posts"
|
58
|
+
params.must_equal 'bar'
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "mentioning_user" do
|
64
|
+
it "returns posts mentioning user" do
|
65
|
+
args(:get) {
|
66
|
+
path, params = subject.mentioning_user(22, 'baz')
|
67
|
+
|
68
|
+
path.must_equal "/stream/0/users/22/mentions"
|
69
|
+
params.must_equal 'baz'
|
70
|
+
}
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "stream" do
|
75
|
+
it "retrieves the stream" do
|
76
|
+
args(:get) {
|
77
|
+
subject.stream('foo').must_equal [base_path + "/stream", 'foo']
|
78
|
+
}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "global_stream" do
|
83
|
+
it "retrieves the global stream" do
|
84
|
+
args(:get) {
|
85
|
+
path, params = subject.global_stream('bar')
|
86
|
+
|
87
|
+
path.must_equal base_path + "/stream/global"
|
88
|
+
params.must_equal 'bar'
|
89
|
+
}
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "by_hashtag" do
|
94
|
+
it "retrieves posts by hashtag" do
|
95
|
+
args(:get) {
|
96
|
+
path, params = subject.by_hashtag('ruby', 'foo')
|
97
|
+
|
98
|
+
path.must_equal base_path + "/tag/ruby"
|
99
|
+
params.must_equal 'foo'
|
100
|
+
}
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative '../../spec_helper'
|
4
|
+
|
5
|
+
describe ADN::API::Response do
|
6
|
+
|
7
|
+
subject { ADN::API::Response }
|
8
|
+
|
9
|
+
it "currently checks a hash-like response for errors" do
|
10
|
+
subject.new("error" => "123").has_error?.must_equal true
|
11
|
+
subject.new("valid" => "123").has_error?.must_equal false
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative '../../spec_helper'
|
4
|
+
|
5
|
+
describe ADN::API::Token do
|
6
|
+
subject { ADN::API::Token }
|
7
|
+
|
8
|
+
describe "current" do
|
9
|
+
it "does not return the current token if it has an error" do
|
10
|
+
ADN::API.stub(:get, ADN::API::Response.new({ "error" => "error message" })) do
|
11
|
+
subject.current.must_equal nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "retrieves the current token" do
|
16
|
+
ADN::API.stub(:get, ADN::API::Response.new({ "data" => "example_token" })) do
|
17
|
+
subject.current.must_equal "example_token"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative '../../spec_helper'
|
4
|
+
|
5
|
+
describe ADN::API::User do
|
6
|
+
subject { ADN::API::User }
|
7
|
+
|
8
|
+
let(:base_path) { '/stream/0/users/' }
|
9
|
+
|
10
|
+
describe "retrieve" do
|
11
|
+
it "retrieves the user" do
|
12
|
+
arg(:get) { subject.retrieve(55).must_equal base_path + "55" }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "by_id" do
|
17
|
+
it "is just an alias for retrieve" do
|
18
|
+
subject.stub(:retrieve, 'foo') do
|
19
|
+
subject.by_id(123).must_equal 'foo'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "following" do
|
25
|
+
it "retrieves the following list" do
|
26
|
+
arg(:get) { subject.following(44).must_equal base_path + "44/following" }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "followers" do
|
31
|
+
it "retrieves the followers list" do
|
32
|
+
arg(:get) { subject.following(66).must_equal base_path + "66/following" }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative '../spec_helper'
|
4
|
+
|
5
|
+
def d(data)
|
6
|
+
{ 'data' => data }
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ADN::Post do
|
10
|
+
subject { ADN::Post }
|
11
|
+
|
12
|
+
let(:empty_post) { subject.new({}) }
|
13
|
+
let(:post_with_id) { subject.new({ post_id: 123 }) }
|
14
|
+
let(:post) { subject.new(post_data) }
|
15
|
+
|
16
|
+
let(:example_user) { { username: 'peterhellberg' } }
|
17
|
+
let(:post_data) {
|
18
|
+
{
|
19
|
+
created_at: '1999-12-31T23:59:59Z',
|
20
|
+
entities: {},
|
21
|
+
html: '<b>The sky above the port…</b>',
|
22
|
+
id: 10001,
|
23
|
+
num_replies: 1,
|
24
|
+
reply_to: 66,
|
25
|
+
source: { link: "https://alpha.app.net", name: "Alpha" },
|
26
|
+
text: "The sky above the port…",
|
27
|
+
thread_id: "301856",
|
28
|
+
user: example_user
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
describe "send_post" do
|
33
|
+
it "creates a post via the API" do
|
34
|
+
ADN::API::Post.stub(:create, ADN::API::Response.new(d(post_data))) do
|
35
|
+
p = subject.send_post({})
|
36
|
+
p.text.must_equal 'The sky above the port…'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "initialize" do
|
42
|
+
it "populates the accessors using the passed in hash" do
|
43
|
+
p = subject.new text: 'foo', id: 123
|
44
|
+
p.text.must_equal 'foo'
|
45
|
+
end
|
46
|
+
|
47
|
+
# TODO: Change this behavior (Add a find method instead)
|
48
|
+
it "populates the accessors based on the passed in id" do
|
49
|
+
ADN::API::Post.stub(:by_id, ->(i){ d({ "text" => 'bar'}) }) do
|
50
|
+
p = subject.new 456
|
51
|
+
p.text.must_equal 'bar'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "details" do
|
57
|
+
it "returns the details for the post" do
|
58
|
+
post.details.keys.must_equal [
|
59
|
+
"created_at", "entities", "html",
|
60
|
+
"id", "num_replies", "reply_to",
|
61
|
+
"source", "text", "thread_id", "user"
|
62
|
+
]
|
63
|
+
end
|
64
|
+
|
65
|
+
it "returns the post from the api if it has no id" do
|
66
|
+
|
67
|
+
ADN::API::Post.stub(:by_id, ->(i){ d({ "id" => i}) }) do
|
68
|
+
post_with_id.details.
|
69
|
+
must_equal({ "data" => { "id" => 123 } })
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "created_at" do
|
75
|
+
it "returns the date and time the post was created" do
|
76
|
+
post.created_at.to_s.must_equal '1999-12-31T23:59:59+00:00'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "user" do
|
81
|
+
it "returns the user" do
|
82
|
+
post.user.username.must_equal 'peterhellberg'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "reply_to_post" do
|
87
|
+
it "returns the post that was replied to" do
|
88
|
+
ADN::API::Post.stub(:by_id, ->(id){
|
89
|
+
ADN::API::Response.new("data" => { "id" => id })
|
90
|
+
}) do
|
91
|
+
post.reply_to_post.id.must_equal 66
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "replies" do
|
97
|
+
it "returns a list of posts" do
|
98
|
+
response = ADN::API::Response.new("data" => [{ text: "foo"}, {text: "bar"}])
|
99
|
+
|
100
|
+
ADN::API::Post.stub(:replies, ->(*a){ response }) do
|
101
|
+
r = post.replies
|
102
|
+
r.size.must_equal 2
|
103
|
+
r[0].text.must_equal 'foo'
|
104
|
+
r[1].text.must_equal 'bar'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "delete" do
|
110
|
+
it "deletes the post via the API and returns a new post" do
|
111
|
+
delete_stub = ->(id){
|
112
|
+
ADN::API::Response.new("data" => { "id" => id*2 })
|
113
|
+
}
|
114
|
+
|
115
|
+
ADN::API::Post.stub(:delete, delete_stub) do
|
116
|
+
post.delete.id.must_equal 20002
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "set_values" do
|
122
|
+
it "sets values with accessors" do
|
123
|
+
p = empty_post
|
124
|
+
|
125
|
+
p.set_values(post_data)
|
126
|
+
|
127
|
+
p.entities.must_equal post_data[:entities]
|
128
|
+
p.html.must_equal post_data[:html]
|
129
|
+
p.id.must_equal post_data[:id]
|
130
|
+
p.num_replies.must_equal post_data[:num_replies]
|
131
|
+
p.reply_to.must_equal post_data[:reply_to]
|
132
|
+
p.source.must_equal post_data[:source]
|
133
|
+
p.text.must_equal post_data[:text]
|
134
|
+
p.thread_id.must_equal post_data[:thread_id]
|
135
|
+
|
136
|
+
p.created_at.must_equal DateTime.parse(post_data[:created_at])
|
137
|
+
|
138
|
+
p.user.username.must_equal post_data[:user][:username]
|
139
|
+
end
|
140
|
+
|
141
|
+
it "does not set arbitrary values" do
|
142
|
+
p = subject.new foo: 'bar'
|
143
|
+
-> { p.foo }.must_raise NoMethodError
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative '../spec_helper'
|
4
|
+
|
5
|
+
describe ADN::User do
|
6
|
+
subject { ADN::User }
|
7
|
+
|
8
|
+
let(:empty_user) { subject.new({}) }
|
9
|
+
let(:user) { subject.new(user_data) }
|
10
|
+
let(:user_data) { fixture('user.json') }
|
11
|
+
|
12
|
+
describe "initialize" do
|
13
|
+
it "populates the accessors based on the raw user data passed in" do
|
14
|
+
u = subject.new(user_data)
|
15
|
+
u.user_id.must_equal "4821"
|
16
|
+
end
|
17
|
+
|
18
|
+
# TODO: Remove this behavior, wrong level of abstraction
|
19
|
+
it "populates the accessors based on the user id passed in" do
|
20
|
+
ADN::API::User.stub(:retrieve, { "data" => user_data }) do
|
21
|
+
u = subject.new("4821")
|
22
|
+
u.name.must_equal "Peter Hellberg"
|
23
|
+
u.user_id.must_equal "4821"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "details" do
|
29
|
+
it "spec_name" do
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "created_at" do
|
34
|
+
it "it returns the date and time the user was created" do
|
35
|
+
user.created_at.to_s.must_equal '2012-08-17T00:38:18+00:00'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# TODO: Change the name to describe what
|
40
|
+
# it actually returns (user_id) or
|
41
|
+
# remove it completely
|
42
|
+
describe "get_user" do
|
43
|
+
it "returns a user id for some reason" do
|
44
|
+
empty_user.get_user(user).must_equal "4821"
|
45
|
+
empty_user.get_user(123).must_equal 123
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "follow" do
|
50
|
+
it "" do
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "unfollow" do
|
55
|
+
it "" do
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "followers" do
|
60
|
+
it "" do
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "following" do
|
65
|
+
it "" do
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "mute" do
|
70
|
+
it "" do
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "unmute" do
|
75
|
+
it "" do
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "mute_list" do
|
80
|
+
it "" do
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "posts" do
|
85
|
+
it "" do
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "stream" do
|
90
|
+
it "" do
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "mentions" do
|
95
|
+
it "" do
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "set_values" do
|
100
|
+
it "only sets valid attributes" do
|
101
|
+
u = subject.new({})
|
102
|
+
u.set_values({ foo: 'bar', name: 'Molly' })
|
103
|
+
u.name.must_equal 'Molly'
|
104
|
+
-> { u.foo }.must_raise NoMethodError
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "has_error?" do
|
109
|
+
it "returns true if no id" do
|
110
|
+
empty_user.has_error?.must_equal true
|
111
|
+
end
|
112
|
+
|
113
|
+
it "returns false if the user has an id" do
|
114
|
+
user.has_error?.must_equal false
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
data/spec/adn_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative 'spec_helper'
|
4
|
+
|
5
|
+
describe ADN do
|
6
|
+
subject { ADN }
|
7
|
+
|
8
|
+
let(:example_token) {
|
9
|
+
'f1d2d2f924e986ac86fdf7b36c94bcdf32beec15'
|
10
|
+
}
|
11
|
+
|
12
|
+
it "can set and get a token" do
|
13
|
+
subject.token.must_equal nil
|
14
|
+
subject.token = example_token
|
15
|
+
subject.token.must_equal example_token
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has a constant containing the hostname of the api" do
|
19
|
+
ADN::API_HOST.must_equal 'alpha-api.app.net'
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has constants containing the API endpoints for posts and users" do
|
23
|
+
ADN::API_ENDPOINT_POSTS.must_equal '/stream/0/posts'
|
24
|
+
ADN::API_ENDPOINT_USERS.must_equal '/stream/0/users'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "has constants containing the API endpoints for tokens" do
|
28
|
+
ADN::API_ENDPOINT_TOKEN.must_equal '/stream/0/token'
|
29
|
+
end
|
30
|
+
|
31
|
+
# TODO: Move into the ADN module, and rename using snake case
|
32
|
+
# Should probably be refactored to a separate class
|
33
|
+
it "currently has a constant containing a http client" do
|
34
|
+
ADN::HTTP.tap { |http|
|
35
|
+
http.address.must_equal "alpha-api.app.net"
|
36
|
+
http.port.must_equal 443
|
37
|
+
http.use_ssl?.must_equal true
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
{
|
2
|
+
"created_at": "2012-08-24T15:47:22Z",
|
3
|
+
"entities": {
|
4
|
+
"hashtags": [
|
5
|
+
{
|
6
|
+
"len": 5,
|
7
|
+
"name": "Ruby",
|
8
|
+
"pos": 27
|
9
|
+
}
|
10
|
+
],
|
11
|
+
"links": [
|
12
|
+
|
13
|
+
],
|
14
|
+
"mentions": [
|
15
|
+
{
|
16
|
+
"id": "351",
|
17
|
+
"len": 6,
|
18
|
+
"name": "joyce",
|
19
|
+
"pos": 0
|
20
|
+
}
|
21
|
+
]
|
22
|
+
},
|
23
|
+
"html": "<span itemscope=\"https://app.net/schemas/Post\"><span itemprop=\"mention\" data-mention-id=\"351\" data-mention-name=\"joyce\">@joyce</span> I’m very partial to <span itemprop=\"hashtag\" data-hashtag-name=\"Ruby\">#Ruby</span> when it comes to server side languages, and it’s also quite easy to learn. (Probably takes a lifetime to fully master though)</span>",
|
24
|
+
"id": "175510",
|
25
|
+
"machine_only": false,
|
26
|
+
"num_replies": 1,
|
27
|
+
"reply_to": "175485",
|
28
|
+
"source": {
|
29
|
+
"link": "http://xtendr.net",
|
30
|
+
"name": "xtendr"
|
31
|
+
},
|
32
|
+
"text": "@joyce I’m very partial to #Ruby when it comes to server side languages, and it’s also quite easy to learn. (Probably takes a lifetime to fully master though)",
|
33
|
+
"thread_id": "175470",
|
34
|
+
"user": {
|
35
|
+
"avatar_image": {
|
36
|
+
"height": 200,
|
37
|
+
"url": "https://d2rfichhc2fb9n.cloudfront.net/image/4/vKp-0ksqIbYGrrDV6y2sDSjvg9Cg5AmCjyVGfuokT2M-U8fB2NM23UW_EDPC-0oEfpgPy7SD7YFuF4Lra1mousUVeMMu5lNcth1BqHYMu-tIKIp3-wpADI0UEhUqr5J5sT4eKopTw34RWXvLOHJE_C7O-wE",
|
38
|
+
"width": 200
|
39
|
+
},
|
40
|
+
"counts": {
|
41
|
+
"followers": 85,
|
42
|
+
"following": 62,
|
43
|
+
"posts": 390
|
44
|
+
},
|
45
|
+
"cover_image": {
|
46
|
+
"height": 538,
|
47
|
+
"url": "https://d2rfichhc2fb9n.cloudfront.net/image/4/LGbl1tTJt3wsWEtK2HQko7gSiM10_hIHy8Z20oC7mH_BVjlZNH2hNaaRTvC00FWUq-jYS_GA4ZX9ivltg6Y6T_uYyvVEPQ7Ijtn5dlhrlClqCP1QxhVk3kcT300TjHfXy0y10p_nYjZi4X6kDQwvJh2oFPM",
|
48
|
+
"width": 1280
|
49
|
+
},
|
50
|
+
"created_at": "2012-08-17T00:38:18Z",
|
51
|
+
"description": {
|
52
|
+
"entities": {
|
53
|
+
"hashtags": [
|
54
|
+
{
|
55
|
+
"len": 5,
|
56
|
+
"name": "Ruby",
|
57
|
+
"pos": 0
|
58
|
+
}
|
59
|
+
],
|
60
|
+
"links": [
|
61
|
+
{
|
62
|
+
"len": 35,
|
63
|
+
"pos": 83,
|
64
|
+
"text": "http://black-white-city.tumblr.com/",
|
65
|
+
"url": "http://black-white-city.tumblr.com/"
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"len": 13,
|
69
|
+
"pos": 122,
|
70
|
+
"text": "http://c7.se/",
|
71
|
+
"url": "http://c7.se/"
|
72
|
+
}
|
73
|
+
],
|
74
|
+
"mentions": [
|
75
|
+
|
76
|
+
]
|
77
|
+
},
|
78
|
+
"html": "<span itemscope=\"https://app.net/schemas/Post\"><span itemprop=\"hashtag\" data-hashtag-name=\"Ruby\">#Ruby</span> developer, Mac convert, Linux aficionado and Boulder climber. Photo project: <a href=\"http://black-white-city.tumblr.com/\">http://black-white-city.tumblr.com/</a>\r\n\r\n<a href=\"http://c7.se/\">http://c7.se/</a></span>",
|
79
|
+
"text": "#Ruby developer, Mac convert, Linux aficionado and Boulder climber. Photo project: http://black-white-city.tumblr.com/\r\n\r\nhttp://c7.se/"
|
80
|
+
},
|
81
|
+
"id": "4821",
|
82
|
+
"locale": "en_US",
|
83
|
+
"name": "Peter Hellberg",
|
84
|
+
"timezone": "America/Los_Angeles",
|
85
|
+
"type": "human",
|
86
|
+
"username": "peterhellberg"
|
87
|
+
}
|
88
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
{
|
2
|
+
"avatar_image": {
|
3
|
+
"height": 200,
|
4
|
+
"url": "https://d2rfichhc2fb9n.cloudfront.net/image/4/vKp-0ksqIbYGrrDV6y2sDSjvg9Cg5AmCjyVGfuokT2M-U8fB2NM23UW_EDPC-0oEfpgPy7SD7YFuF4Lra1mousUVeMMu5lNcth1BqHYMu-tIKIp3-wpADI0UEhUqr5J5sT4eKopTw34RWXvLOHJE_C7O-wE",
|
5
|
+
"width": 200
|
6
|
+
},
|
7
|
+
"counts": {
|
8
|
+
"followers": 85,
|
9
|
+
"following": 62,
|
10
|
+
"posts": 390
|
11
|
+
},
|
12
|
+
"cover_image": {
|
13
|
+
"height": 538,
|
14
|
+
"url": "https://d2rfichhc2fb9n.cloudfront.net/image/4/LGbl1tTJt3wsWEtK2HQko7gSiM10_hIHy8Z20oC7mH_BVjlZNH2hNaaRTvC00FWUq-jYS_GA4ZX9ivltg6Y6T_uYyvVEPQ7Ijtn5dlhrlClqCP1QxhVk3kcT300TjHfXy0y10p_nYjZi4X6kDQwvJh2oFPM",
|
15
|
+
"width": 1280
|
16
|
+
},
|
17
|
+
"created_at": "2012-08-17T00:38:18Z",
|
18
|
+
"description": {
|
19
|
+
"entities": {
|
20
|
+
"hashtags": [
|
21
|
+
{
|
22
|
+
"len": 5,
|
23
|
+
"name": "Ruby",
|
24
|
+
"pos": 0
|
25
|
+
}
|
26
|
+
],
|
27
|
+
"links": [
|
28
|
+
{
|
29
|
+
"len": 35,
|
30
|
+
"pos": 83,
|
31
|
+
"text": "http://black-white-city.tumblr.com/",
|
32
|
+
"url": "http://black-white-city.tumblr.com/"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"len": 13,
|
36
|
+
"pos": 122,
|
37
|
+
"text": "http://c7.se/",
|
38
|
+
"url": "http://c7.se/"
|
39
|
+
}
|
40
|
+
],
|
41
|
+
"mentions": [
|
42
|
+
|
43
|
+
]
|
44
|
+
},
|
45
|
+
"html": "<span itemscope=\"https://app.net/schemas/Post\"><span itemprop=\"hashtag\" data-hashtag-name=\"Ruby\">#Ruby</span> developer, Mac convert, Linux aficionado and Boulder climber. Photo project: <a href=\"http://black-white-city.tumblr.com/\">http://black-white-city.tumblr.com/</a>\r\n\r\n<a href=\"http://c7.se/\">http://c7.se/</a></span>",
|
46
|
+
"text": "#Ruby developer, Mac convert, Linux aficionado and Boulder climber. Photo project: http://black-white-city.tumblr.com/\r\n\r\nhttp://c7.se/"
|
47
|
+
},
|
48
|
+
"id": "4821",
|
49
|
+
"locale": "en_US",
|
50
|
+
"name": "Peter Hellberg",
|
51
|
+
"timezone": "America/Los_Angeles",
|
52
|
+
"type": "human",
|
53
|
+
"username": "peterhellberg"
|
54
|
+
}
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'minitest/spec'
|
4
|
+
require 'minitest/autorun'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'minitest/pride'
|
8
|
+
rescue LoadError
|
9
|
+
puts "Install the minitest gem if you want colored output"
|
10
|
+
end
|
11
|
+
|
12
|
+
require "find"
|
13
|
+
|
14
|
+
%w{./lib}.each do |load_path|
|
15
|
+
Find.find(load_path) { |f| require f if f.match(/\.rb$/) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def arg(m, k = ADN::API, &b)
|
19
|
+
k.stub(m,->(a){a}, &b)
|
20
|
+
end
|
21
|
+
|
22
|
+
def args(m, k = ADN::API, &b)
|
23
|
+
k.stub(m,->(*a){a}, &b)
|
24
|
+
end
|
25
|
+
|
26
|
+
def fixture(file_name)
|
27
|
+
JSON.parse IO.read(
|
28
|
+
File.dirname(__FILE__) + "/fixtures/#{file_name}"
|
29
|
+
)
|
30
|
+
end
|