From fa44b312802b771a26be5df7c5bed484e2b91810 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Fri, 7 Apr 2017 17:06:03 -0400 Subject: [PATCH] add spec for filters class --- lib/jekyll-seo-tag/drop.rb | 6 ++++-- spec/jekyll_seo_tag/filters_spec.rb | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 spec/jekyll_seo_tag/filters_spec.rb diff --git a/lib/jekyll-seo-tag/drop.rb b/lib/jekyll-seo-tag/drop.rb index a2f7714..34cec8d 100644 --- a/lib/jekyll-seo-tag/drop.rb +++ b/lib/jekyll-seo-tag/drop.rb @@ -2,6 +2,9 @@ module Jekyll class SeoTag class Drop < Jekyll::Drops::Drop TITLE_SEPARATOR = " | ".freeze + FORMAT_STRING_METHODS = %i[ + markdownify strip_html normalize_whitespace escape_once + ].freeze def initialize(text, context) @obj = {} @@ -190,8 +193,7 @@ module Jekyll end def format_string(string) - methods = %i[markdownify strip_html normalize_whitespace escape_once] - methods.each do |method| + FORMAT_STRING_METHODS.each do |method| string = filters.public_send(method, string) end diff --git a/spec/jekyll_seo_tag/filters_spec.rb b/spec/jekyll_seo_tag/filters_spec.rb new file mode 100644 index 0000000..c44d5cb --- /dev/null +++ b/spec/jekyll_seo_tag/filters_spec.rb @@ -0,0 +1,18 @@ +RSpec.describe Jekyll::SeoTag::Filters do + let(:page) { make_page } + let(:site) { make_site } + let(:context) { make_context(:page => page, :site => site) } + subject { described_class.new(context) } + + it "stores the context" do + expect(subject.instance_variable_get("@context")).to be_a(Liquid::Context) + end + + it "exposes jekyll filters" do + expect(subject).to respond_to(:markdownify) + end + + it "exposes liquid standard filters" do + expect(subject).to respond_to(:normalize_whitespace) + end +end