Sha256: 97e8eea1e7568c77af6a49fe12e4afcac3e520a17ae0925cd5b71da3d7a02cae

Contents?: true

Size: 1.2 KB

Versions: 9

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe 'Tabbed areas', :type => :helper do
  
  def tabbed_area(opts = {})
    result = helper.tabbed do |tab|
      tab.panel('First Tab', opts) do
        "First tab content"
      end
      tab.panel('Second Tab') do
        "Second tab content"
      end
    end
    result.to_s
  end
  
  let(:result) do
    tabbed_area
  end
  
  it 'adds a .tabbed method' do
    helper.respond_to?(:tabbed).should be_true
  end
  
  describe 'navigation' do
    
    it 'renders a list item for each tab' do
      result.should have_selector('ul > li', :count => 2)
    end
    
    it 'renders a section.tab for each tab' do
      result.should have_selector('section.tab', :count => 2)
    end
    
    context 'when no id is passed to the panel' do
      
      it 'sets the links href to a id formatted string of the title' do
        result.should have_xpath('//a', :href => '#first_tab')
      end
      
    end
    
    context 'when an id is passed to the panel' do
      
      let(:result) do
        tabbed_area(:id => 'tab1')
      end
      
      it 'sets the links href to match the id' do
        result.should have_xpath('//a', :href => '#tab1')
      end
      
    end
    
  end
  
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
facades-1.1.0 spec/unit/patterns/tabs_spec.rb
facades-1.0.9 spec/unit/patterns/tabs_spec.rb
facades-1.0.8 spec/unit/patterns/tabs_spec.rb
facades-1.0.6 spec/unit/patterns/tabs_spec.rb
facades-1.0.4 spec/unit/patterns/tabs_spec.rb
facades-1.0.3 spec/unit/patterns/tabs_spec.rb
facades-1.0.2 spec/unit/patterns/tabs_spec.rb
facades-1.0.1 spec/unit/patterns/tabs_spec.rb
facades-1.0.0 spec/unit/patterns/tabs_spec.rb