Sha256: ce6f85f813c5ae9be70303d0fe354d16a7043eb0e9acbc61a74490624f0242d1

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

require 'test_helper'

class BuoysHelerTest < ActionView::TestCase
  include Buoys::Helper

  test '.buoy (only current)' do
    assert respond_to?(:breadcrumb)

    buoy :account
    html = render('breadcrumbs/buoys').gsub(/[[:space:]]{2,}|\n/, '')

    assert_dom_equal %{<ul><li><a class="active" href=""><span>Account</span></a></li></ul>}, html
  end

  test '.buoy (not only active)' do
    buoy :history
    html = render('breadcrumbs/buoys').gsub(/[[:space:]]{2,}|\n/, '')

    assert_dom_equal %{<ul><li><a class="hover" href="/about"><span>about</span></a><span>&gt;</span></li><li><a class="active" href=""><span>history</span></a></li></ul>}, html
  end

  test '.buoy (has 2 `link`s in one buoy block)' do
    breadcrumb :help, true
    html = render('breadcrumbs/buoys').gsub(/[[:space:]]{2,}|\n/, '')

    assert_dom_equal %{<ul><li><a class="hover" href="https://example.com/help"><span>help</span></a><span>&gt;</span></li><li><a class="active" href=""><span>usage</span></a></li></ul>}, html
  end

  test '.buoy (receive multiple arguments)' do
    breadcrumb :edit_book_author, 1, 2
    html = render('breadcrumbs/buoys').gsub(/[[:space:]]{2,}|\n/, '')

    assert_dom_equal %{<ul><li><a class="hover" href="http://example.com/books"><span>Books</span></a><span>&gt;</span></li><li><a class="active" href="http://example.com/books/1/authors/2"><span>edit-1-2</span></a></li></ul>}, html
  end

  test ".buoy (has configuration options in link's arguments)" do
    breadcrumb :show_books, 1
    html = render('breadcrumbs/buoys').gsub(/[[:space:]]{2,}|\n/, '')

    assert_dom_equal %{<ul><li><a class="hover" href="http://example.com/books"><span>Books</span></a><span>&gt;</span></li><li><a class="active" href="http://example.com/books/1"><span>show-1</span></a></li></ul>}, html
  end

  test '.buoys (no given key)' do
    buoys
    html = render('breadcrumbs/buoys').gsub(/[[:space:]]{2,}|\n/, '')

    assert_dom_equal '', html
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buoys-0.2.0 test/buoys_helper_test.rb