require 'rubygems' require 'bundler' Bundler.require(:test) require 'test/unit' require 'action_controller' require 'active_support/core_ext/string/output_safety' require 'crummy' require 'crummy/standard_renderer' class StandardRendererTest < Test::Unit::TestCase include Crummy def test_classes renderer = StandardRenderer.new assert_equal('name', renderer.render_crumbs([['name', 'url']], :first_class => 'first', :last_class => 'last', :format => :html)) assert_equal('', renderer.render_crumbs([['name', 'url']], :first_class => 'first', :last_class => 'last', :format => :html_list)) assert_equal('name', renderer.render_crumbs([['name', 'url']], :first_class => 'first', :last_class => 'last', :format => :xml)) assert_equal('name1 » name2', renderer.render_crumbs([['name1', 'url1'], ['name2', 'url2']], :first_class => 'first', :last_class => 'last', :format => :html)) assert_equal('', renderer.render_crumbs([['name1', 'url1'], ['name2', 'url2'], ['name3', 'url3']], :li_class => "li_class", :first_class => 'first', :last_class => 'last', :format => :html_list)) assert_equal('', renderer.render_crumbs([['name1', 'url1'], ['name2', 'url2'], ['name3', 'url3']], :li_class => "li_class", :first_class => 'first', :last_class => 'last', :format => :html_list, :separator => " / ")) assert_equal('name1name2', renderer.render_crumbs([['name1', 'url1'], ['name2', 'url2']], :first_class => 'first', :last_class => 'last', :format => :xml)) assert_equal('
', renderer.render_crumbs([['name', 'url']], :first_class => 'first', :last_class => 'last', :format => :html, :microdata => true)) assert_equal('', renderer.render_crumbs([['name', 'url']], :first_class => 'first', :last_class => 'last', :format => :html_list, :microdata => true)) end def test_configuration renderer = StandardRenderer.new # check defaults assert_equal " » ", Crummy.configuration.html_separator # adjust configuration Crummy.configure do |config| config.html_separator = " / " end assert_equal " / ", Crummy.configuration.html_separator end def test_configured_renderer renderer = StandardRenderer.new Crummy.configure do |config| config.html_separator = " / " end # using configured separator assert_equal('name1 / name2', renderer.render_crumbs([['name1', 'url1'], ['name2', 'url2']])) # overriding configured separator assert_equal('name1 | name2', renderer.render_crumbs([['name1', 'url1'], ['name2', 'url2']], :separator => " | ")) end def test_configured_renderer_with_microdata renderer = StandardRenderer.new Crummy.configure do |config| config.microdata = true end # using configured microdata setting assert_equal('
', renderer.render_crumbs([['name', 'url']], :first_class => 'first', :last_class => 'last', :format => :html)) end end