Sha256: 6be927680efef9fae8fe7e7d36dbcfcefef1129899b84c86aa937fbdbcc1f73b
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true require "spec_helpers" describe Wayfarer::Networking::Follow do let(:page) { build(:page) } let(:url) { test_app_path("/foo") } let(:redirect_url) { test_app_path("/redirect") } let(:success) { Wayfarer::Networking::Result::Success.new(page) } let(:redirect) { Wayfarer::Networking::Result::Redirect.new(redirect_url) } let(:inner) { spy } subject(:outer) { described_class.new(inner) } describe "#fetch" do context "when context returns Success" do before { allow(inner).to receive(:fetch).and_return(success) } it "returns the page" do expect(outer.fetch(url)).to be(page) end end context "when context returns Redirect" do it "follows the redirect" do expect(inner).to receive(:fetch).with(url).and_return(redirect).ordered expect(inner).to receive(:fetch).with(redirect_url).and_return(success).ordered outer.fetch(url, follow: 2) end end context "with redirects exhausted" do it "raises" do allow(inner).to receive(:fetch).with(url).and_return(redirect) expect { outer.fetch(url, follow: 0) }.to raise_error(Wayfarer::Networking::RedirectsExhaustedError) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wayfarer-0.4.6 | spec/networking/follow_spec.rb |
wayfarer-0.4.5 | spec/networking/follow_spec.rb |
wayfarer-0.4.4 | spec/networking/follow_spec.rb |