From 446aa88bdf64d8b890bdfcedf570d890f90ecf9c Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Sun, 16 Dec 2018 11:46:24 +0530 Subject: [PATCH] Add a custom inspect string for StaticFile objects (#7422) Merge pull request 7422 --- lib/jekyll/static_file.rb | 6 ++++++ test/test_static_file.rb | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/lib/jekyll/static_file.rb b/lib/jekyll/static_file.rb index a07d9e4b..f7db58f5 100644 --- a/lib/jekyll/static_file.rb +++ b/lib/jekyll/static_file.rb @@ -152,6 +152,12 @@ module Jekyll @defaults ||= @site.frontmatter_defaults.all url, type end + # Returns a debug string on inspecting the static file. + # Includes only the relative path of the object. + def inspect + "#<#{self.class} @relative_path=#{relative_path.inspect}>" + end + private def copy_file(dest_path) diff --git a/test/test_static_file.rb b/test/test_static_file.rb index 0c981fc3..cb8f6e7e 100644 --- a/test/test_static_file.rb +++ b/test/test_static_file.rb @@ -48,6 +48,11 @@ class TestStaticFile < JekyllUnitTest remove_dummy_file(@filename) if File.exist?(source_dir(@filename)) end + should "return a simple string on inspection" do + static_file = setup_static_file("root", "dir", @filename) + assert_equal "#", static_file.inspect + end + should "have a source file path" do static_file = setup_static_file("root", "dir", @filename) assert_equal "root/dir/#{@filename}", static_file.path