File: test_cases_spec.rb

package info (click to toggle)
ruby-open-graph-reader 0.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 272 kB
  • sloc: ruby: 1,588; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 1,308 bytes parent folder | download
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
30
31
32
33
34
35
36
37
38
39
40
41
42
require "spec_helper"

RSpec.describe "test cases" do
  describe "image_alt_before_image" do
    it "parses" do
      expect {
        OpenGraphReader.parse! fixture_html "test_cases/image_alt_before_image"
      }.not_to raise_error
    end

    it "returns the data" do
      object = OpenGraphReader.parse!(fixture_html("test_cases/image_alt_before_image"))
      expect(object.og.image.content).to eq "https://example.com/example.png"
      expect(object.og.image.alt).to eq "image:alt"
    end
  end

  describe "missing_image" do
    it "parses" do
      expect {
        OpenGraphReader.parse! fixture_html "test_cases/missing_image"
      }.not_to raise_error
    end

    it "returns the data" do
      object = OpenGraphReader.parse!(fixture_html("test_cases/missing_image"))
      expect(object.og.image.content).to be_nil
      expect(object.og.image.url).to eq "https://example.com/example.png"
    end

    context "with image content synthesization enabled" do
      before do
        OpenGraphReader.config.synthesize_image_content = true
      end

      it "returns the synthesized image content" do
        object = OpenGraphReader.parse!(fixture_html("test_cases/missing_image"))
        expect(object.og.image.content).to eq "https://example.com/example.png"
      end
    end
  end
end