Sha256: 2e31020e07635e924a16bbfefbd2b303d3d39dc2841e180350e81031e495a0ef

Contents?: true

Size: 1.58 KB

Versions: 34

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::Content.define_block_types", config)
        assert_match("block_type 'Code Snippet'", config)
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.45 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.44 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.43 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.42 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.41 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.40 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.39 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.38 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.37 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.36 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.35 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.34 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.33 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.32 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.31 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.30 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.29 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.28 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.27 test/generators/workarea/content_block_type_generator_test.rb
workarea-core-3.4.26 test/generators/workarea/content_block_type_generator_test.rb