require 'spec_helper' describe 'Navigasmic::Builder::ListBuilder', type: :helper do subject { Navigasmic::Builder::ListBuilder } def clean(string) string.gsub(/\n(\s+)|\n|^\s+/, '') end describe "rendering" do it "outputs basic example" do builder = subject.new helper, :primary, {} do |n| n.group(class: 'group') { n.item "Label", '/path' } n.item('Level 1', class: 'item') { n.item 'Level 2' } end html = <<-HTML
HTML builder.render.should match(clean(html)) end it "handles builder configurations" do builder = subject.new helper, :primary, {config: :bootstrap} do |n| n.group('Group', class: 'group') { n.item "Label", '/path' } n.item('Level 1', class: 'item') { n.item 'Level 2' } n.item('Foo') end html = <<-HTML HTML builder.render.should match(clean(html)) end it "handles link_html of items" do builder = subject.new helper, :primary, {} do |n| n.item('Level 1', 'level1.html', class: 'item', link_html: {class: "dialog"}) end html = <<-HTML HTML builder.render.should match(clean(html)) end end end