Sha256: 7016e63e9e40e412f741145e02c0ca646680edc44c57b2d4598722c592f7430b

Contents?: true

Size: 1.28 KB

Versions: 16

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'
require 'rspec/active_model/mocks'

describe Qbrick::BrickList do
  class TestBrick
    include Qbrick::BrickList
  end

  let :brick do
    TestBrick.new
  end

  describe '#collect_fulltext' do
    context 'with bricks' do
      it 'collects its childs fulltext' do
        result = [mock_model(Qbrick::Brick, collect_fulltext: 'hallo')]
        allow(brick).to receive_message_chain(:bricks, :localized).and_return(result)
        expect(brick.collect_fulltext).to eq('hallo')
      end
    end

    context 'with bricks without content' do
      it 'returns a string' do
        allow(brick).to receive_message_chain(:bricks, :localized).and_return([])
        expect(brick.collect_fulltext).to eq('')
      end
    end

    context 'without bricks' do
      it 'returns a string' do
        expect(brick.collect_fulltext).to eq('')
      end

      it 'does not fail' do
        expect { brick.collect_fulltext }.to_not raise_error
      end
    end
  end

  describe '#allowed_brick_types' do
    it 'returns an array of possible classes as strings' do
      expect(brick.allowed_brick_types).to be_a(Array)
    end
  end

  describe '#brick_types' do
    it 'returns a Qbrick::BrickTypeFilter' do
      expect(brick.brick_types).to be_a(Qbrick::BrickTypeFilter)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
qbrick-2.7.1 spec/lib/brick_list_spec.rb
qbrick-2.7 spec/lib/brick_list_spec.rb
qbrick-2.6.10 spec/lib/brick_list_spec.rb
qbrick-2.6.9 spec/lib/brick_list_spec.rb
qbrick-2.6.8 spec/lib/brick_list_spec.rb
qbrick-2.6.7 spec/lib/brick_list_spec.rb
qbrick-2.6.6 spec/lib/brick_list_spec.rb
qbrick-2.6.5 spec/lib/brick_list_spec.rb
qbrick-2.6.4 spec/lib/brick_list_spec.rb
qbrick-2.6.3 spec/lib/brick_list_spec.rb
qbrick-2.6.2 spec/lib/brick_list_spec.rb
qbrick-2.6.1 spec/lib/brick_list_spec.rb
qbrick-2.6.0 spec/lib/brick_list_spec.rb
qbrick-2.5.2 spec/lib/brick_list_spec.rb
qbrick-2.5.1 spec/lib/brick_list_spec.rb
qbrick-2.5.0 spec/lib/brick_list_spec.rb