Sha256: a4d411050ec8283d762c671190148b7a992a626876d30d76c602e002b06cc7e7

Contents?: true

Size: 1.66 KB

Versions: 14

Compression:

Stored size: 1.66 KB

Contents

require 'helper'

module BibTeX
  
	class ElementTest < MiniTest::Spec
		
		describe '.parse' do
			
			it 'accepts a BibTeX string' do
				Element.parse('@misc{x,},@misc{y,}').length.must_be :==, 2
			end
			
			it 'accepts an Element' do
				Element.parse(Comment.new('blah')).length.must_be :==, 1
			end
			
			it 'accepts a Hash and returns an Entry' do
				Element.parse({ :type => :book })[0].type.must_be :==, :book
			end
			
			it 'accepts an array of hashes' do
				Element.parse([{ :type => :book }, { :type => :misc }])[1].type.must_be :==, :misc
			end
			
		end
		
	end

  class PreambleTest < MiniTest::Spec
    
    describe 'a new preamble instance' do
      before do
        @preamble = Preamble.new
      end
      
      it 'should not be nil' do
        assert @preamble
      end
    end
    
    describe 'given a set of @preambles' do
      before do
        @bib = BibTeX.open(Test.fixtures(:preamble))
        @preambles = @bib.preambles
      end
      
      it 'should support round-trips of all parsed preambles' do
        assert_equal %q[@preamble{ "This bibliography was created \today" }], @preambles[0].to_s
        assert_equal %q[@preamble{ "Bib\TeX" }], @preambles[1].to_s
        assert_equal %q[@preamble{ "Maintained by " # maintainer }], @preambles[2].to_s
      end

      it 'should support string replacement of preamble contents' do
        assert_equal %q["Maintained by " # maintainer], @preambles[2].value.to_s
        @bib.replace_strings
        assert_equal %q["Maintained by " # "Myself"], @preambles[2].value.to_s
        @bib.join_strings
        assert_equal 'Maintained by Myself', @preambles[2].value.to_s
      end
    end

  end
  
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
bibtex-ruby-2.0.12 test/bibtex/test_elements.rb
bibtex-ruby-2.0.11 test/bibtex/test_elements.rb
bibtex-ruby-2.0.10 test/bibtex/test_elements.rb
bibtex-ruby-2.0.9 test/bibtex/test_elements.rb
bibtex-ruby-2.0.8 test/bibtex/test_elements.rb
bibtex-ruby-2.0.7 test/bibtex/test_elements.rb
bibtex-ruby-2.0.6 test/bibtex/test_elements.rb
bibtex-ruby-2.0.5 test/bibtex/test_elements.rb
bibtex-ruby-2.0.4 test/bibtex/test_elements.rb
bibtex-ruby-2.0.3 test/bibtex/test_elements.rb
bibtex-ruby-2.0.2 test/bibtex/test_elements.rb
bibtex-ruby-2.0.1 test/bibtex/test_elements.rb
bibtex-ruby-2.0.0 test/bibtex/test_elements.rb
bibtex-ruby-2.0.0pre1 test/bibtex/test_elements.rb