# encoding: utf-8 require_relative 'common' describe 'Sanitize::Transformers::CleanDoctype' do make_my_diffs_pretty! parallelize_me! describe 'when :allow_doctype is false' do before do @s = Sanitize.new(:allow_doctype => false, :elements => ['html']) end it 'should remove doctype declarations' do @s.document('foo').must_equal "foo" @s.fragment('foo').must_equal 'foo' end it 'should not allow doctype definitions in fragments' do @s.fragment('foo') .must_equal "foo" @s.fragment('foo') .must_equal "foo" @s.fragment("foo") .must_equal "foo" end end describe 'when :allow_doctype is true' do before do @s = Sanitize.new(:allow_doctype => true, :elements => ['html']) end it 'should allow doctype declarations in documents' do @s.document('foo') .must_equal "foo" @s.document('foo') .must_equal "foo" @s.document("foo") .must_equal "foo" end it 'should not allow obviously invalid doctype declarations in documents' do @s.document('foo') .must_equal "foo" @s.document('foo') .must_equal "foo" @s.document('foo') .must_equal "foo" @s.document('foo') .must_equal "foo" end it 'should not allow doctype definitions in fragments' do @s.fragment('foo') .must_equal "foo" @s.fragment('foo') .must_equal "foo" @s.fragment("foo") .must_equal "foo" end end end