Sha256: fbcd6468cb4682125ad5263daac5715debfda08e3479386c0246dbaa8773505a

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe Administrate::Field::BooleanEmoji do
  subject { Administrate::Field::BooleanEmoji.new(:boolean, data, :show) }

  describe '#to_partial_path' do
    let(:data) { true }

    it 'returns a partial based on the page being rendered' do
      path = subject.to_partial_path
      expect(path).to eq('/fields/boolean_emoji/show')
    end
  end

  describe '#lboolean' do
    let(:output) { subject.lboolean }

    context 'with default locale' do
      context 'when nil' do
        let(:data) { nil }

        it 'returns dash' do
          expect(output).to eq '–'
        end
      end

      context 'when true' do
        let(:data) { true }

        it 'returns the localized value' do
          expect(output).to eq '✅'
        end
      end

      context 'when false' do
        let(:data) { false }

        it 'returns the localized value' do
          expect(output).to eq '❌'
        end
      end
    end

    context 'with german locale' do
      around do |example|
        I18n.with_locale(:de) { example.run }
      end

      context 'when true' do
        let(:data) { true }

        it 'returns the localized value' do
          expect(output).to eq 'Ja'
        end
      end

      context 'when false' do
        let(:data) { false }

        it 'returns the localized value' do
          expect(output).to eq 'Nein'
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
administrate-field-boolean_emoji-0.3.0 spec/lib/administrate/field/boolean_emoji_spec.rb
administrate-field-boolean_emoji-0.2.1 spec/lib/administrate/field/boolean_emoji_spec.rb
administrate-field-boolean_emoji-0.2.0 spec/lib/administrate/field/boolean_emoji_spec.rb
administrate-field-boolean_emoji-0.1.0 spec/lib/administrate/field/boolean_emoji_spec.rb