# frozen_string_literal: true require 'spec_helper' RSpec.describe CKEditor5::Rails::Assets::AssetsBundleHtmlSerializer do let(:test_bundle_class) do Class.new(CKEditor5::Rails::Assets::AssetsBundle) do attr_accessor :scripts, :stylesheets def initialize(scripts, stylesheets) @scripts = scripts @stylesheets = stylesheets super() end end end let(:bundle) { test_bundle_class.new(scripts, stylesheets) } let(:scripts) do [ CKEditor5::Rails::Assets::JSUrlImportMeta.new( 'https://cdn.com/script1.js', window_name: 'CKEditor5' ), CKEditor5::Rails::Assets::JSUrlImportMeta.new( 'https://cdn.com/script2.js', import_name: '@ckeditor/script2' ) ] end let(:stylesheets) { ['https://cdn.com/style1.css', 'https://cdn.com/style2.css'] } let(:preloads) { bundle.preloads } subject(:serializer) { described_class.new(bundle) } describe '#initialize' do context 'with invalid bundle' do let(:bundle) { 'not a bundle' } it 'raises TypeError' do expect { serializer }.to raise_error(TypeError, 'bundle must be an instance of AssetsBundle') end end end describe '#to_html' do subject(:html) { serializer.to_html } it 'includes window scripts' do expect(html).to include( '