diff --git a/test/lib/docs/filters/core/internal_urls_test.rb b/test/lib/docs/filters/core/internal_urls_test.rb index 92ed5caa..1ca7bc9c 100644 --- a/test/lib/docs/filters/core/internal_urls_test.rb +++ b/test/lib/docs/filters/core/internal_urls_test.rb @@ -110,29 +110,6 @@ class InternalUrlsFilterTest < MiniTest::Spec @body = link_to 'http://example.com/dir/file' assert_empty internal_urls end - - context "when context[:trailing_slash] is true" do - it "adds a trailing slash" do - context[:trailing_slash] = true - @body = link_to 'http://example.com/dir/path' - assert_includes internal_urls, 'http://example.com/dir/path/' - end - end - - context "when context[:trailing_slash] is false" do - before { context[:trailing_slash] = false } - - it "removes trailing slashes" do - @body = link_to 'http://example.com/dir/path/' - assert_includes internal_urls, 'http://example.com/dir/path' - end - - it "doesn't remove the leading slash" do - context[:base_url] = context[:root_url] = 'http://example.com/' - @body = link_to 'http://example.com/' - assert_includes internal_urls, 'http://example.com/' - end - end end context "when the base url is 'example.com'" do @@ -258,6 +235,46 @@ class InternalUrlsFilterTest < MiniTest::Spec end end + context "context[:trailing_slash]" do + before do + @body = link_to('http://example.com/dir/path/') + link_to('http://example.com/dir/path') + end + + context "when it is true" do + before do + context[:trailing_slash] = true + end + + it "adds a trailing slash to :internal_urls" do + assert_equal ['http://example.com/dir/path/'], internal_urls + end + + it "adds a trailing slash to replaced urls" do + assert_equal link_to('path/') * 2, filter_output_string + end + end + + context "when it is false" do + before do + context[:trailing_slash] = false + end + + it "removes the trailing slash from :internal_urls" do + assert_equal ['http://example.com/dir/path'], internal_urls + end + + it "removes the trailing slash from replaced urls" do + assert_equal link_to('path') * 2, filter_output_string + end + + it "doesn't remove the leading slash" do + url = context[:base_url] = context[:root_url] = 'http://example.com/' + @body = link_to(url) + assert_equal [url], internal_urls + end + end + end + context "context[:skip_links]" do before do @body = link_to context[:url]