Sha256: c95e5b747fc3c42ab2b58b9c6a3ce098ab12a862f2db915a1bb9b18b35cfb44c

Contents?: true

Size: 1.58 KB

Versions: 5

Compression:

Stored size: 1.58 KB

Contents

require 'test_helper'

require_relative '../../../lib/nesta/static/assets'

describe 'Assets' do
  include TestConfiguration

  after do
    remove_temp_directory
  end

  it 'is happy if attachments directory not present' do
    in_temporary_project do |project_root|
      stub_config('content' => File.join(project_root, 'content')) do
        Nesta::Static::Assets.new('dist').copy_attachments
      end
    end
  end

  it 'copies attachments into build directory' do
    build_dir = 'dist'
    attachment = 'image.jpeg'

    in_temporary_project do |project_root|
      stub_config('content' => File.join(project_root, 'content')) do
        FileUtils.mkdir_p(Nesta::Config.attachment_path)
        open(File.join(Nesta::Config.attachment_path, attachment), 'w')

        Nesta::Static::Assets.new(build_dir).copy_attachments

        assert_exists_in_project File.join(build_dir, 'attachments', attachment)
      end
    end
  end

  it 'is happy if public directory not present' do
    in_temporary_project do |project_root|
      Nesta::Static::Assets.new('dist').copy_public_folder
    end
  end

  it 'copies contents of public directory into build directory' do
    build_dir = 'dist'
    asset_path = File.join('css', 'third-party.css')

    in_temporary_project do |project_root|
      public_path = File.join(project_root, 'public')
      FileUtils.mkdir_p(File.dirname(File.join(public_path, asset_path)))
      open(File.join(public_path, asset_path), 'w')

      Nesta::Static::Assets.new(build_dir).copy_public_folder

      assert_exists_in_project File.join(build_dir, asset_path)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nesta-0.18.0 test/unit/static/assets_test.rb
nesta-0.17.0 test/unit/static/assets_test.rb
nesta-0.16.0 test/unit/static/assets_test.rb
nesta-0.15.0 test/unit/static/assets_test.rb
nesta-0.14.0 test/unit/static/assets_test.rb