bibtex-ruby 4.4.7 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bibtex-ruby might be problematic. Click here for more details.

Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +23 -24
  3. data/History.txt +4 -0
  4. data/Rakefile +23 -25
  5. data/bibtex-ruby.gemspec +1 -1
  6. data/examples/bib2html.rb +5 -6
  7. data/examples/bib2yaml.rb +2 -2
  8. data/features/step_definitions/bibtex_steps.rb +3 -6
  9. data/features/step_definitions/name_steps.rb +1 -2
  10. data/lib/bibtex.rb +11 -13
  11. data/lib/bibtex/bibliography.rb +45 -58
  12. data/lib/bibtex/compatibility.rb +3 -5
  13. data/lib/bibtex/elements.rb +49 -42
  14. data/lib/bibtex/entry.rb +80 -84
  15. data/lib/bibtex/entry/citeproc_converter.rb +47 -52
  16. data/lib/bibtex/entry/rdf_converter.rb +97 -63
  17. data/lib/bibtex/error.rb +10 -11
  18. data/lib/bibtex/extensions.rb +2 -5
  19. data/lib/bibtex/filters.rb +4 -9
  20. data/lib/bibtex/filters/latex.rb +0 -2
  21. data/lib/bibtex/filters/linebreaks.rb +0 -2
  22. data/lib/bibtex/lexer.rb +81 -81
  23. data/lib/bibtex/names.rb +24 -28
  24. data/lib/bibtex/replaceable.rb +15 -17
  25. data/lib/bibtex/utilities.rb +5 -10
  26. data/lib/bibtex/value.rb +28 -34
  27. data/lib/bibtex/version.rb +6 -6
  28. data/test/benchmark.rb +20 -22
  29. data/test/bibtex/entry/test_rdf_converter.rb +3 -5
  30. data/test/bibtex/test_bibliography.rb +22 -35
  31. data/test/bibtex/test_elements.rb +7 -15
  32. data/test/bibtex/test_entry.rb +78 -87
  33. data/test/bibtex/test_filters.rb +8 -7
  34. data/test/bibtex/test_lexer.rb +10 -13
  35. data/test/bibtex/test_name_parser.rb +6 -9
  36. data/test/bibtex/test_names.rb +50 -55
  37. data/test/bibtex/test_parser.rb +30 -34
  38. data/test/bibtex/test_string.rb +8 -9
  39. data/test/bibtex/test_utilities.rb +6 -9
  40. data/test/bibtex/test_value.rb +41 -43
  41. data/test/helper.rb +3 -6
  42. data/test/macruby.rb +12 -13
  43. data/test/profile.rb +16 -16
  44. data/test/test_bibtex.rb +10 -15
  45. data/test/test_export.rb +5 -13
  46. metadata +4 -4
@@ -1,11 +1,8 @@
1
1
  require 'helper'
2
2
 
3
3
  module BibTeX
4
-
5
4
  class ElementTest < Minitest::Spec
6
-
7
5
  describe '.parse' do
8
-
9
6
  it 'accepts a BibTeX string' do
10
7
  Element.parse('@misc{x,},@misc{y,}').length.must_be :==, 2
11
8
  end
@@ -15,19 +12,16 @@ module BibTeX
15
12
  end
16
13
 
17
14
  it 'accepts a Hash and returns an Entry' do
18
- Element.parse({ :bibtex_type => :book })[0].type.must_be :==, :book
15
+ Element.parse(bibtex_type: :book)[0].type.must_be :==, :book
19
16
  end
20
17
 
21
18
  it 'accepts an array of hashes' do
22
- Element.parse([{ :bibtex_type => :book }, { :bibtex_type => :misc }])[1].type.must_be :==, :misc
19
+ Element.parse([{ bibtex_type: :book }, { bibtex_type: :misc }])[1].type.must_be :==, :misc
23
20
  end
24
-
25
21
  end
26
-
27
22
  end
28
23
 
29
24
  class PreambleTest < Minitest::Spec
30
-
31
25
  describe 'a new preamble instance' do
32
26
  before do
33
27
  @preamble = Preamble.new
@@ -45,20 +39,18 @@ module BibTeX
45
39
  end
46
40
 
47
41
  it 'should support round-trips of all parsed preambles' do
48
- assert_equal %[@preamble{ "This bibliography was created \\today" }\n], @preambles[0].to_s
49
- assert_equal %[@preamble{ "Bib\\TeX" }\n], @preambles[1].to_s
50
- assert_equal %[@preamble{ "Maintained by " # maintainer }\n], @preambles[2].to_s
42
+ assert_equal %(@preamble{ "This bibliography was created \\today" }\n), @preambles[0].to_s
43
+ assert_equal %(@preamble{ "Bib\\TeX" }\n), @preambles[1].to_s
44
+ assert_equal %(@preamble{ "Maintained by " # maintainer }\n), @preambles[2].to_s
51
45
  end
52
46
 
53
47
  it 'should support string replacement of preamble contents' do
54
- assert_equal %q["Maintained by " # maintainer], @preambles[2].value.to_s
48
+ assert_equal '"Maintained by " # maintainer', @preambles[2].value.to_s
55
49
  @bib.replace_strings
56
- assert_equal %q["Maintained by " # "Myself"], @preambles[2].value.to_s
50
+ assert_equal '"Maintained by " # "Myself"', @preambles[2].value.to_s
57
51
  @bib.join_strings
58
52
  assert_equal 'Maintained by Myself', @preambles[2].value.to_s
59
53
  end
60
54
  end
61
-
62
55
  end
63
-
64
56
  end
@@ -1,10 +1,7 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  require 'helper.rb'
4
2
 
5
3
  module BibTeX
6
4
  class EntryTest < Minitest::Spec
7
-
8
5
  describe 'a new entry' do
9
6
  it "won't be nil" do
10
7
  Entry.new.wont_be_nil
@@ -14,7 +11,7 @@ module BibTeX
14
11
  describe '#add' do
15
12
  it 'preserves BibTeX::Names (and other subclasses of BibTeX::Value)' do
16
13
  e = Entry.new
17
- e.add(:author, Names.new(Name.new(:first => 'first_name')))
14
+ e.add(:author, Names.new(Name.new(first: 'first_name')))
18
15
  assert_equal e[:author].class, Names
19
16
  end
20
17
  end
@@ -88,7 +85,7 @@ module BibTeX
88
85
  end
89
86
 
90
87
  describe 'when "booktitle" is undefined for the entry but defined in the reference' do
91
- before { @bib['a'].booktitle = "A Booktitle" }
88
+ before { @bib['a'].booktitle = 'A Booktitle' }
92
89
  it 'returns the referenced booktitle' do
93
90
  @bib['a1'].booktitle.must_be :==, @bib['a'].booktitle
94
91
  end
@@ -119,7 +116,7 @@ module BibTeX
119
116
  end
120
117
 
121
118
  it 'returns a list of all fields not set in the field but in the reference' do
122
- @bib['a1'].inherited_fields.must_be :==, [:booktitle, :editor, :title]
119
+ @bib['a1'].inherited_fields.must_be :==, %i[booktitle editor title]
123
120
  end
124
121
  end
125
122
 
@@ -138,7 +135,6 @@ module BibTeX
138
135
  end
139
136
  end
140
137
  end
141
-
142
138
  end
143
139
  end
144
140
 
@@ -148,21 +144,20 @@ module BibTeX
148
144
  end
149
145
 
150
146
  it 'returns the author (if set)' do
151
- Entry.new(:author => 'A').names.must_be :==, %w{ A }
147
+ Entry.new(author: 'A').names.must_be :==, %w[A]
152
148
  end
153
149
 
154
150
  it 'returns all authors (if set)' do
155
- Entry.new(:author => 'A B and C D').parse_names.names.length.must_be :==, 2
151
+ Entry.new(author: 'A B and C D').parse_names.names.length.must_be :==, 2
156
152
  end
157
153
 
158
154
  it 'returns the editor (if set)' do
159
- Entry.new(:editor => 'A').names.must_be :==, %w{ A }
155
+ Entry.new(editor: 'A').names.must_be :==, %w[A]
160
156
  end
161
157
 
162
158
  it 'returns the translator (if set)' do
163
- Entry.new(:translator => 'A').names.must_be :==, %w{ A }
159
+ Entry.new(translator: 'A').names.must_be :==, %w[A]
164
160
  end
165
-
166
161
  end
167
162
 
168
163
  describe 'month conversion' do
@@ -170,14 +165,14 @@ module BibTeX
170
165
  @entry = Entry.new
171
166
  end
172
167
 
173
- [[:jan,'January'], [:feb,'February'], [:sep,'September']].each do |m|
168
+ [[:jan, 'January'], [:feb, 'February'], [:sep, 'September']].each do |m|
174
169
  it 'should convert english months' do
175
170
  @entry.month = m[1]
176
171
  assert_equal m[0], @entry.month.v
177
172
  end
178
173
  end
179
174
 
180
- [[:jan,:jan], [:feb,:feb], [:sep,:sep]].each do |m|
175
+ [%i[jan jan], %i[feb feb], %i[sep sep]].each do |m|
181
176
  it 'should convert bibtex abbreviations' do
182
177
  @entry.month = m[1]
183
178
  assert_equal m[0], @entry.month.v
@@ -190,7 +185,7 @@ module BibTeX
190
185
  assert_match(/month = aug/, @entry.to_s)
191
186
  end
192
187
 
193
- [[:jan,1], [:feb,2], [:sep,9]].each do |m|
188
+ [[:jan, 1], [:feb, 2], [:sep, 9]].each do |m|
194
189
  it 'should convert numbers' do
195
190
  @entry.month = m[1]
196
191
  assert_equal m[0], @entry.month.v
@@ -201,7 +196,6 @@ module BibTeX
201
196
  assert_equal m[1], @entry.month_numeric
202
197
  end
203
198
  end
204
-
205
199
  end
206
200
 
207
201
  describe '#values_at' do
@@ -210,7 +204,7 @@ module BibTeX
210
204
  end
211
205
 
212
206
  it 'returns an empty array when given no arguments' do
213
- assert_equal [], Entry.new(:title => 'foo').values_at
207
+ assert_equal [], Entry.new(title: 'foo').values_at
214
208
  end
215
209
 
216
210
  it 'returns a nil array if the passed in key is not set' do
@@ -218,8 +212,8 @@ module BibTeX
218
212
  end
219
213
 
220
214
  it 'returns an array with the value of the passed in key' do
221
- assert_equal ['x'], Entry.new(:title => 'x').values_at(:title)
222
- assert_equal ['a', 'b'], Entry.new(:title => 'b', :year => 'a').values_at(:year, :title)
215
+ assert_equal ['x'], Entry.new(title: 'x').values_at(:title)
216
+ assert_equal %w[a b], Entry.new(title: 'b', year: 'a').values_at(:year, :title)
223
217
  end
224
218
  end
225
219
 
@@ -229,12 +223,12 @@ module BibTeX
229
223
  end
230
224
 
231
225
  it 'includes type and all defined fields' do
232
- assert_equal 'book', Entry.new(:bibtex_type => 'book').digest
233
- assert_equal 'book|title:foo', Entry.new(:bibtex_type => 'book', :title => 'foo').digest
226
+ assert_equal 'book', Entry.new(bibtex_type: 'book').digest
227
+ assert_equal 'book|title:foo', Entry.new(bibtex_type: 'book', title: 'foo').digest
234
228
  end
235
229
 
236
230
  it 'accepts a filter' do
237
- assert_equal 'book|year:2012', Entry.new(:bibtex_type => 'book', :title => 'foo', :year => 2012).digest([:year])
231
+ assert_equal 'book|year:2012', Entry.new(bibtex_type: 'book', title: 'foo', year: 2012).digest([:year])
238
232
  end
239
233
  end
240
234
 
@@ -254,13 +248,13 @@ module BibTeX
254
248
  end
255
249
 
256
250
  it 'supports renaming! of field attributes' do
257
- @entry.rename!(:title => :foo)
251
+ @entry.rename!(title: :foo)
258
252
  refute @entry.has_field?(:title)
259
253
  assert_equal 'Moby Dick', @entry[:foo]
260
254
  end
261
255
 
262
256
  it 'supports renaming of field attributes' do
263
- e = @entry.rename(:title => :foo)
257
+ e = @entry.rename(title: :foo)
264
258
 
265
259
  assert @entry.has_field?(:title)
266
260
  refute @entry.has_field?(:foo)
@@ -277,54 +271,54 @@ module BibTeX
277
271
  e = @entry.to_citeproc
278
272
  assert_equal 'book', e['type']
279
273
  assert_equal 'New York', e['publisher-place']
280
- assert_equal [1993,11], e['issued']['date-parts'][0]
274
+ assert_equal [1993, 11], e['issued']['date-parts'][0]
281
275
  assert_equal 1, e['author'].length
282
276
  assert_equal 'Herman', e['author'][0]['given']
283
277
  assert_equal 'Melville', e['author'][0]['family']
284
278
  end
285
279
 
286
280
  it 'sets both issue and number in techreports' do
287
- report = Entry.new { |r|
281
+ report = Entry.new do |r|
288
282
  r.type = :techreport
289
283
  r.number = 1
290
- }.to_citeproc
284
+ end.to_citeproc
291
285
 
292
286
  assert_equal '1', report['number']
293
287
  assert_equal '1', report['issue']
294
288
  end
295
289
 
296
290
  it 'uses authority and publisher for proceedings' do
297
- proceedings = Entry.new { |p|
291
+ proceedings = Entry.new do |p|
298
292
  p.type = :inproceedings
299
293
  p.publisher = 'Publisher'
300
294
  p.organization = 'Organization'
301
- }.to_citeproc
295
+ end.to_citeproc
302
296
 
303
297
  assert_equal 'Publisher', proceedings['publisher']
304
298
  assert_equal 'Organization', proceedings['authority']
305
299
 
306
- proceedings = Entry.new { |p|
300
+ proceedings = Entry.new do |p|
307
301
  p.type = :inproceedings
308
302
  p.organization = 'Organization'
309
- }.to_citeproc
303
+ end.to_citeproc
310
304
 
311
305
  assert_equal 'Organization', proceedings['publisher']
312
306
  refute proceedings.key?('authority')
313
307
 
314
- proceedings = Entry.new { |p|
308
+ proceedings = Entry.new do |p|
315
309
  p.type = :inproceedings
316
310
  p.publisher = 'Publisher'
317
- }.to_citeproc
311
+ end.to_citeproc
318
312
 
319
313
  assert_equal 'Publisher', proceedings['publisher']
320
314
  refute proceedings.key?('authority')
321
315
  end
322
316
 
323
317
  it 'uses event_place for conferences' do
324
- conference = Entry.new { |p|
318
+ conference = Entry.new do |p|
325
319
  p.type = :conference
326
320
  p.address = 'Place'
327
- }.to_citeproc
321
+ end.to_citeproc
328
322
 
329
323
  assert_equal 'Place', conference['event-place']
330
324
  end
@@ -336,30 +330,29 @@ module BibTeX
336
330
  end
337
331
 
338
332
  it 'combines year, month and day in issued date' do
339
- @entry.update :year => 2005, :month => 5, :day => 31
333
+ @entry.update year: 2005, month: 5, day: 31
340
334
  assert_equal [[2005, 5, 31]], @entry.to_citeproc['issued']['date-parts']
341
335
  end
342
336
 
343
337
  it 'prefers biblatex syntax' do
344
338
  @entry.date = '2014-07-13'
345
- assert_equal [[2014,7,13]], @entry.to_citeproc['issued']['date-parts']
339
+ assert_equal [[2014, 7, 13]], @entry.to_citeproc['issued']['date-parts']
346
340
  end
347
341
 
348
342
  it 'supports biblatex date ranges' do
349
343
  @entry.date = '2014-06-12/2014-07-13'
350
344
 
351
- assert_equal [[2014,6,12],[2014,7,13]],
352
- @entry.to_citeproc['issued']['date-parts']
345
+ assert_equal [[2014, 6, 12], [2014, 7, 13]],
346
+ @entry.to_citeproc['issued']['date-parts']
353
347
  end
354
348
 
355
349
  it 'supports biblatex partial dates' do
356
350
  @entry.date = '2014-07'
357
- assert_equal [[2014,7]], @entry.to_citeproc['issued']['date-parts']
351
+ assert_equal [[2014, 7]], @entry.to_citeproc['issued']['date-parts']
358
352
  end
359
353
  end
360
354
 
361
355
  describe 'given a filter object or a filter name' do
362
-
363
356
  class SuffixB < BibTeX::Filter
364
357
  def apply(value)
365
358
  value.is_a?(::String) ? "#{value}b" : value
@@ -368,7 +361,9 @@ module BibTeX
368
361
 
369
362
  before do
370
363
  @filter = Object.new
371
- def @filter.apply (value); value.is_a?(::String) ? value.upcase : value; end
364
+ def @filter.apply(value)
365
+ value.is_a?(::String) ? value.upcase : value
366
+ end
372
367
  end
373
368
 
374
369
  it 'supports arbitrary conversion' do
@@ -386,18 +381,17 @@ module BibTeX
386
381
  end
387
382
 
388
383
  it 'supports conditional arbitrary in-place conversion' do
389
- @entry.convert!(@filter) { |k,v| k.to_s =~ /publisher/i }
384
+ @entry.convert!(@filter) { |k, _v| k.to_s =~ /publisher/i }
390
385
  assert_equal 'Moby Dick', @entry.title
391
386
  assert_equal 'PENGUIN', @entry.publisher
392
387
  end
393
388
 
394
389
  it 'supports conditional arbitrary conversion' do
395
- e = @entry.convert(@filter) { |k,v| k.to_s =~ /publisher/i }
390
+ e = @entry.convert(@filter) { |k, _v| k.to_s =~ /publisher/i }
396
391
  assert_equal 'Moby Dick', e.title
397
392
  assert_equal 'PENGUIN', e.publisher
398
393
  assert_equal 'Penguin', @entry.publisher
399
394
  end
400
-
401
395
  end
402
396
 
403
397
  describe 'LaTeX filter' do
@@ -436,7 +430,6 @@ module BibTeX
436
430
  e.title.to_s.length.must_be :==, @entry.title.to_s.length
437
431
  end
438
432
  end
439
-
440
433
  end
441
434
  end
442
435
 
@@ -455,12 +448,12 @@ module BibTeX
455
448
  end
456
449
 
457
450
  it 'should accept option to use non-dropping-particle' do
458
- assert_equal 'van', @entry.to_citeproc(:particle => 'non-dropping-particle')['author'][0]['non-dropping-particle']
451
+ assert_equal 'van', @entry.to_citeproc(particle: 'non-dropping-particle')['author'][0]['non-dropping-particle']
459
452
  end
460
453
  end
461
454
 
462
455
  def test_simple
463
- bib = BibTeX::Bibliography.open(Test.fixtures(:entry), :debug => false)
456
+ bib = BibTeX::Bibliography.open(Test.fixtures(:entry), debug: false)
464
457
  refute_nil(bib)
465
458
  assert_equal(BibTeX::Bibliography, bib.class)
466
459
  assert_equal(4, bib.data.length)
@@ -482,7 +475,7 @@ module BibTeX
482
475
  end
483
476
 
484
477
  def test_ghost_methods
485
- bib = BibTeX::Bibliography.open(Test.fixtures(:entry), :debug => false)
478
+ bib = BibTeX::Bibliography.open(Test.fixtures(:entry), debug: false)
486
479
 
487
480
  assert_equal 'Poe, Edgar A.', bib[0].author.to_s
488
481
 
@@ -506,12 +499,12 @@ module BibTeX
506
499
  end
507
500
 
508
501
  def test_creation_from_hash
509
- entry = BibTeX::Entry.new({
510
- :bibtex_type => 'book',
511
- :bibtex_key => :raven,
512
- :author => 'Poe, Edgar A.',
513
- :title => 'The Raven'
514
- })
502
+ entry = BibTeX::Entry.new(
503
+ bibtex_type: 'book',
504
+ bibtex_key: :raven,
505
+ author: 'Poe, Edgar A.',
506
+ title: 'The Raven'
507
+ )
515
508
 
516
509
  assert_equal :book, entry.type
517
510
  assert_equal 'raven', entry.key
@@ -535,27 +528,26 @@ module BibTeX
535
528
 
536
529
  def test_sorting
537
530
  entries = []
538
- entries << Entry.new({ :bibtex_type => 'book', :bibtex_key => 'raven3', :author => 'Poe, Edgar A.', :title => 'The Raven'})
539
- entries << Entry.new({ :bibtex_type => 'book', :bibtex_key => 'raven2', :author => 'Poe, Edgar A.', :title => 'The Raven'})
540
- entries << Entry.new({ :bibtex_type => 'book', :bibtex_key => 'raven1', :author => 'Poe, Edgar A.', :title => 'The Raven'})
541
- entries << Entry.new({ :bibtex_type => 'book', :bibtex_key => 'raven1', :author => 'Poe, Edgar A.', :title => 'The Aven'})
531
+ entries << Entry.new(bibtex_type: 'book', bibtex_key: 'raven3', author: 'Poe, Edgar A.', title: 'The Raven')
532
+ entries << Entry.new(bibtex_type: 'book', bibtex_key: 'raven2', author: 'Poe, Edgar A.', title: 'The Raven')
533
+ entries << Entry.new(bibtex_type: 'book', bibtex_key: 'raven1', author: 'Poe, Edgar A.', title: 'The Raven')
534
+ entries << Entry.new(bibtex_type: 'book', bibtex_key: 'raven1', author: 'Poe, Edgar A.', title: 'The Aven')
542
535
 
543
536
  entries.sort!
544
537
 
545
- assert_equal ['raven1', 'raven1', 'raven2', 'raven3'], entries.map(&:key)
546
- assert_equal ['The Aven', 'The Raven'], entries.map(&:title)[0,2]
547
-
538
+ assert_equal %w[raven1 raven1 raven2 raven3], entries.map(&:key)
539
+ assert_equal ['The Aven', 'The Raven'], entries.map(&:title)[0, 2]
548
540
  end
549
541
 
550
542
  describe 'default keys' do
551
- before {
552
- @e1 = Entry.new(:bibtex_type => 'book', :author => 'Poe, Edgar A.', :title => 'The Raven', :editor => 'John Hopkins', :year => 1996)
553
- @e2 = Entry.new(:bibtex_type => 'book', :title => 'The Raven', :editor => 'John Hopkins', :year => 1996)
554
- @e3 = Entry.new(:bibtex_type => 'book', :author => 'Poe, Edgar A.', :title => 'The Raven', :editor => 'John Hopkins')
555
- @e4 = Entry.new(:bibtex_type => 'book', :author => 'Poe, Edgar A.', :title => 'The Raven', :editor => 'John Hopkins', :date => '2003-09')
556
- @e5 = Entry.new(:bibtex_type => 'book', :author => 'Poe, Edgar A.', :title => 'The Raven', :editor => 'John Hopkins', :year => 'n.d.')
557
- @e6 = Entry.new(:bibtex_type => 'book', :author => 'Poe, Edgar A.', :title => 'The Raven', :editor => 'John Hopkins', :year => '[2009]')
558
- }
543
+ before do
544
+ @e1 = Entry.new(bibtex_type: 'book', author: 'Poe, Edgar A.', title: 'The Raven', editor: 'John Hopkins', year: 1996)
545
+ @e2 = Entry.new(bibtex_type: 'book', title: 'The Raven', editor: 'John Hopkins', year: 1996)
546
+ @e3 = Entry.new(bibtex_type: 'book', author: 'Poe, Edgar A.', title: 'The Raven', editor: 'John Hopkins')
547
+ @e4 = Entry.new(bibtex_type: 'book', author: 'Poe, Edgar A.', title: 'The Raven', editor: 'John Hopkins', date: '2003-09')
548
+ @e5 = Entry.new(bibtex_type: 'book', author: 'Poe, Edgar A.', title: 'The Raven', editor: 'John Hopkins', year: 'n.d.')
549
+ @e6 = Entry.new(bibtex_type: 'book', author: 'Poe, Edgar A.', title: 'The Raven', editor: 'John Hopkins', year: '[2009]')
550
+ end
559
551
 
560
552
  it 'should return "unknown-a" for an empty Entry' do
561
553
  Entry.new.key.must_be :==, 'unknown-a'
@@ -591,10 +583,10 @@ module BibTeX
591
583
  end
592
584
 
593
585
  describe 'when the entry is added to a Bibliography' do
594
- before {
586
+ before do
595
587
  @e = Entry.new
596
588
  @bib = Bibliography.new
597
- }
589
+ end
598
590
 
599
591
  it 'should register itself with its key' do
600
592
  @bib << @e
@@ -604,13 +596,12 @@ module BibTeX
604
596
  describe "when there is already an element registered with the entry's key" do
605
597
  before { @bib << Entry.new }
606
598
 
607
- it "should find a suitable key" do
599
+ it 'should find a suitable key' do
608
600
  k = @e.key
609
601
  @bib << @e
610
602
  @bib.entries.keys.must_include @e.key
611
603
  k.wont_be :==, @e.key
612
604
  end
613
-
614
605
  end
615
606
  end
616
607
 
@@ -645,11 +636,11 @@ module BibTeX
645
636
  end
646
637
 
647
638
  describe '#valid?' do
648
- before {
639
+ before do
649
640
  @misc = Entry.new
650
- @book = Entry.new({ :bibtex_type => :book })
651
- @article = Entry.new({ :bibtex_type => :article })
652
- }
641
+ @book = Entry.new(bibtex_type: :book)
642
+ @article = Entry.new(bibtex_type: :article)
643
+ end
653
644
 
654
645
  it 'is true by default' do
655
646
  assert @misc.valid?
@@ -661,12 +652,12 @@ module BibTeX
661
652
  end
662
653
 
663
654
  it 'is true only if all mandatory fields are present' do
664
- @book.update({
665
- :author => 'Henry James',
666
- :title => 'What Maisie Knew',
667
- :year => 1897,
668
- :publisher => 'Heineman'
669
- })
655
+ @book.update(
656
+ author: 'Henry James',
657
+ title: 'What Maisie Knew',
658
+ year: 1897,
659
+ publisher: 'Heineman'
660
+ )
670
661
 
671
662
  assert @book.valid?
672
663
 
@@ -682,11 +673,11 @@ module BibTeX
682
673
  end
683
674
 
684
675
  describe '#fetch' do
685
- let(:pages){ '1--2' }
686
- let(:entry){
676
+ let(:pages) { '1--2' }
677
+ let(:entry) do
687
678
  e = Entry.new
688
679
  e.add(:pages, pages)
689
- }
680
+ end
690
681
 
691
682
  describe '(:pages)' do
692
683
  it 'should fetch pages' do