<commit_before>require "spec_helper"

describe Pliny::Helpers::Serialize do
  context "without a serializer" do
    def app
      Sinatra.new do
        helpers Pliny::Helpers::Serialize

        get "/" do
          MultiJson.encode(serialize([]))
        end
      end
    end

    it "sets the Content-Type" do
      assert_raises(RuntimeError) do
        get "/"
      end
    end
  end

  context "with a serializer" do
    class Serializer
      def initialize(opts); end
      def serialize(data)
        data
      end
    end

    def app
      Sinatra.new do
        helpers Pliny::Helpers::Serialize

        serializer Serializer

        get "/" do
          MultiJson.encode(serialize([]))<commit_msg>Fix copy-paste mistake<commit_after>require "spec_helper"

describe Pliny::Helpers::Serialize do
  context "without a serializer" do
    def app
      Sinatra.new do
        helpers Pliny::Helpers::Serialize

        get "/" do
          MultiJson.encode(serialize([]))
        end
      end
    end

    it "raises a runtime error" do
      assert_raises(RuntimeError) do
        get "/"
      end
    end
  end

  context "with a serializer" do
    class Serializer
      def initialize(opts); end
      def serialize(data)
        data
      end
    end

    def app
      Sinatra.new do
        helpers Pliny::Helpers::Serialize

        serializer Serializer

        get "/" do
          MultiJson.encode(serialize([]))
{'fraction_non_alphanumeric': 0.07777777777777778, 'fraction_numerical': 0.0, 'mean_word_length': 1.9528688524590163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5754136', 'n_tokens_mistral': 418, 'n_tokens_neox': 414, 'n_words': 120}