add spec for filters class

This commit is contained in:
Ben Balter 2017-04-07 17:06:03 -04:00
parent dea21f0f8d
commit fa44b31280
No known key found for this signature in database
GPG Key ID: DBB67C246AD356C4
2 changed files with 22 additions and 2 deletions

View File

@ -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

View File

@ -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