Sha256: 4488e3c8ee45a45ba3763d4b9108c3a6a2bd17785d953fa936e95392aa2e6249

Contents?: true

Size: 1.86 KB

Versions: 9

Compression:

Stored size: 1.86 KB

Contents

require 'spec_helper'

module Alchemy
  describe "ActsAsEssence" do
    let(:element) { Element.new }
    let(:content) { Content.new(name: 'foo') }
    let(:essence) { EssenceText.new }
    let(:content_description) { {'name' => 'foo'} }

    describe '#description' do
      subject { essence.description }

      context 'without element' do
        it { should eq({}) }
      end

      context 'with element' do
        before { essence.stub(element: element) }

        context 'but without content descriptions' do
          it { should eq({}) }
        end

        context 'and content descriptions' do
          before do
            essence.stub(content: content)
          end

          context 'containing the content name' do
            before { element.stub(content_descriptions: [content_description]) }

            it "returns the content description" do
              should eq(content_description)
            end
          end

          context 'not containing the content name' do
            before { element.stub(content_descriptions: []) }

            it { should eq({}) }
          end
        end
      end
    end

    describe '#ingredient=' do
      it 'should set the value to ingredient column' do
        essence.ingredient = 'Hallo'
        expect(essence.ingredient).to eq('Hallo')
      end
    end

    describe '#open_link_in_new_window?' do

      subject { essence.open_link_in_new_window? }

      context 'essence responds to link_taget' do
        context 'if link_target attribute is set to "blank"' do

          before { essence.link_target = 'blank' }

          it "should return true" do
            expect(subject).to eq(true)
          end
        end

        context 'if link_target attribute is not "blank"' do
          it "should return false" do
            expect(subject).to eq(false)
          end
        end
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
alchemy_cms-2.9.1 spec/libraries/essence_spec.rb
alchemy_cms-2.9.0 spec/libraries/essence_spec.rb
alchemy_cms-2.8.3 spec/libraries/essence_spec.rb
alchemy_cms-2.7.5 spec/libraries/essence_spec.rb
alchemy_cms-2.7.4 spec/libraries/essence_spec.rb
alchemy_cms-2.8.2 spec/libraries/essence_spec.rb
alchemy_cms-2.8.1 spec/libraries/essence_spec.rb
alchemy_cms-2.7.3 spec/libraries/essence_spec.rb
alchemy_cms-2.7.2 spec/libraries/essence_spec.rb