onebox 1.4.7 → 1.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onebox/engine/twitter_status_onebox.rb +81 -8
- data/lib/onebox/engine/whitelisted_generic_onebox.rb +1 -0
- data/lib/onebox/version.rb +1 -1
- data/spec/fixtures/twitterstatus.response +3004 -12
- data/spec/lib/onebox/engine/twitter_status_onebox_spec.rb +84 -12
- metadata +1 -1
@@ -2,30 +2,102 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Onebox::Engine::TwitterStatusOnebox do
|
4
4
|
before(:all) do
|
5
|
-
@link = "https://twitter.com/
|
6
|
-
@uri = "https://api.twitter.com/1/statuses/oembed.json?id=504354595733504000"
|
7
|
-
fake(@uri, response(described_class.onebox_name))
|
8
|
-
onebox = described_class.new(@link)
|
9
|
-
@html = onebox.to_html
|
5
|
+
@link = "https://twitter.com/vyki_e/status/363116819147538433"
|
10
6
|
end
|
11
|
-
let(:html) { @html }
|
12
7
|
|
13
|
-
|
8
|
+
shared_examples_for "#to_html" do
|
14
9
|
it "includes tweet" do
|
15
|
-
expect(html).to include("
|
10
|
+
expect(html).to include("I'm a sucker for pledges.")
|
16
11
|
end
|
17
12
|
|
18
13
|
it "includes timestamp" do
|
19
14
|
pending
|
20
|
-
expect(html).to include("
|
15
|
+
expect(html).to include("6:59 PM - 1 Aug 13")
|
21
16
|
end
|
22
17
|
|
23
18
|
it "includes username" do
|
24
|
-
expect(html).to include("
|
19
|
+
expect(html).to include("vyki_e")
|
25
20
|
end
|
26
21
|
|
27
|
-
it "includes
|
28
|
-
expect(html).to include("
|
22
|
+
it "includes user avatar" do
|
23
|
+
expect(html).to include("39b969d32a10b2437563e246708c8f9d_normal.jpeg")
|
29
24
|
end
|
25
|
+
|
26
|
+
it "includes tweet favorite count" do
|
27
|
+
pending
|
28
|
+
expect(html).to include("")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "includes retweet count" do
|
32
|
+
pending
|
33
|
+
expect(html).to include("")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with html" do
|
38
|
+
include_context "engines"
|
39
|
+
it_behaves_like "an engine"
|
40
|
+
it_behaves_like "#to_html"
|
41
|
+
end
|
42
|
+
|
43
|
+
context "with twitter client" do
|
44
|
+
before(:each) do
|
45
|
+
@twitter_client = double("TwitterClient")
|
46
|
+
@twitter_client.stub("status") do
|
47
|
+
{
|
48
|
+
created_at: "Fri Aug 02 01:59:30 +0000 2013",
|
49
|
+
id: 363_116_819_147_538_433,
|
50
|
+
id_str: "363116819147538433",
|
51
|
+
text:
|
52
|
+
"I'm a sucker for pledges. @Peers Pledge #sharingeconomy http://t.co/T4Sc47KAzh",
|
53
|
+
source:
|
54
|
+
"<a href=\"http://twitter.com/tweetbutton\" rel=\"nofollow\">Tweet Button</a>",
|
55
|
+
user:
|
56
|
+
{ id: 1_087_064_150,
|
57
|
+
id_str: "1087064150",
|
58
|
+
name: "Vyki Englert",
|
59
|
+
screen_name: "vyki_e",
|
60
|
+
location: "Los Angeles, CA",
|
61
|
+
description: "I am woman, hear me #RoR.",
|
62
|
+
url: "http://t.co/umZG76wmv2",
|
63
|
+
protected: false,
|
64
|
+
followers_count: 249,
|
65
|
+
friends_count: 907,
|
66
|
+
listed_count: 6,
|
67
|
+
created_at: "Sun Jan 13 19:53:00 +0000 2013",
|
68
|
+
favourites_count: 506,
|
69
|
+
statuses_count: 926,
|
70
|
+
lang: "en",
|
71
|
+
contributors_enabled: false,
|
72
|
+
is_translator: false,
|
73
|
+
profile_image_url:
|
74
|
+
"http://pbs.twimg.com/profile_images/3518892092/39b969d32a10b2437563e246708c8f9d_normal.jpeg",
|
75
|
+
profile_image_url_https:
|
76
|
+
"https://pbs.twimg.com/profile_images/3518892092/39b969d32a10b2437563e246708c8f9d_normal.jpeg",
|
77
|
+
following: true,
|
78
|
+
follow_request_sent: false,
|
79
|
+
notifications: nil },
|
80
|
+
geo: nil,
|
81
|
+
coordinates: nil,
|
82
|
+
place: nil,
|
83
|
+
contributors: nil,
|
84
|
+
retweet_count: 0,
|
85
|
+
favorite_count: 0,
|
86
|
+
favorited: false,
|
87
|
+
retweeted: false,
|
88
|
+
possibly_sensitive: false,
|
89
|
+
lang: "en"
|
90
|
+
}
|
91
|
+
end
|
92
|
+
Onebox.options = { twitter_client: @twitter_client }
|
93
|
+
end
|
94
|
+
|
95
|
+
after(:each) do
|
96
|
+
Onebox.options = { twitter_client: nil }
|
97
|
+
end
|
98
|
+
|
99
|
+
include_context "engines"
|
100
|
+
it_behaves_like "an engine"
|
101
|
+
it_behaves_like "#to_html"
|
30
102
|
end
|
31
103
|
end
|