Sha256: 89a21d029d9580848ea8bc5720b2437a35b7ac1fbb3d638f735d1385821d9f33

Contents?: true

Size: 1.95 KB

Versions: 5

Compression:

Stored size: 1.95 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
    c = CatalogController.new
    c.blacklight_config = @config
    @response, @document_list = c.search_results(@params)

    # munge the solr response to match test expectations
    @document_list[1] = SolrDocument.new(@document_list[1].with_indifferent_access.reject! { |k,v| k == "author_display" })
    @document_list[5] = SolrDocument.new(@document_list[1].with_indifferent_access.reject! { |k,v| k == "marc_display" })
  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

5 entries across 5 versions & 1 rubygems

Version Path
blacklight-marc-6.3.0 spec/views/catalog/index.atom.builder_spec.rb
blacklight-marc-6.2.0 spec/views/catalog/index.atom.builder_spec.rb
blacklight-marc-6.1.1 spec/views/catalog/index.atom.builder_spec.rb
blacklight-marc-6.1.0 spec/views/catalog/index.atom.builder_spec.rb
blacklight-marc-6.0.0 spec/views/catalog/index.atom.builder_spec.rb