Sha256: 7537982f5b78faa9dfc64a4828c905bcf15c47814101f76d36f174441ed06c56

Contents?: true

Size: 1.29 KB

Versions: 39

Compression:

Stored size: 1.29 KB

Contents

require 'helper.rb'

module BibTeX

  class TestBibtex < Minitest::Unit::TestCase

    def test_empty?
      assert BibTeX.open(Test.fixtures(:empty)).empty?
      refute BibTeX.open(Test.fixtures(:bibdesk)).empty?
    end

    def test_parse
      bib = BibTeX.parse %q[ @book{ id, author = {Poe, Edgar Allen}, title = "Ligeia" } ]
      assert_equal 1, bib.length
      assert_equal 'Ligeia', bib[:id].title
      assert_equal 'Poe, Edgar Allen', bib[:id].author.to_s
    end

    def test_validation
      log_level = BibTeX.log.level
      BibTeX.log.level = Logger::ERROR

      refute BibTeX.parse(%q[ @book{ id, author = {Poe, Edgar Allen}, title = "Ligeia" } ]).valid?
      assert BibTeX.parse(%q[ @book{ id, author = {Poe, Edgar Allen}, title = "Ligeia", publisher = "Penguin", year = 1996 } ]).valid?
      assert BibTeX.parse(%q[ @book{ id, editor = {Poe, Edgar Allen}, title = "Ligeia", publisher = "Penguin", year = 1996 } ]).valid?
      refute BibTeX.parse(%q[ @book{ id, xxxxxx = {Poe, Edgar Allen}, title = "Ligeia", publisher = "Penguin", year = 1996 } ]).valid?
      refute BibTeX.parse(%q[ @book{ id, author = {Poe, Edgar Allen}, title = "Lig"eia", publisher = "Penguin", year = 1996 } ]).valid?
      assert BibTeX.valid?(Test.fixtures(:bibdesk))

      BibTeX.log.level = log_level
    end
  end

end

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
bibtex-ruby-4.4.7 test/bibtex/test_utilities.rb
bibtex-ruby-4.4.6 test/bibtex/test_utilities.rb
bibtex-ruby-4.4.5 test/bibtex/test_utilities.rb
bibtex_to_scrapbox-0.2.0 gems/gems/bibtex-ruby-4.4.4/test/bibtex/test_utilities.rb
bibtex_to_scrapbox-0.1.0 gems/gems/bibtex-ruby-4.4.4/test/bibtex/test_utilities.rb
bibtex-ruby-4.4.4 test/bibtex/test_utilities.rb
bibtex-ruby-4.4.3 test/bibtex/test_utilities.rb
bibtex-ruby-4.4.2 test/bibtex/test_utilities.rb
bibtex-ruby-4.4.1 test/bibtex/test_utilities.rb
bibtex-ruby-4.4.0 test/bibtex/test_utilities.rb
bibtex-ruby-4.3.0 test/bibtex/test_utilities.rb
bibtex-ruby-4.2.0 test/bibtex/test_utilities.rb
bibtex-ruby-4.1.2 test/bibtex/test_utilities.rb
bibtex-ruby-4.1.1 test/bibtex/test_utilities.rb
bibtex-ruby-4.1.0 test/bibtex/test_utilities.rb
bibtex-ruby-4.0.16 test/bibtex/test_utilities.rb
bibtex-ruby-4.0.15 test/bibtex/test_utilities.rb
bibtex-ruby-4.0.14 test/bibtex/test_utilities.rb
bibtex-ruby-4.0.13 test/bibtex/test_utilities.rb
bibtex-ruby-4.0.12 test/bibtex/test_utilities.rb