Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Styles committed Jan 30, 2015
1 parent 11391de commit 67e53e3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/fixtures/title_not_present.response
@@ -0,0 +1,21 @@
HTTP/1.1 200 OK
Age: 13
Cache-Control: max-age=120
Content-Type: text/html
Date: Mon, 06 Jan 2014 12:47:42 GMT
Expires: Mon, 06 Jan 2014 12:49:28 GMT
Server: Apache/2.2.14 (Ubuntu)
Vary: Accept-Encoding
Via: 1.1 varnish
X-Powered-By: PHP/5.3.2-1ubuntu4.22
X-Varnish: 1188792404 1188790413
Content-Length: 202
Connection: keep-alive

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head></head>
<body>
<p>A sample page with many types of meta tags</p>
</body>
</html>
5 changes: 5 additions & 0 deletions spec/meta_inspector/texts_spec.rb
Expand Up @@ -37,6 +37,11 @@
expect(page.best_title).to eq('This title came from the head and has leading and trailing whitespace')
end

it "should return nil if none of the candidates are present" do
page = MetaInspector.new('http://example.com/title_not_present')
expect(page.best_title).to be(nil)
end

end

describe '#description' do
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Expand Up @@ -45,6 +45,7 @@ def fixture_file(filename)
FakeWeb.register_uri(:get, "http://example.com/title_in_h1", :response => fixture_file("title_in_h1.response"))
FakeWeb.register_uri(:get, "http://example.com/title_best_choice", :response => fixture_file("title_best_choice.response"))
FakeWeb.register_uri(:get, "http://example.com/title_in_head_with_whitespace", :response => fixture_file("title_in_head_with_whitespace.response"))
FakeWeb.register_uri(:get, "http://example.com/title_not_present", :response => fixture_file("title_not_present.response"))

# These are older fixtures
FakeWeb.register_uri(:get, "http://pagerankalert.com", :response => fixture_file("pagerankalert.com.response"))
Expand Down

0 comments on commit 67e53e3

Please sign in to comment.