From 642c1cff7d31ed5c336557e83ce170e2b314967e Mon Sep 17 00:00:00 2001 From: Thu Trang Pham Date: Tue, 3 Mar 2015 11:34:29 -0500 Subject: [PATCH] Make sure that home_url can be nil --- lib/docs/core/scraper.rb | 4 ++-- test/lib/docs/core/doc_test.rb | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/docs/core/scraper.rb b/lib/docs/core/scraper.rb index c0da1447..fa461ae2 100644 --- a/lib/docs/core/scraper.rb +++ b/lib/docs/core/scraper.rb @@ -3,7 +3,7 @@ require 'set' module Docs class Scraper < Doc class << self - attr_accessor :base_url, :home_url, :root_path, :initial_paths, :options, :html_filters, :text_filters + attr_accessor :base_url, :root_path, :initial_paths, :options, :html_filters, :text_filters def inherited(subclass) super @@ -66,7 +66,7 @@ module Docs end def home_url - @home_url ||= URL.parse self.class.home_url + @home_url ||= URL.parse self.class.home_url if self.class.home_url end def root_path diff --git a/test/lib/docs/core/doc_test.rb b/test/lib/docs/core/doc_test.rb index dfad3731..d3d783d3 100644 --- a/test/lib/docs/core/doc_test.rb +++ b/test/lib/docs/core/doc_test.rb @@ -60,6 +60,19 @@ class DocsDocTest < MiniTest::Spec end end + describe ".home_url" do + it "returns nil" do + assert_nil doc.home_url + end + end + + describe ".home_url=" do + it "stores .home_url" do + doc.home_url = 'http://www.url.com/doc' + assert_equal 'http://www.url.com/doc', doc.home_url + end + end + describe ".abstract" do it "returns nil" do assert_nil doc.abstract