Sha256: 61c8a14740ea9ed10c4e129230b74a6e550f68aa43215e0ee79543c295d50dcd

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require 'test_helper'

class BlockBuilderTest < ActionView::TestCase
  tests TabsOnRails::ActionController::HelperMethods

  include ActionView::Helpers::TagHelper
  include ActionView::Helpers::UrlHelper

  def current_tab(namespace)
    case namespace
      when nil, :default
        :dashboard
      when :foospace
        :footab
      else
        :elsetab
    end
  end

  class BlockBuilder < TabsOnRails::Tabs::TabsBuilder
    def tab_for(tab, name, options, item_options = {}, &block)
      item_options[:class] = item_options[:class].to_s.split(" ").push("current").join(" ") if current_tab?(tab)
      content  = @context.link_to(name, options)
      content += @context.capture(&block) if block_given?
      @context.content_tag(:li, content, item_options)
    end
  end

  def setup
    @klass    = BlockBuilder
    @builder  = @klass.new(self)
  end

  def test_tab_for_with_block
    expected = %Q{<li class="current"><a href="http://dashboard.com/">Foo Bar</a><p>More Content</p></li>}
    actual = @builder.tab_for(:dashboard, 'Foo Bar', 'http://dashboard.com/') do
      content_tag(:p, "More Content")
    end

    assert_dom_equal expected, actual
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tabs_on_rails-2.0.2 test/unit/tabs/block_builder_test.rb