From 2bb393684baf5da1112923db7bcda920d606be78 Mon Sep 17 00:00:00 2001 From: Kazushige Tominaga Date: Thu, 8 Feb 2018 08:17:53 +0900 Subject: [PATCH] Added #link_header spec (#6439) --- spec/services/fetch_atom_service_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/services/fetch_atom_service_spec.rb b/spec/services/fetch_atom_service_spec.rb index 5491fd0279..fcba55e8d6 100644 --- a/spec/services/fetch_atom_service_spec.rb +++ b/spec/services/fetch_atom_service_spec.rb @@ -1,4 +1,24 @@ require 'rails_helper' RSpec.describe FetchAtomService do + describe '#link_header' do + context 'Link is Array' do + target = FetchAtomService.new + target.instance_variable_set('@response', 'Link' => [ + '; rel="up"; meta="bar"', + '; rel="self"', + ]) + + it 'set first link as link_header' do + expect(target.send(:link_header).links[0].href).to eq 'http://example.com/' + end + end + + context 'Link is not Array' do + target = FetchAtomService.new + target.instance_variable_set('@response', 'Link' => '; rel="self", ; rel = "up"') + + it { expect(target.send(:link_header).links[0].href).to eq 'http://example.com/foo' } + end + end end