File: fetcher_spec.rb

package info (click to toggle)
ruby-open-graph-reader 0.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 272 kB
  • sloc: ruby: 1,588; makefile: 2
file content (21 lines) | stat: -rw-r--r-- 666 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
require "spec_helper"

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

  context "with an error during body fetch" do
    before do
      stub_request(:head, host).to_return(good_response)
      stub_request(:get, host).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