# stdlib require "ostruct" require "spec_helper" RSpec.describe Jekyll::AssetsPlugin::Renderer do let(:assets_config) { Hash.new } let(:site) do Jekyll::Site.new Jekyll.configuration({ "source" => fixtures_path.to_s, "destination" => @dest.to_s, "assets" => assets_config }) end let(:params) { "app" } let(:context) { OpenStruct.new(:registers => { :site => site }) } let(:renderer) { described_class.new context, params } describe "#path" do subject { renderer.path } context "with logical path only" do context "when logical path contains no spaces" do let(:params) { "app" } it { is_expected.to eq "app" } end context "when logical path contains spaces and double quoted" do let(:params) { '"my app"' } it { is_expected.to eq "my app" } end context "when logical path contains spaces and single quoted" do let(:params) { "'my app'" } it { is_expected.to eq "my app" } end end context "with logical path and params" do context "when logical path contains no spaces" do let(:params) { 'app foo bar="baz"' } it { is_expected.to eq "app" } end context "when logical path contains spaces and double quoted" do let(:params) { '"my app" foo bar="baz"' } it { is_expected.to eq "my app" } end context "when logical path contains spaces and single quoted" do let(:params) { %q('my app' foo bar="baz") } it { is_expected.to eq "my app" } end end end describe "#attrs" do subject { renderer.attrs } context "with logical path only" do context "when logical path contains no spaces" do let(:params) { "app" } it { is_expected.to eq "" } end context "when logical path contains spaces and double quoted" do let(:params) { '"my app"' } it { is_expected.to eq "" } end context "when logical path contains spaces and single quoted" do let(:params) { "'my app'" } it { is_expected.to eq "" } end end context "with logical path and params" do context "when logical path contains no spaces" do let(:params) { 'app foo bar="baz"' } it { is_expected.to eq ' foo bar="baz"' } end context "when logical path contains spaces and double quoted" do let(:params) { '"my app" foo bar="baz"' } it { is_expected.to eq ' foo bar="baz"' } end context "when logical path contains spaces and single quoted" do let(:params) { %q('my app' foo bar="baz") } it { is_expected.to eq ' foo bar="baz"' } end end end describe "#options" do subject { renderer.options } context "with no options given" do it { is_expected.to be_an Array } it { is_expected.to be_empty } end context "with options given" do let(:params) { "app [foo,bar]" } it { is_expected.to eq %w(foo bar) } end end describe "#render_javascript" do subject { renderer.render_javascript } context "when debug mode enabled" do let(:assets_config) { Hash[:debug, true] } it { is_expected.to match(/^(\s*