<commit_before>require "spec_helper"

describe Pandago do
  it "has a version number" do
    expect(Pandago::VERSION).not_to be nil
  end

  describe ".url" do
    before { @old_url = Pandago.class_variable_get(:@@url) }
    after { Pandago.class_variable_set(:@@url, @old_url) }

    it "should be able to get and set url" do
      described_class.url = "https://example.com"
      expect(described_class.url).to eq URI("https://example.com")
    end
  end

  describe ".convert" do
    let(:source) { StringIO.new("<h1>Hello, World!</h1><p>This is a paragraph</p>") }

    it "returns an IO object with the result" do
      converted = described_class.convert(source, from: :html, to: :markdown)
      expect(converted.read).to eq "Hello, World!\n=============\n\nThis is a paragraph\n"
    end

    describe "with actual files" do
      let(:source_markdown) { SPEC_ROOT.join("fixtures/source.md").open }
      let(:source_html) { SPEC_ROOT.join("fixtures/source.html").open }
      let(:source_docx) { SPEC_ROOT.join("fixtures/source.docx").open }

      let(:expect_markdown) { SPEC_ROOT.join("fixtures/expect.md").open }
      let(:expect_html) { SPEC_ROOT.join("fixtures/expect.html").open }
      let(:expect_docx) { SPEC_ROOT.join("fixtures/expect.docx").open }

      context "when converting from html" do
        it "should convert to html" do
          converted = described_class.convert(source_html, from: :html, to: :html)
          expect(converted.read).to eq expect_html.read
        end

        it "should convert to markdown" do
          converted = described_class.convert(source_html, from: :html, to: :markdown)
          expect(converted.read).to eq expect_markdown.read
        end
      end

      context "when converting from markdown" do
        it "should convert to html" do
          converted = described_class.convert(source_markdown, from: :markdown, to: :html)
          expect(converted.read).to eq expect_html.read
        end

        it "should convert to markdown" do
          converted = described_class.convert(source_markdown, from: :markdown, to: :markdown)
          expect(converted.read).to eq expect_markdown.read
        end
      end

      context "when converting from docx" do
        it "should convert to html" do
          converted = described_class.convert(source_docx, from: :docx, to: :html)
          expect(converted.read).to eq expect_html.read
        end

        it "should convert to markdown" do
          converted = described_class.convert(source_docx, from: :docx, to: :markdown)
          expect(converted.read).to eq expect_markdown.read
        end
      end
    end
  end
end
<commit_msg>adds stubs for unimplemented specs<commit_after>require "spec_helper"

describe Pandago do
  it "has a version number" do
    expect(Pandago::VERSION).not_to be nil
  end

  describe ".url" do
    before { @old_url = Pandago.class_variable_get(:@@url) }
    after { Pandago.class_variable_set(:@@url, @old_url) }

    it "should be able to get and set url" do
      described_class.url = "https://example.com"
      expect(described_class.url).to eq URI("https://example.com")
    end
  end

  describe ".convert" do
    let(:source) { StringIO.new("<h1>Hello, World!</h1><p>This is a paragraph</p>") }

    it "takes and IO object and returns an IO object with the result" do
      converted = described_class.convert(source, from: :html, to: :markdown)
      expect(converted.read).to eq "Hello, World!\n=============\n\nThis is a paragraph\n"
    end

    describe "with actual files" do
      let(:source_markdown) { SPEC_ROOT.join("fixtures/source.md").open }
      let(:source_html) { SPEC_ROOT.join("fixtures/source.html").open }
      let(:source_docx) { SPEC_ROOT.join("fixtures/source.docx").open }

      let(:expect_markdown) { SPEC_ROOT.join("fixtures/expect.md").open }
      let(:expect_html) { SPEC_ROOT.join("fixtures/expect.html").open }
      let(:expect_docx) { SPEC_ROOT.join("fixtures/expect.docx").open }

      context "when converting from html" do
        it "should convert to html" do
          converted = described_class.convert(source_html, from: :html, to: :html)
          expect(converted.read).to eq expect_html.read
        end

        it "should convert to markdown" do
          converted = described_class.convert(source_html, from: :html, to: :markdown)
          expect(converted.read).to eq expect_markdown.read
        end

        it "should convert to docx" # TODO: figure out how to implement this
      end

      context "when converting from markdown" do
        it "should convert to html" do
          converted = described_class.convert(source_markdown, from: :markdown, to: :html)
          expect(converted.read).to eq expect_html.read
        end

        it "should convert to markdown" do
          converted = described_class.convert(source_markdown, from: :markdown, to: :markdown)
          expect(converted.read).to eq expect_markdown.read
        end

        it "should convert to docx" # TODO: figure out how to implement this
      end

      context "when converting from docx" do
        it "should convert to html" do
          converted = described_class.convert(source_docx, from: :docx, to: :html)
          expect(converted.read).to eq expect_html.read
        end

        it "should convert to markdown" do
          converted = described_class.convert(source_docx, from: :docx, to: :markdown)
          expect(converted.read).to eq expect_markdown.read
        end

        it "should convert to docx" # TODO: figure out how to implement this
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.11148708815672306, 'fraction_numerical': 0.0007123775601068567, 'mean_word_length': 2.8784530386740332, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 4, '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': '1162516', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1684, 'n_words': 465}