solr_ead 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
3
2
  require "rspec/core/rake_task"
4
- require "jettywrapper"
5
3
  Bundler::GemHelper.install_tasks
4
+
6
5
  # load rake tasks in lib/tasks
7
6
  Dir.glob('lib/tasks/*.rake').each { |r| import r }
7
+
8
8
  RSpec::Core::RakeTask.new(:spec)
9
- task :default => :ci
9
+ task :default => :ci
@@ -123,13 +123,13 @@ class Indexer
123
123
  # Determines the url to our solr service by consulting yaml files
124
124
  def solr_url
125
125
  if defined?(Rails.root)
126
- YAML.load(ERB.new(File.read(File.join(Rails.root,"config","solr.yml"))).result)[Rails.env]['url']
126
+ ::YAML.load(ERB.new(File.read(File.join(Rails.root,"config","solr.yml"))).result)[Rails.env]['url']
127
127
  elsif ENV['RAILS_ENV']
128
- YAML.load(ERB.new(File.read("config/solr.yml")).result)[ENV['RAILS_ENV']]['url']
128
+ ::YAML.load(ERB.new(File.read("config/solr.yml")).result)[ENV['RAILS_ENV']]['url']
129
129
  else
130
- YAML.load(ERB.new(File.read("config/solr.yml")).result)['development']['url']
130
+ ::YAML.load(ERB.new(File.read("config/solr.yml")).result)['development']['url']
131
131
  end
132
132
  end
133
133
 
134
134
  end
135
- end
135
+ end
@@ -1,3 +1,3 @@
1
1
  module SolrEad
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
3
3
  end
data/lib/solr_ead.rb CHANGED
@@ -3,6 +3,10 @@ require 'solrizer'
3
3
  require 'om'
4
4
  require 'rsolr'
5
5
  require 'active_support'
6
+ require 'yaml'
7
+
8
+ # Load these rake tasks when the gem is included in a Rails application
9
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),"../tasks/*.rake"))].each { |ext| load ext } if defined?(Rake)
6
10
 
7
11
  module SolrEad
8
12
  extend ActiveSupport::Autoload
@@ -13,9 +17,8 @@ module SolrEad
13
17
  autoload :Indexer
14
18
  autoload :Document
15
19
  autoload :Component
16
- autoload :Railtie if defined?(Rails)
17
20
 
18
21
  def self.version
19
22
  SolrEad::VERSION
20
23
  end
21
- end
24
+ end
@@ -0,0 +1,9 @@
1
+ require 'jettywrapper'
2
+ Jettywrapper.url = "https://github.com/awead/solr-jetty/archive/v1.zip"
3
+
4
+ desc "Travis continuous integration task"
5
+ task :ci do
6
+ Rake::Task["jetty:clean"].invoke
7
+ Rake::Task["jetty:start"].invoke
8
+ Rake::Task["spec"].invoke
9
+ end
data/solr_ead.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
12
12
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
+ gem.test_files = gem.files.grep(%r{^(spec)/})
14
14
  gem.name = "solr_ead"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = SolrEad::VERSION
@@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
26
26
  gem.add_development_dependency 'redcarpet'
27
27
  gem.add_development_dependency 'rake'
28
28
  gem.add_development_dependency 'rspec'
29
- gem.add_development_dependency 'debugger'
29
+ gem.add_development_dependency 'byebug'
30
30
  gem.add_development_dependency 'rdoc'
31
31
  gem.add_development_dependency 'jettywrapper'
32
32
  end
@@ -2,51 +2,42 @@ require "spec_helper"
2
2
 
3
3
  describe SolrEad::Behaviors do
4
4
 
5
- before :all do
6
- @not_numbered = fixture "ARC-0005.xml"
7
- @numbered = fixture "pp002010.xml"
8
- @messy = fixture "ead_messy_format.xml"
9
- class TestClass
10
- include SolrEad::Behaviors
11
- end
12
- @test = TestClass.new
5
+ class TestClass
6
+ include SolrEad::Behaviors
13
7
  end
14
8
 
15
9
  describe "#components" do
16
10
 
17
- before :all do
18
- @non_numbered_nodeset = @test.components(@not_numbered)
19
- @numbered_nodeset = @test.components(@numbered)
20
- @messy_nodeset = @test.components(@messy)
21
- end
11
+ let(:non_numbered_nodeset) { TestClass.new.components(fixture("ARC-0005.xml")) }
12
+ let(:numbered_nodeset) { TestClass.new.components(fixture("pp002010.xml")) }
13
+ let(:messy_nodeset) { TestClass.new.components(fixture("ead_messy_format.xml")) }
22
14
 
23
15
  it "should return a nodeset" do
24
- @non_numbered_nodeset.should be_a_kind_of(Nokogiri::XML::NodeSet)
25
- @non_numbered_nodeset.first.should be_a_kind_of(Nokogiri::XML::Element)
16
+ expect(non_numbered_nodeset).to be_a_kind_of(Nokogiri::XML::NodeSet)
17
+ expect(non_numbered_nodeset.first).to be_a_kind_of(Nokogiri::XML::Element)
26
18
  end
27
19
 
28
20
  it "should be able to handle both numbered and non-numbered <c> nodes" do
29
- @non_numbered_nodeset.count.should == 135
30
- @numbered_nodeset.count.should == 83
21
+ expect(non_numbered_nodeset.count).to eq(135)
22
+ expect(numbered_nodeset.count).to eq(83)
31
23
  end
32
24
 
33
25
  it "should find some components even if ead is messily formatted" do
34
- @messy_nodeset.count.should > 0
26
+ expect(messy_nodeset.count).to be > 0
35
27
  end
36
28
 
37
29
  end
38
30
 
39
31
  describe "#prep" do
32
+ let(:subject) { TestClass.new.prep(fixture("pp002010.xml")) }
40
33
  it "should return a single component document" do
41
- part = @test.prep(@numbered_nodeset)
42
- part.should be_a_kind_of(Nokogiri::XML::Document)
34
+ expect(subject).to be_a_kind_of(Nokogiri::XML::Document)
43
35
  end
44
36
  end
45
37
 
46
38
  describe "#component_children?" do
47
-
48
- before :all do
49
- @true = '
39
+ let(:true_node) do
40
+ Nokogiri::XML('
50
41
  <c id="ref167" level="file">
51
42
  <did>
52
43
  <unittitle>Zines</unittitle>
@@ -68,27 +59,27 @@ describe SolrEad::Behaviors do
68
59
  </did>
69
60
  </c>
70
61
  </c>
71
- '
72
- @false = '
62
+ ')
63
+ end
64
+
65
+ let(:false_node) do
66
+ Nokogiri::XML('
73
67
  <c id="ref167" level="file">
74
68
  <did>
75
69
  <unittitle>Zines</unittitle>
76
70
  </did>
77
71
  </c>
78
- '
72
+ ')
79
73
  end
80
74
 
81
-
82
75
  it "should return true for components that have c nodes below them" do
83
- node = Nokogiri::XML(@true)
84
- @test.component_children?(node.elements.first).should be_true
76
+ expect(TestClass.new.component_children?(true_node.elements.first)).to be true
85
77
  end
86
78
 
87
79
  it "should return false for components that do not have c nodes below them" do
88
- node = Nokogiri::XML(@false)
89
- @test.component_children?(node.elements.first).should be_false
80
+ expect(TestClass.new.component_children?(false_node.elements.first)).to be false
90
81
  end
91
82
 
92
83
  end
93
84
 
94
- end
85
+ end
@@ -2,40 +2,35 @@ require "spec_helper"
2
2
 
3
3
  describe SolrEad::Component do
4
4
 
5
- describe "the solr document" do
5
+ context "with parent components" do
6
6
 
7
- before :all do
8
- file = "component_template.xml"
9
- @doc = SolrEad::Component.from_xml(fixture file)
7
+ let(:subject) do
8
+ additional_fields = {
9
+ "id" => "TEST-0001ref010",
10
+ Solrizer.solr_name("ead", :stored_sortable) => "TEST-0001",
11
+ Solrizer.solr_name("parent", :stored_sortable) => "ref001",
12
+ Solrizer.solr_name("parent", :displayable) => ["ref001", "ref002", "ref003"],
13
+ Solrizer.solr_name("parent_unittitles", :displayable) => ["Series I", "Subseries A", "Subseries 1"],
14
+ Solrizer.solr_name("component_children", :type => :boolean) => FALSE
15
+ }
16
+ SolrEad::Component.from_xml(fixture "component_template.xml").to_solr(additional_fields)
10
17
  end
11
18
 
12
- describe "for item-level components" do
19
+ it "should accept additional fields from a hash" do
20
+ expect(subject["id"]).to eq("TEST-0001ref010")
21
+ expect(subject[Solrizer.solr_name("level", :facetable)]).to include "item"
22
+ expect(subject[Solrizer.solr_name("accessrestrict", :displayable)].first).to match /^This item .* is available.$/
23
+ end
13
24
 
14
- before :each do
15
- additional_fields = {
16
- "id" => "TEST-0001ref010",
17
- Solrizer.solr_name("ead", :stored_sortable) => "TEST-0001",
18
- Solrizer.solr_name("parent", :stored_sortable) => "ref001",
19
- Solrizer.solr_name("parent", :displayable) => ["ref001", "ref002", "ref003"],
20
- Solrizer.solr_name("parent_unittitles", :displayable) => ["Series I", "Subseries A", "Subseries 1"],
21
- Solrizer.solr_name("component_children", :type => :boolean) => FALSE
22
- }
23
- @solr_doc = @doc.to_solr(additional_fields)
24
- end
25
+ it "should create fields using type" do
26
+ expect(subject[Solrizer.solr_name("ref", :stored_sortable)]).to eq("ref215")
27
+ end
25
28
 
26
- it "should accept additional fields from a hash" do
27
- @solr_doc["id"].should == "TEST-0001ref010"
28
- @solr_doc[Solrizer.solr_name("level", :facetable)].should include "item"
29
- @solr_doc[Solrizer.solr_name("accessrestrict", :displayable)].first.should match /^This item .* is available.$/
30
- end
29
+ end
31
30
 
32
- it "should create fields using type" do
33
- @solr_doc[Solrizer.solr_name("ref", :stored_sortable)].should == "ref215"
34
- end
31
+ context "without parent components" do
35
32
 
36
- end
37
-
38
- it "should format heading_display with only one element" do
33
+ let(:subject) do
39
34
  additional_fields = {
40
35
  "id" => "TEST-0001ref010",
41
36
  Solrizer.solr_name("ead", :stored_sortable) => "TEST-0001",
@@ -44,25 +39,21 @@ describe SolrEad::Component do
44
39
  Solrizer.solr_name("parent_unittitles", :displayable) => [],
45
40
  Solrizer.solr_name("component_children", :type => :boolean) => FALSE
46
41
  }
47
- solr_doc = @doc.to_solr(additional_fields)
48
- solr_doc["id"].should == "TEST-0001ref010"
49
- solr_doc[Solrizer.solr_name("level", :facetable)].should include "item"
50
- solr_doc[Solrizer.solr_name("accessrestrict", :displayable)].first.should match /^This item .* is available.$/
51
- end
42
+ SolrEad::Component.from_xml(fixture "component_template.xml").to_solr(additional_fields)
43
+ end
44
+ it "should format heading_display with only one element" do
45
+ expect(subject["id"]).to eq("TEST-0001ref010")
46
+ expect(subject[Solrizer.solr_name("level", :facetable)]).to include "item"
47
+ expect(subject[Solrizer.solr_name("accessrestrict", :displayable)].first).to match /^This item .* is available.$/
48
+ end
52
49
 
53
- end
50
+ end
54
51
 
55
52
  describe "formatting fields as html" do
56
-
57
- before :all do
58
- file = "html_component.xml"
59
- @sample = SolrEad::Component.from_xml(fixture file)
60
- end
61
-
53
+ let(:subject) { SolrEad::Component.from_xml(fixture "html_component.xml") }
62
54
  it "should format as term as html" do
63
- @sample.term_to_html("scopecontent").should include "<em>OPAL</em> "
55
+ expect(subject.term_to_html("scopecontent")).to include "<em>OPAL</em> "
64
56
  end
65
-
66
57
  end
67
58
 
68
- end
59
+ end
@@ -2,77 +2,76 @@ require "spec_helper"
2
2
 
3
3
  describe SolrEad::Document do
4
4
 
5
- before(:all) do
6
- @ex1 = SolrEad::Document.from_xml(fixture "ARC-0005.xml")
7
- @ex2 = SolrEad::Document.from_xml(fixture "pp002010.xml")
8
- @ex3 = SolrEad::Document.from_xml(fixture "ARC-0161.xml")
9
- @solr_ex1 = @ex1.to_solr
10
- @solr_ex2 = @ex2.to_solr
11
- @solr_ex3 = @ex3.to_solr
12
- end
13
-
14
5
  describe "#terminology" do
15
6
 
7
+ let(:ex1) { SolrEad::Document.from_xml(fixture "ARC-0005.xml") }
8
+ let(:ex2) { SolrEad::Document.from_xml(fixture "pp002010.xml") }
9
+ let(:ex3) { SolrEad::Document.from_xml(fixture "ARC-0161.xml") }
10
+
16
11
  it "should have an id field" do
17
- @ex1.eadid.first.should == "ARC-0005"
12
+ expect(ex1.eadid.first).to eq("ARC-0005")
18
13
  end
19
14
 
20
15
  it "should have a simple title" do
21
- @ex1.title.first.should match "Eddie Cochran Historical Organization Collection"
16
+ expect(ex1.title.first).to match "Eddie Cochran Historical Organization Collection"
22
17
  end
23
18
 
24
19
  it "should have some subject headings" do
25
- @ex1.persname.should include "Cochran, Eddie, 1938-1960"
26
- @ex1.genreform.should include "Newspapers"
27
- @ex1.subject.should include "Rockabilly music"
28
- @ex2.corpname.should include "Tuskegee Normal and Industrial Institute--1880-1940."
29
- @ex2.genreform.should include "Group portraits--1880-1940."
30
- @ex2.geogname.should include "Washington, D.C."
31
- @ex2.name.should include "Bell, J.S., Portland, OR"
32
- @ex2.persname.should include "Johnston, Frances Benjamin, 1864-1952, photographer."
33
- @ex2.subject.should include "Buildings--1880-1940."
20
+ expect(ex1.persname).to include "Cochran, Eddie, 1938-1960"
21
+ expect(ex1.genreform).to include "Newspapers"
22
+ expect(ex1.subject).to include "Rockabilly music"
23
+ expect(ex2.corpname).to include "Tuskegee Normal and Industrial Institute--1880-1940."
24
+ expect(ex2.genreform).to include "Group portraits--1880-1940."
25
+ expect(ex2.geogname).to include "Washington, D.C."
26
+ expect(ex2.name).to include "Bell, J.S., Portland, OR"
27
+ expect(ex2.persname).to include "Johnston, Frances Benjamin, 1864-1952, photographer."
28
+ expect(ex2.subject).to include "Buildings--1880-1940."
34
29
  end
35
30
 
36
31
  it "should have scope and contents" do
37
- @ex2.scopecontent.first.should match /^Photographs/
32
+ expect(ex2.scopecontent.first).to match /^Photographs/
38
33
  end
39
34
 
40
35
  it "should have one separatedmaterial material note from the archdesc section" do
41
- @ex1.separatedmaterial.first.should match /^Commercially-released publications.*materials are available.$/
36
+ expect(ex1.separatedmaterial.first).to match /^Commercially-released publications.*materials are available.$/
42
37
  end
43
38
 
44
39
  it "should have its xml" do
45
- @ex1.to_xml.should match "<c\s"
46
- @ex2.to_xml.should match "<c01\s"\
40
+ expect(ex1.to_xml).to match "<c\s"
41
+ expect(ex2.to_xml).to match "<c01\s"\
47
42
  end
48
43
 
49
44
  it "should have a bibliography" do
50
- @ex3.bibliography.first.should == "All Music Guide. Accessed February 4, 2013. http://www.allmusic.com/."
45
+ expect(ex3.bibliography.first).to eq("All Music Guide. Accessed February 4, 2013. http://www.allmusic.com/.")
51
46
  end
52
47
 
53
48
  end
54
49
 
55
50
  describe ".to_solr" do
56
51
 
52
+ let(:ex1) { SolrEad::Document.from_xml(fixture "ARC-0005.xml").to_solr }
53
+ let(:ex2) { SolrEad::Document.from_xml(fixture "pp002010.xml").to_solr }
54
+ let(:ex3) { SolrEad::Document.from_xml(fixture "ARC-0161.xml").to_solr }
55
+
57
56
  it "should have the appropriate id fields" do
58
- @solr_ex2["id"].should == "http://hdl.loc.gov/loc.pnp/eadpnp.pp002010"
59
- @solr_ex1["id"].should == "ARC-0005"
60
- @solr_ex2[Solrizer.solr_name("ead", :stored_sortable)].should == "http://hdl.loc.gov/loc.pnp/eadpnp.pp002010"
61
- @solr_ex1[Solrizer.solr_name("ead", :stored_sortable)].should == "ARC-0005"
57
+ expect(ex2["id"]).to eq("http://hdl.loc.gov/loc.pnp/eadpnp.pp002010")
58
+ expect(ex1["id"]).to eq("ARC-0005")
59
+ expect(ex2[Solrizer.solr_name("ead", :stored_sortable)]).to eq("http://hdl.loc.gov/loc.pnp/eadpnp.pp002010")
60
+ expect(ex1[Solrizer.solr_name("ead", :stored_sortable)]).to eq("ARC-0005")
62
61
  end
63
62
 
64
63
  it "should have faceted terms created from subject headings" do
65
- @solr_ex1[Solrizer.solr_name("persname", :facetable)].should include "Cochran, Eddie, 1938-1960"
66
- @solr_ex1[Solrizer.solr_name("genreform", :facetable)].should include "Newspapers"
67
- @solr_ex1[Solrizer.solr_name("subject", :facetable)].should include "Rockabilly music"
68
- @solr_ex2[Solrizer.solr_name("corpname", :facetable)].should include "Tuskegee Normal and Industrial Institute--1880-1940."
69
- @solr_ex2[Solrizer.solr_name("genreform", :facetable)].should include "Group portraits--1880-1940."
70
- @solr_ex2[Solrizer.solr_name("geogname", :facetable)].should include "Washington, D.C."
71
- @solr_ex2[Solrizer.solr_name("name", :facetable)].should include "Bell, J.S., Portland, OR"
72
- @solr_ex2[Solrizer.solr_name("persname", :facetable)].should include "Johnston, Frances Benjamin, 1864-1952, photographer."
73
- @solr_ex2[Solrizer.solr_name("subject", :facetable)].should include "Buildings--1880-1940."
64
+ expect(ex1[Solrizer.solr_name("persname", :facetable)]).to include "Cochran, Eddie, 1938-1960"
65
+ expect(ex1[Solrizer.solr_name("genreform", :facetable)]).to include "Newspapers"
66
+ expect(ex1[Solrizer.solr_name("subject", :facetable)]).to include "Rockabilly music"
67
+ expect(ex2[Solrizer.solr_name("corpname", :facetable)]).to include "Tuskegee Normal and Industrial Institute--1880-1940."
68
+ expect(ex2[Solrizer.solr_name("genreform", :facetable)]).to include "Group portraits--1880-1940."
69
+ expect(ex2[Solrizer.solr_name("geogname", :facetable)]).to include "Washington, D.C."
70
+ expect(ex2[Solrizer.solr_name("name", :facetable)]).to include "Bell, J.S., Portland, OR"
71
+ expect(ex2[Solrizer.solr_name("persname", :facetable)]).to include "Johnston, Frances Benjamin, 1864-1952, photographer."
72
+ expect(ex2[Solrizer.solr_name("subject", :facetable)]).to include "Buildings--1880-1940."
74
73
  end
75
74
 
76
75
  end
77
76
 
78
- end
77
+ end
@@ -2,25 +2,24 @@ require 'spec_helper'
2
2
 
3
3
  describe SolrEad::Formatting do
4
4
 
5
- before :all do
5
+ let(:subject) do
6
6
  class SampleClass
7
7
  include SolrEad::Formatting
8
8
  end
9
- @sample = SampleClass.new
9
+ return SampleClass.new
10
10
  end
11
11
 
12
12
  describe "#ead_to_html" do
13
13
 
14
14
  it "should convert ead markup to html" do
15
15
  xml = 'This is some text with <title render="italics">italics</title> included in it.'
16
- @sample.ead_to_html(xml).should == 'This is some text with <em>italics</em> included in it.'
16
+ expect(subject.ead_to_html(xml)).to eq('This is some text with <em>italics</em> included in it.')
17
17
  end
18
18
 
19
19
  it "should remove other tags" do
20
20
  xml = 'Blah blah <title render="italics">italics</title> blah <span>blah</span> <title render="bold">italics</title>'
21
- @sample.ead_to_html(xml).should == 'Blah blah <em>italics</em> blah blah <strong>italics</strong>'
21
+ expect(subject.ead_to_html(xml)).to eq('Blah blah <em>italics</em> blah blah <strong>italics</strong>')
22
22
  end
23
23
  end
24
24
 
25
-
26
- end
25
+ end
data/spec/indexer_spec.rb CHANGED
@@ -2,112 +2,103 @@ require "spec_helper"
2
2
 
3
3
  describe SolrEad::Indexer do
4
4
 
5
- before :all do
6
- @file = fixture "ARC-0005.xml"
7
- end
5
+ let(:file) { fixture "ARC-0005.xml" }
8
6
 
9
7
  describe "indexing an ead document into multiple solr documents" do
10
8
 
11
- before :each do
12
- @indexer = SolrEad::Indexer.new
13
- end
9
+ let(:indexer) { SolrEad::Indexer.new }
14
10
 
15
11
  it "should index a new ead from a file" do
16
- @indexer.create(@file)
17
- q = @indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
18
- q["response"]["numFound"].should == 136
12
+ indexer.create(file)
13
+ q = indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
14
+ expect(q["response"]["numFound"]).to eq(136)
19
15
  end
20
16
 
21
-
22
17
  it "should update an ead from a file" do
23
- @indexer.update(@file)
24
- q = @indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
25
- q["response"]["numFound"].should == 136
18
+ indexer.update(file)
19
+ q = indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
20
+ expect(q["response"]["numFound"]).to eq(136)
26
21
  end
27
22
 
28
23
  it "should delete and ead give an id" do
29
- @indexer.delete("ARC-0005")
30
- q = @indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
31
- q["response"]["numFound"].should == 0
24
+ indexer.delete("ARC-0005")
25
+ q = indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
26
+ expect(q["response"]["numFound"]).to eq(0)
32
27
  end
33
28
 
34
29
  end
35
30
 
36
31
  describe "indexing ead document into one solr document" do
37
32
 
38
- before :each do
39
- @simple_indexer = SolrEad::Indexer.new(:simple => true)
40
- end
33
+ let(:indexer) { SolrEad::Indexer.new(:simple => true) }
41
34
 
42
35
  it "should be set to use the simple option" do
43
- @simple_indexer.options[:simple].should be_true
36
+ expect(indexer.options[:simple]).to be true
44
37
  end
45
38
 
46
39
  it "should index a new ead from a file as a single solr document" do
47
- @simple_indexer.create(@file)
48
- q = @simple_indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
49
- q["response"]["numFound"].should == 1
40
+ indexer.create(file)
41
+ q = indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
42
+ expect(q["response"]["numFound"]).to eq(1)
50
43
  end
51
44
 
52
45
  it "should delete a single ead" do
53
- @simple_indexer.delete("ARC-0005")
54
- q = @simple_indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
55
- q["response"]["numFound"].should == 0
46
+ indexer.delete("ARC-0005")
47
+ q = indexer.solr.get 'select', :params => {:q=>Solrizer.solr_name("ead", :stored_sortable)+':"ARC-0005"', :qt=>'document'}
48
+ expect(q["response"]["numFound"]).to eq(0)
56
49
  end
57
50
 
58
51
  end
59
52
 
60
53
  describe "specifying custom om definitions" do
61
54
 
62
- before :all do
63
- class CustomDocument < SolrEad::Document
64
- include OM::XML::Document
65
- include OM::XML::TerminologyBasedSolrizer
66
- include SolrEad::OmBehaviors
67
- set_terminology do |t|
68
- t.root(:path=>"ead", :index_as => [:not_searchable])
69
- t.title
70
- t.eadid
71
- t.title_num
72
- end
55
+ class CustomDocument < SolrEad::Document
56
+ include OM::XML::Document
57
+ include OM::XML::TerminologyBasedSolrizer
58
+ include SolrEad::OmBehaviors
59
+ set_terminology do |t|
60
+ t.root(:path=>"ead", :index_as => [:not_searchable])
61
+ t.title
62
+ t.eadid
63
+ t.title_num
73
64
  end
65
+ end
74
66
 
75
- class CustomComponent < SolrEad::Component
76
- include OM::XML::Document
77
- include OM::XML::TerminologyBasedSolrizer
78
- set_terminology do |t|
79
- t.root(:path=>"c", :index_as => [:not_searchable, :not_displayable])
80
- t.ref(:path=>"/c/@id")
81
- t.level(:path=>"/c/@level", :index_as => [:facetable])
82
- t.title(:path=>"unittitle", :attributes=>{ :type => :none }, :index_as=>[:searchable, :displayable])
83
- end
67
+ class CustomComponent < SolrEad::Component
68
+ include OM::XML::Document
69
+ include OM::XML::TerminologyBasedSolrizer
70
+ set_terminology do |t|
71
+ t.root(:path=>"c", :index_as => [:not_searchable, :not_displayable])
72
+ t.ref(:path=>"/c/@id")
73
+ t.level(:path=>"/c/@level", :index_as => [:facetable])
74
+ t.title(:path=>"unittitle", :attributes=>{ :type => :none }, :index_as=>[:searchable, :displayable])
84
75
  end
85
76
  end
86
77
 
87
78
  it "should raise an error if you use an undefined class" do
88
- lambda {SolrEad::Indexer.new(:document => BogusClass)}.should raise_error NameError
79
+ expect {SolrEad::Indexer.new(:document => BogusClass)}.to raise_error NameError
89
80
  end
90
81
 
91
82
  it "should accept a document definition" do
92
83
  indexer = SolrEad::Indexer.new(:document => CustomDocument)
93
- indexer.create(@file)
84
+ indexer.create(file)
94
85
  end
95
86
 
96
87
  it "should accept a component definition" do
97
88
  indexer = SolrEad::Indexer.new(:component => CustomComponent)
98
- indexer.create(@file)
89
+ indexer.create(file)
99
90
  end
100
91
 
101
92
  it "should accept a simple custom document definition" do
102
93
  indexer = SolrEad::Indexer.new(:document => CustomDocument, :stored_sortable=>true)
103
- indexer.create(@file)
94
+ indexer.create(file)
104
95
  end
105
96
 
106
97
  it "should accept both custom definitions and components" do
107
98
  indexer = SolrEad::Indexer.new(:document => CustomDocument, :component => CustomComponent)
108
- indexer.create(@file)
99
+ indexer.create(file)
109
100
  end
110
101
 
111
102
  end
112
103
 
113
- end
104
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,18 +1,9 @@
1
1
  # :nodoc
2
2
  require "solr_ead"
3
- require "debugger"
3
+ require "byebug" unless ENV['TRAVIS']
4
4
 
5
5
  RSpec.configure do |config|
6
-
7
- # == Mock Framework
8
- # Note: we're not mocking... yet.
9
- # config.mock_with :mocha
10
- # config.mock_with :flexmock
11
- # config.mock_with :rr
12
- #config.mock_with :rspec
13
-
14
6
  config.color = true
15
-
16
7
  end
17
8
 
18
9
  def fixture(file) #:nodoc
@@ -27,4 +18,4 @@ def debug_solr_doc(doc) #:nodoc
27
18
  puts doc[key]
28
19
  end
29
20
  end
30
- end
21
+ end
@@ -45,4 +45,4 @@ def load_indexer
45
45
  options[:simple] = (ENV['SIMPLE'] or ENV['SIMPLE']=="true") ? true : false
46
46
  indexer = SolrEad::Indexer.new(options)
47
47
  return indexer
48
- end
48
+ end