spec/specset_spec.rb in marcspec-1.5.0 vs spec/specset_spec.rb in marcspec-1.6.1

- old
+ new

@@ -67,63 +67,64 @@ @h = @ss.hash_from_marc @one end it "should get all the specs" do - @ss.solrfieldspecs.size.should.equal 4 + @ss.solrfieldspecs.size.should == 4 end it "gets the places field" do - @h['places'].sort.should.equal @places.sort + @h['places'].sort.should == @places.sort end - correct = { - 'title' => @title, - 'titleA' => @titleA, - 'constantField' => ['A', 'B'] - } - correct.each do |k,v| - it "gets correct value for #{k}" do - @h[k].should.equal v - end + it "gets title" do + @h['title'].should == @title end + it "gets title_a" do + @h['titleA'].should == @titleA + end + + it "gets constant" do + @h['constantField'].should == ['A', 'B'] + end + it "allows customs that reference previous work" do @speclist << {:solrField=>'titleSort', :module=>A::B, :functionSymbol=>:sortable, :functionArgs=>['title']} ss = MARCSpec::SpecSet.new ss.buildSpecsFromList(@speclist) h = ss.hash_from_marc @one - h['title'].should.equal @title - h['titleSort'].should.equal @title.map{|a| a.gsub(/\p{Punct}/, ' ').gsub(/\s+/, ' ').strip.downcase} + h['title'].should == @title + h['titleSort'].should == @title.map{|a| a.gsub(/\p{Punct}/, ' ').gsub(/\s+/, ' ').strip.downcase} end it "should allow repeated solrFields" do @speclist << {:solrField=>'titleA', :specs=>[['260', 'c']]} # '1939.' expected = @titleA expected << '1939.' ss = MARCSpec::SpecSet.new ss.buildSpecsFromList(@speclist) h = ss.hash_from_marc @one - h['titleA'].sort.should.equal expected.sort + h['titleA'].sort.should == expected.sort end it "should allow multi-headed custom fields" do @speclist << {:solrField => ['one', 'two', 'letters'], :module => A::B, :functionSymbol => :three_value_custom, } ss = MARCSpec::SpecSet.new ss.buildSpecsFromList(@speclist) h = ss.hash_from_marc @one - h['one'].should.equal [1] - h['two'].should.equal [2] - h['letters'].should.equal ['a', 'b'] + h['one'].should == [1] + h['two'].should == [2] + h['letters'].should == ['a', 'b'] end it "bails if it can't find a map" do @speclist << {:solrField => 'tst', :mapname=>'nosuch', :specs => [['245']]} - lambda{@ss.buildSpecsFromList(@speclist)}.should.raise SystemExit + lambda{@ss.buildSpecsFromList(@speclist)}.should raise_error(SystemExit ) end end @@ -157,10 +158,10 @@ it "should benchmark" do @reader.each do |r| h = @ss.hash_from_marc(r, true) end @ss.solrfieldspecs.each do |sfs| - @ss.benchmarks[sfs.solrField].real.should.be positive + @ss.benchmarks[sfs.solrField].real.should be > 0.0 end # @ss.benchmarks.each do |k,v| # puts "%-10s %s" % [k + ':', v.to_s] # end \ No newline at end of file