Skip to content

Commit

Permalink
Prep work for #183: Start using Jekyll::Site#liquid_renderer to test.
Browse files Browse the repository at this point in the history
  • Loading branch information
envygeeks committed Nov 17, 2015
1 parent ef29633 commit ad15eee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions spec/lib/jekyll/assets/liquid/tag_spec.rb
Expand Up @@ -9,22 +9,31 @@
subject { described_class }
before :all do
@site = stub_jekyll_site
@env = Jekyll::Assets::Env.new(@site)
@site_struct = OpenStruct.new(:registers => {
:sprockets => @env, :site => @site
})
@env = Jekyll::Assets::Env.new(@site)
@renderer = @site.liquid_renderer
@register = {
:registers => {
:site => @site
}
}
end

def stub_tag(tag, data)
fragment(subject.send(:new, tag, data, []).render( \
@site_struct))
payload = "{%% %s %s %%}" % [tag, data]
fragment(@renderer.file(__FILE__).parse(payload).render!( \
@site.site_payload, @register))
end

def fragment(html)
Nokogiri::HTML.fragment(html).children. \
first
end

# it "allows the user to use Liquid variables" do
# require "pry"
# binding. pry
# end

it "works with alias tags" do
expect(subject.send(:new, "image", "ruby.png", []).instance_variable_get(:@tag)).to eq \
"img"
Expand Down
2 changes: 1 addition & 1 deletion spec/support/jekyll.rb
Expand Up @@ -82,7 +82,7 @@ def stub_jekyll_site(opts = {})
silence_stdout do
Jekyll::Site.new(Jekyll.configuration(opts.merge({
"source" => path, "destination" => File.join(path, "_site")
})))
}))).tap(&:read)
end
end

Expand Down

0 comments on commit ad15eee

Please sign in to comment.