Sha256: d0863976bd05194e70a9a52725fd902a2e109e6a9a5640c56b142c0171981166

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'
require 'fileutils'

describe Kuhsaft::PlaceholderBrick, type: :model do

  let :placeholder_brick do
    Kuhsaft::PlaceholderBrick.new
  end

  before do
    FileUtils.mkdir_p("#{Rails.root}/app/views/kuhsaft/placeholder_bricks/partials")
    FileUtils.touch("#{Rails.root}/app/views/kuhsaft/placeholder_bricks/partials/_valid_partial.html.haml")
    FileUtils.touch("#{Rails.root}/app/views/kuhsaft/placeholder_bricks/partials/not_a_partial.html.haml")
    FileUtils.touch("#{Rails.root}/app/views/kuhsaft/placeholder_bricks/partials/_not_a_haml_file.txt")
  end

  after do
    FileUtils.rm_rf(Dir.glob("#{Rails.root}/app/views/kuhsaft"))
  end

  describe 'available partials' do
    it 'returns haml files' do
      expect(Kuhsaft::PlaceholderBrick.available_partials.flatten).to include('valid_partial')
    end

    it 'returns only partials' do
      expect(Kuhsaft::PlaceholderBrick.available_partials.flatten).not_to include('not_a_partial')
    end

    it 'does not return other files' do
      expect(Kuhsaft::PlaceholderBrick.available_partials.flatten).not_to include('not_a_haml_file')
    end
  end

  describe '#bricks' do
    it 'can not have childs' do
      expect(placeholder_brick).not_to respond_to(:bricks)
    end
  end

  describe '#user_can_add_childs?' do
    it 'returns false' do
      expect(placeholder_brick.user_can_add_childs?).to be_falsey
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kuhsaft-2.6.3 spec/models/placeholder_brick_spec.rb
kuhsaft-2.6.2 spec/models/placeholder_brick_spec.rb
kuhsaft-2.6.1 spec/models/placeholder_brick_spec.rb
kuhsaft-2.5.2 spec/models/placeholder_brick_spec.rb
kuhsaft-2.6.0 spec/models/placeholder_brick_spec.rb
kuhsaft-2.5.1 spec/models/placeholder_brick_spec.rb
kuhsaft-2.5.0 spec/models/placeholder_brick_spec.rb