# frozen_string_literal: true # This file is part of Alexandria. # # See the file README.md for authorship and licensing information. require "spec_helper" RSpec.describe Alexandria::BookProviders::WorldCatProvider do let(:sky_catalog_main) do <<~XHTML
XHTML end let(:sky_catalog_details) do <<~XHTML

Sky catalogue 2000.0 ed. by Alan Hirshfeld and Roger W. Sinnott

Author: Hirshfeld Alan; Sinnott Roger W.; Cambridge Cambridge University Press 1982-
Publisher: 1982
All Authors / Contributors: Hirshfeld Alan; Sinnott Roger W.; Cambridge Cambridge University Press 1982-
ISBN: 0521247101 9780521247108 0521289130 9780521289139 0521258189 9780521258180
XHTML end let(:florence_ru_details) do <<~XHTML

Флоренс Аравийская : роман /
Florens Araviĭskai︠a︡ : roman

Author: Кристофер Бакли ; перевод с английского Андрея Геласимова. Геласимов, Андрей. ; Christopher Buckley; Andreĭ Gelasimov
Publisher: Иностранка, Moskva : Inostranka, 2006.
All Authors / Contributors: Кристофер Бакли ; перевод с английского Андрея Геласимова. Геласимов, Андрей. ; Christopher Buckley; Andreĭ Gelasimov
ISBN: 5941454139 9785941454136
XHTML end it "works for an isbn with multiple results" do stub_request(:get, "https://www.worldcat.org/search?q=isbn:9780521247108&qt=advanced") .to_return(status: 200, body: +sky_catalog_main, headers: {}) stub_request(:get, "https://www.worldcat.org/title/" \ "sky-catalogue-20000-ed-by-alan-hirshfeld-and-roger-w-sinnott" \ "/oclc/476534140&referer=brief_results") .to_return(status: 200, body: +sky_catalog_details, headers: {}) assert_correct_search_result(described_class, "9780521247108") end it "works with vernacular" do stub_request(:get, "https://www.worldcat.org/search?q=isbn:9785941454136&qt=advanced") .to_return(status: 200, body: +florence_ru_details, headers: {}) assert_correct_search_result(described_class, "9785941454136") end it "works with multiple authors" do stub_request(:get, "https://www.worldcat.org/search?q=isbn:9785941454136&qt=advanced") .to_return(status: 200, body: +florence_ru_details, headers: {}) results = assert_correct_search_result(described_class, "9785941454136") this_book = results.first expect(this_book.authors).to be_instance_of(Array), "Not an array!" expect(this_book.authors.length).to eq(2), "Wrong number of authors for this book!" end end