-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathhtml_presenter_spec.rb
More file actions
51 lines (41 loc) · 1.38 KB
/
html_presenter_spec.rb
File metadata and controls
51 lines (41 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require 'spec_helper'
describe Tweet::HtmlPresenter do
subject { presenter }
let(:presenter) { described_class.new tweet }
let(:tweet_link) {
link = 'http://t.co/cyL9StoS'
ExpandUrl.stub(:expand_url).with(link).and_return(link)
link
}
let(:tweet) {
Tweet.new(tweet_id: "263515718753079296",
tweet_text: "at @SteelCityRuby with @coreyhaines - one of my favorite #rubyfriends #{tweet_link}",
username: "joshsusser",
media_url: "http://p.twimg.com/A6gyJmlCUAA9Il2.jpg",
image: "A6gyJmlCUAA9Il2.jpg",
media_display_url: "pic.twitter.com/cyL9StoS"
)
}
its(:username) { should == "@joshsusser" }
describe "#text" do
subject(:text) { presenter.text }
it "links twitter hashtags" do
should include '<a href="http://twitter.com/search?q=%23rubyfriends">#rubyfriends</a>'
end
it "links twitter usernames" do
should include '<a href="http://twitter.com/SteelCityRuby">@SteelCityRuby</a>'
should include '<a href="http://twitter.com/coreyhaines">@coreyhaines</a>'
end
it "sanitizes html" do
tweet.tweet_text = "this < is > a & test"
should == "this < is > a & test"
end
end
describe "#url" do
subject(:url) { presenter.url }
it "adds a protocol if missing" do
tweet.media_display_url = "pic.twitter.com/cyL9StoS"
should match %r{^http://}
end
end
end