Sha256: 2e526bbf0068db09c15eda0be08c11a1e1b5ac916e2f2be54dd73ea9e6cfbdf8

Contents?: true

Size: 1.54 KB

Versions: 7

Compression:

Stored size: 1.54 KB

Contents

require 'test_helper'

class ElementTest < ActiveSupport::TestCase

  def test_initialize_should_require_name
    assert_raise(ArgumentError) { BreadcrumbsOnRails::Breadcrumbs::Element.new }
    assert_nothing_raised { BreadcrumbsOnRails::Breadcrumbs::Element.new(nil) }
  end

  def test_initialize_should_set_name
    element = BreadcrumbsOnRails::Breadcrumbs::Element.new(:homepage, nil)
    assert_equal :homepage, element.name
  end

  def test_initialize_should_set_path
    element = BreadcrumbsOnRails::Breadcrumbs::Element.new(nil, "/")
    assert_equal "/", element.path
  end

  def test_initialize_should_allow_options
    element = BreadcrumbsOnRails::Breadcrumbs::Element.new(:homepage, "/", :title => "Go to the Homepage")
    assert_equal({ :title => "Go to the Homepage" }, element.options)
  end


  def test_name
    element = BreadcrumbsOnRails::Breadcrumbs::Element.new(nil, nil)
    element.name = :the_name
    assert_equal :the_name, element.name
  end

  def test_path
    element = BreadcrumbsOnRails::Breadcrumbs::Element.new(nil, nil)
    element.path = { :controller => "index", :action => "index" }
    assert_equal({ :controller => "index", :action => "index" }, element.path)
  end

  def test_options
    element = BreadcrumbsOnRails::Breadcrumbs::Element.new(nil, nil)
    element.options = { :title => "Go to the Homepage" }
    assert_equal({ :title => "Go to the Homepage" }, element.options)
  end
  
  def test_path_is_optional
    element = BreadcrumbsOnRails::Breadcrumbs::Element.new(:homepage)
    assert_nil element.path
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/breadcrumbs_on_rails-4.1.0/test/unit/element_test.rb
breadcrumbs_on_rails-4.1.0 test/unit/element_test.rb
breadcrumbs_on_rails-4.0.0 test/unit/element_test.rb
breadcrumbs_on_rails-3.0.1 test/unit/element_test.rb
breadcrumbs_on_rails-3.0.0 test/unit/element_test.rb
breadcrumbs_on_rails-2.3.1 test/unit/element_test.rb
breadcrumbs_on_rails-2.3.0 test/unit/element_test.rb