<commit_before>require 'spec_helper'

describe Muddle::Filter::BoilerplateStyleElement do
  let(:f) { Muddle::Filter::BoilerplateStyleElement }

  it "can parse full documents" do
    output = f.filter(minimal_email_body)

    xpath(output, 'html/body/style').count.should eql(2)
  end

  it "inserts a <body> element if missing" do
    output = f.filter('<html><body>woot</body></html>')
    output.should have_xpath('html/body')
  end

  it "inserts a style declaration for non-inlined styles if <body> found" do
    f.filter('<html><body></body></html>').should have_xpath('html/body/style')
  end
end<commit_msg>Only insert ONE style tag.<commit_after>require 'spec_helper'

describe Muddle::Filter::BoilerplateStyleElement do
  let(:f) { Muddle::Filter::BoilerplateStyleElement }

  it "can parse full documents" do
    output = f.filter(minimal_email_body)

    xpath(output, 'html/body/style').count.should eql(1)
  end

  it "inserts a <body> element if missing" do
    output = f.filter('<html><body>woot</body></html>')
    output.should have_xpath('html/body')
  end

  it "inserts a style declaration for non-inlined styles if <body> found" do
    f.filter('<html><body></body></html>').should have_xpath('html/body/style')
  end
end
{'fraction_non_alphanumeric': 0.14216867469879518, 'fraction_numerical': 0.001606425702811245, 'mean_word_length': 4.663636363636364, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1681956', 'n_tokens_mistral': 427, 'n_tokens_neox': 406, 'n_words': 99}