Sha256: b82c1a4bdcb87e64ce85ec4aafecffc6b6d3d61af0a31d872ab3e71119f48865

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'
require 'maltese/cli'

describe Maltese::CLI do
  let(:subject) do
    described_class.new
  end

  let(:from_date) { "2018-03-15" }
  let(:until_date) { "2018-04-08" }
  let(:sitemap_bucket) { "sitemaps-search-datacite-test" }
  let(:cli_options) { { sitemap_bucket: sitemap_bucket,
                        from_date: from_date,
                        until_date: until_date } }

  describe "sitemap", vcr: true, :order => :defined do
    it 'should succeed' do
      subject.options = cli_options
      expect { subject.sitemap }.to output(/266 links/).to_stdout
      sitemap = Zlib::GzipReader.open("public/sitemaps-test/sitemap.xml.gz") { |gz| gz.read }
      doc = Nokogiri::XML(sitemap)
      expect(doc.xpath("//xmlns:url").size).to eq(266)
      expect(doc.xpath("//xmlns:loc").last.text).to eq("https://search.test.datacite.org/works/10.0133/37522")
    end

    it 'should succeed with no works' do
      from_date = "2005-04-07"
      until_date = "2005-04-08"
      subject.options = { sitemap_bucket: sitemap_bucket,
                          from_date: from_date,
                          until_date: until_date }
      expect { subject.sitemap }.to output("No works found for date range 2005-04-07 - 2005-04-08.\n").to_stdout
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
maltese-0.2 spec/cli_spec.rb