metainspector 1.9.4 → 1.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/meta_inspector/scraper.rb +2 -1
- data/lib/meta_inspector/version.rb +1 -1
- data/spec/fixtures/twitter_w3clove.response +4232 -0
- data/spec/metainspector_spec.rb +27 -19
- metadata +4 -3
data/spec/metainspector_spec.rb
CHANGED
@@ -15,6 +15,7 @@ describe MetaInspector do
|
|
15
15
|
FakeWeb.register_uri(:get, "http://example.com/nonhttp", :response => fixture_file("nonhttp.response"))
|
16
16
|
FakeWeb.register_uri(:get, "http://www.youtube.com/watch?v=iaGSSrp49uc", :response => fixture_file("youtube.response"))
|
17
17
|
FakeWeb.register_uri(:get, "http://w3clove.com/faqs", :response => fixture_file("w3clove_faqs.response"))
|
18
|
+
FakeWeb.register_uri(:get, "https://twitter.com/w3clove", :response => fixture_file("twitter_w3clove.response"))
|
18
19
|
|
19
20
|
describe 'Initialization' do
|
20
21
|
it 'should accept an URL with a scheme' do
|
@@ -58,14 +59,28 @@ describe MetaInspector do
|
|
58
59
|
@m.image.should == nil
|
59
60
|
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
describe "get image" do
|
63
|
+
it "should find the og image" do
|
64
|
+
@m = MetaInspector.new('http://www.theonion.com/articles/apple-claims-new-iphone-only-visible-to-most-loyal,2772/')
|
65
|
+
@m.image.should == "http://o.onionstatic.com/images/articles/article/2772/Apple-Claims-600w-R_jpg_130x110_q85.jpg"
|
66
|
+
@m.meta_og_image.should == "http://o.onionstatic.com/images/articles/article/2772/Apple-Claims-600w-R_jpg_130x110_q85.jpg"
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should find image on youtube" do
|
70
|
+
MetaInspector.new('http://www.youtube.com/watch?v=iaGSSrp49uc').image.should == "http://i2.ytimg.com/vi/iaGSSrp49uc/mqdefault.jpg"
|
71
|
+
end
|
65
72
|
end
|
66
73
|
|
67
|
-
|
68
|
-
|
74
|
+
describe "get images" do
|
75
|
+
it "should find all page images" do
|
76
|
+
@m.images == ["http://pagerankalert.com/images/pagerank_alert.png?1309512337"]
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should find images on twitter" do
|
80
|
+
m = MetaInspector.new('https://twitter.com/w3clove')
|
81
|
+
m.images.length.should == 6
|
82
|
+
m.images.join("; ").should == "https://twimg0-a.akamaihd.net/profile_images/2380086215/fcu46ozay5f5al9kdfvq_reasonably_small.png; https://twimg0-a.akamaihd.net/profile_images/2380086215/fcu46ozay5f5al9kdfvq_normal.png; https://twimg0-a.akamaihd.net/profile_images/2293774732/v0pgo4xpdd9rou2xq5h0_normal.png; https://twimg0-a.akamaihd.net/profile_images/1538528659/jaime_nov_08_normal.jpg; https://si0.twimg.com/sticky/default_profile_images/default_profile_6_mini.png; https://twimg0-a.akamaihd.net/a/1342841381/images/bigger_spinner.gif"
|
83
|
+
end
|
69
84
|
end
|
70
85
|
|
71
86
|
it "should ignore malformed image tags" do
|
@@ -91,6 +106,12 @@ describe MetaInspector do
|
|
91
106
|
@m = MetaInspector.new('http://www.tea-tron.com/jbravo/blog/')
|
92
107
|
@m.feed.should == 'http://www.tea-tron.com/jbravo/blog/feed/'
|
93
108
|
end
|
109
|
+
|
110
|
+
describe "get description" do
|
111
|
+
it "should find description on youtube" do
|
112
|
+
MetaInspector.new('http://www.youtube.com/watch?v=iaGSSrp49uc').description.should == ""
|
113
|
+
end
|
114
|
+
end
|
94
115
|
end
|
95
116
|
|
96
117
|
describe 'Page with missing meta description' do
|
@@ -295,17 +316,4 @@ describe MetaInspector do
|
|
295
316
|
end
|
296
317
|
end
|
297
318
|
|
298
|
-
describe "regression tests" do
|
299
|
-
describe "get image" do
|
300
|
-
it "should find image on youtube" do
|
301
|
-
MetaInspector.new('http://www.youtube.com/watch?v=iaGSSrp49uc').image.should == "http://i2.ytimg.com/vi/iaGSSrp49uc/mqdefault.jpg"
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
describe "get description" do
|
306
|
-
it "should find description on youtube" do
|
307
|
-
MetaInspector.new('http://www.youtube.com/watch?v=iaGSSrp49uc').description.should == ""
|
308
|
-
end
|
309
|
-
end
|
310
|
-
end
|
311
319
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metainspector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 1.9.
|
9
|
+
- 5
|
10
|
+
version: 1.9.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jaime Iniesta
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- spec/fixtures/tea-tron.com.response
|
163
163
|
- spec/fixtures/theonion-no-description.com.response
|
164
164
|
- spec/fixtures/theonion.com.response
|
165
|
+
- spec/fixtures/twitter_w3clove.response
|
165
166
|
- spec/fixtures/w3clove_faqs.response
|
166
167
|
- spec/fixtures/youtube.response
|
167
168
|
- spec/metainspector_spec.rb
|