require 'spec_helper' describe Nutmeg::TagTreeHelper do before(:each) do @tree_from_yaml = Nutmeg::TreeFromYaml.new({file: [Dir.pwd, "/spec/files/tree.yml"].join}) data = File.open([Dir.pwd, "/spec/files/tree.json"].join) @tree_from_json = Nutmeg::TreeFromJson.new(data) end describe "#print_html" do it "outputs html" do expect(Nutmeg::TagTreeHelper.new(@tree_from_yaml.tree).print_html([1]).class).to eq(String) expect(Nutmeg::TagTreeHelper.new(@tree_from_yaml.tree).print_html(["north", "men", "collections", "summer_2015"])).to eq("
") end it "outputs html for subtree" do subtree = @tree_from_yaml.tree.subtree("north") expect(Nutmeg::TagTreeHelper.new(subtree).print_html(["men", "collections", "summer_2015"])).to eq("") end it "outputs html for subtree (greedy)" do subtree = @tree_from_yaml.tree.subtree("north") expect(Nutmeg::TagTreeHelper.new(subtree).print_html(["men", "collections"],true)).to eq("") end context "from json" do it "outputs html for subtree" do subtree = @tree_from_json.tree expect(Nutmeg::TagTreeHelper.new(subtree, {:prepend_path => "/nl/t"}).print_html(["men", "collections"],false)).to eq("") end context "additional leaf content" do it "renders additional content in the leaf" do subtree = @tree_from_json.tree expect(Nutmeg::TagTreeHelper.new(subtree, {:prepend_path => "/nl/t"}).print_html(["north", "men", "footwear"],false, "Extra content")).to eq("") end end end end end