File: fetcher_spec.rb

package info (click to toggle)
ruby-open-graph-reader 0.7.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 9,988 kB
  • sloc: ruby: 1,525; xml: 22; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 629 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
require "spec_helper"

RSpec.describe OpenGraphReader::Fetcher do
  let(:uri) { URI("http://example.org") }
  let(:fetcher) { described_class.new uri }
  let(:good_response) { {status: 200, body: "", headers: {"Content-Type" => "text/html"}} }

  context "error during body fetch" do
    before do
      stub_request(:head, uri).to_return(good_response)
      stub_request(:get, uri).to_raise(Faraday::ConnectionFailed.new("execution expired"))
    end

    describe "#body" do
      it "raises" do
        expect { fetcher.body }.to raise_error OpenGraphReader::NoOpenGraphDataError, /response body/
      end
    end
  end
end