Sha256: c5ec8cd096486e1263cd35216810ba38090cd6fb191d3fd913b02d4d69688437

Contents?: true

Size: 1.58 KB

Versions: 28

Compression:

Stored size: 1.58 KB

Contents

require 'test_helper'
require 'generators/workarea/content_block_type/content_block_type_generator'

module Workarea
  class ContentBlockTypeGeneratorTest < GeneratorTest
    tests Workarea::ContentBlockTypeGenerator
    destination Dir.mktmpdir

    setup do
      prepare_destination

      FileUtils.mkdir_p "#{destination_root}/config/initializers"
      File.open "#{destination_root}/config/initializers/workarea.rb", 'w' do |file|
        file.write "Workarea.configure do |config|\n\nend"
      end

      run_generator %w(CodeSnippet)
    end

    def test_create_storefront_view
      assert_file 'app/views/workarea/storefront/content_blocks/_code_snippet.html.haml'
    end

    def test_create_stylesheet
      assert_file 'app/assets/stylesheets/workarea/storefront/components/_code_snippet_block.scss'
      assert_file 'config/initializers/workarea.rb' do |stylesheet|
        assert_match("workarea/storefront/components/_code_snippet", stylesheet)
      end
    end

    def test_create_block_icon
      assert_file 'app/assets/images/workarea/admin/content_block_types/code_snippet.svg'
    end

    def test_create_view_model
      assert_file 'app/view_models/workarea/storefront/content_blocks/code_snippet_view_model.rb' do |view_model|
        assert_match("class CodeSnippetViewModel", view_model)
      end
    end

    def test_update_configuration
      assert_file 'config/initializers/workarea_content_block_types.rb' do |config|
        assert_match("Workarea.define_content_block_types", config)
        assert_match("block_type 'Code Snippet'", config)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.26 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.25 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.23 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.22 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.21 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.20 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.19 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.18 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.17 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.16 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.15 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.14 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.13 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.12 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.11 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.10 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.9 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.8 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.5.7 test/generators/workarea/content_block_type_generator_test.rb