Sha256: 97213e4fbb6305099f2e217bd087157dd1f332909fbb1a480500c2f48764d780

Contents?: true

Size: 947 Bytes

Versions: 8

Compression:

Stored size: 947 Bytes

Contents

require 'spec_helper'

describe Locomotive::Steam::Models::I18nField do

  let(:name)          { 'title' }
  let(:translations)  { nil }
  let(:field)         { described_class.new(name, translations) }

  describe '#blank?' do

    subject { field.blank? }

    it { is_expected.to eq true }

    context 'with translations' do

      let(:translations) { { en: 'Hello world', fr: nil } }

      it { is_expected.to eq false }

    end

  end

  describe '#dup' do

    let(:translations) { { en: 'Hello world', fr: nil } }

    subject { field.dup }

    it 'gets a fresh copy of the translations' do
      expect(subject[:en]).to eq 'Hello world'
      expect(subject.translations.object_id).not_to eq field.translations.object_id
    end

  end

  describe '#to_json' do

    let(:translations) { { en: 'Hello world', fr: nil } }

    subject { field.to_json }

    it { is_expected.to eq("{\"en\":\"Hello world\",\"fr\":null}") }

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
locomotivecms_steam-1.3.0.rc2 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.2.1 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.3.0.rc1 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.2.0 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.2.0.rc3 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.2.0.rc2 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.2.0.rc1 spec/unit/models/i18n_field_spec.rb
locomotivecms_steam-1.2.0.beta1 spec/unit/models/i18n_field_spec.rb