-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
19 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
describe SolrDocument do | ||
|
||
before(:each) do | ||
|
||
@solrdoc = SolrDocument.new :id => '00282214', :format => ['Book'], :title_display => 'some-title' | ||
|
||
end | ||
|
||
describe "new" do | ||
it "takes a Hash as the argument" do | ||
expect { SolrDocument.new(:id => 1) }.not_to raise_error | ||
end | ||
end | ||
|
||
RSpec.describe SolrDocument do | ||
describe "access methods" do | ||
|
||
it "has the right value for title_display" do | ||
expect(@solrdoc[:title_display]).not_to be_nil | ||
let(:solrdoc) do | ||
SolrDocument.new(id: '00282214', format: ['Book'], title_display: 'some-title') | ||
end | ||
|
||
it "has the right value for format" do | ||
expect(@solrdoc[:format][0]).to eq 'Book' | ||
|
||
describe "#[]" do | ||
subject { solrdoc[field] } | ||
|
||
context "with title_display" do | ||
let(:field) { :title_display } | ||
it { is_expected.to eq 'some-title' } | ||
end | ||
context "with format" do | ||
let(:field) { :format } | ||
it { is_expected.to eq ['Book'] } | ||
end | ||
end | ||
|
||
it "provides the item's solr id" do | ||
expect(@solrdoc.id).to eq '00282214' | ||
describe "#id" do | ||
subject { solrdoc.id } | ||
it { is_expected.to eq '00282214' } | ||
end | ||
end | ||
end | ||
end |