File: examples_spec.rb

package info (click to toggle)
ruby-html2text 0.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 196 kB
  • ctags: 19
  • sloc: ruby: 190; makefile: 8
file content (29 lines) | stat: -rw-r--r-- 748 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require "spec_helper"

describe Html2Text do
  describe "#convert" do
    let(:text) { Html2Text.convert(html) }

    examples = Dir[File.dirname(__FILE__) + "/examples/*.html"]

    examples.each do |filename|
      context "#{filename}" do
        let(:html) { File.read(filename) }
        let(:text_file) { filename.sub(".html", ".txt") }
        let(:expected) { Html2Text.fix_newlines(File.read(text_file)) }

        it "has an expected output" do
          expect(File.exist?(text_file)).to eq(true), "'#{text_file}' did not exist"
        end

        it "converts to text" do
          expect(text).to eq(expected)
        end
      end
    end

    it "has examples to test" do
      expect(examples.size).to_not eq(0)
    end
  end
end