Sha256: d4fdbf67160dbf12826dece8aaf6674433695fd5c8120ddb13183eaa7ef0d1c8

Contents?: true

Size: 1.96 KB

Versions: 2

Compression:

Stored size: 1.96 KB

Contents

require 'rails_helper'

RSpec.describe ActiveAdmin::Views::Tabs do
  describe "creating with the dsl" do
    context "when creating tabs with a symbol" do
      before do
        expect(I18n).to receive(:t).at_least(:once).with(:tab_key).and_return "テスト"
      end

      let(:tabs) do
        render_arbre_component do
          tabs do
            tab :overview
            tab I18n.t(:tab_key), id: :something_unique, html_options: { class: :some_css_class }
          end
        end
      end

      let(:subject) { Capybara.string(tabs.to_s) }

      it "should create a tab navigation bar based on the symbol" do
        expect(subject).to have_content('Overview')
      end

      it "should have tab with id based on symbol" do
        expect(subject).to have_selector('div#overview')
      end

      it "should have link with fragment based on symbol" do
        expect(subject).to have_selector('a[href="#overview"]')
      end

      it "should handle translation" do
        expect(subject).to have_content('テスト')
      end

      it "should have tab with id based on options" do
        expect(subject).to have_selector('div#something_unique')
      end

      it "should have link with fragment based on options" do
        expect(subject).to have_selector('a[href="#something_unique"]')
      end

      it "should have li with specific css class" do
        expect(subject).to have_selector('li.some_css_class')
      end

    end

    context "when creating a tab with a block" do
      let(:tabs) do
        render_arbre_component do
          tabs do
            tab :overview do
              span 'tab 1'
            end
          end
        end
      end

      it "should create a tab navigation bar based on the symbol" do
        expect(tabs.find_by_tag('li').first.content).to include "Overview"
      end

      it "should create a tab with a span inside of it" do
        expect(tabs.find_by_tag('span').first.content).to eq('tab 1')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activeadmin-rb-1.6.0 spec/unit/views/components/tabs_spec.rb
activeadmin-rb-1.5.2 spec/unit/views/components/tabs_spec.rb