Sha256: 1569f144c7c60d398e56ca37c7f0f002ec6b49f34cf3a2e862c6522cb5d44ace

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'
require 'rexml/document'

describe "catalog/index" do

  before(:all) do
    @config = Blacklight::Configuration.new.configure do |config|
      config.default_solr_params = {
        :fl => '*',
        :rows => 10
      }
    end

    @params = { :content_format => 'marc', :f => { :format => ['Book'] }, :page => 2 }

    # run a solr query to get our data
    service = CatalogController.search_service_class.new(@config, @params)
    @response, _ = service.search_results
    @document_list = @response.documents
  end

  before(:each) do
    # Not sure what Assigns was doing here ... dhf
    #    assigns[:response] = @rsolr_response
    #    assigns[:document_list] = @document_list
    # not sure why we can't use assigns for 'params', instead this weird way,
    # but okay.

    params.merge!( @params )
    allow(view).to receive(:blacklight_config).and_return(@config)
    allow(view).to receive(:search_field_options_for_select).and_return([])

    render :template => 'catalog/index', :formats => [:atom]

    # We need to use rexml to test certain things that have_tag wont' test
    # note that response is depricated rails 3, use "redered" instead.
    @response_xml = REXML::Document.new(rendered)
  end

  describe "when content_format is specified" do
    describe "for an entry with content available" do
      before do
        @entry = @response_xml.elements.to_a("/feed/entry")[0]
      end
      it "should include a link rel tag" do
        expect(@entry.to_s).to have_selector("link[rel=alternate][type='application/marc']")
      end
      it "should have content embedded" do
        expect(@entry.to_s).to have_selector("content")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blacklight-marc-7.0.0.rc1 spec/views/catalog/index.atom.builder_spec.rb