citeproc 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abde1189aaa24cbddc03302bf1dfddbf5cf16c4c
4
- data.tar.gz: 166d801b807891e3c56f454ac9281209c2f50de2
3
+ metadata.gz: 66ce4e398cb9a4ab393a5f4baf0bbb08b54b053c
4
+ data.tar.gz: 222b8101e61b1aac744082a5155106cc15e49499
5
5
  SHA512:
6
- metadata.gz: 8b5d32aebb7b02fb0703562db2c4959e96d1c76dd2b7444b0d2b43ee1a1652b4e0786ccbf0c90be1bd8aa042de1c80109f3d28acf0fcbb182d0cf20a11564b83
7
- data.tar.gz: 2752f32474e7c1a51a718517e78c4200fb5f72505d4ed475597e99012213650e9c631344d1cc1c7a5a6c9b245788b356ebc298a785760fe9c6803d3e4e948165
6
+ metadata.gz: 07a7857820062116708c5f0716471016b065eafb460da34d07b8e401030fac0e5207e2b314a7cfbd1ca26caa53ccbf47ed7888d61831abb5454a13c80197d53a
7
+ data.tar.gz: c67fcd016def1e8664b42651848549ab3fc2355e1945e5ac6f8e5c260a2c2db152057828729be5903fd60ffd1548f8ab149155adcefe32f6c7a7b98f9aadba33
data/Gemfile CHANGED
@@ -2,10 +2,16 @@ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
4
  group :debug do
5
- gem 'ruby-debug', :require => false, :platform => :jruby
6
- gem 'debugger', '~>1.6', :require => false, :platform => :mri
7
- gem 'rubinius-compiler', '~>2.0', :require => false, :platform => :rbx
8
- gem 'rubinius-debugger', '~>2.0', :require => false, :platform => :rbx
5
+ if RUBY_VERSION >= '2.0'
6
+ gem 'byebug', :require => false, :platforms => :mri
7
+ else
8
+ gem 'debugger', :require => false, :platforms => :mri
9
+ end
10
+
11
+ gem 'ruby-debug', :require => false, :platforms => :jruby
12
+
13
+ gem 'rubinius-debugger', :require => false, :platforms => :rbx
14
+ gem 'rubinius-compiler', :require => false, :platforms => :rbx
9
15
  end
10
16
 
11
17
  group :optional do
@@ -30,7 +36,7 @@ end
30
36
  group :development do
31
37
  gem 'rake'
32
38
  gem 'cucumber'
33
- gem 'rspec'
39
+ gem 'rspec', '~>2.0'
34
40
  gem 'simplecov', '~>0.8', :require => false
35
41
  gem 'rubinius-coverage', :platform => :rbx
36
42
  gem 'coveralls', :require => false
@@ -4,32 +4,32 @@ end
4
4
 
5
5
  Given(/^the following input:$/) do |string|
6
6
  @input = JSON.parse(string)
7
- @input.should_not be_nil
7
+ expect(@input).not_to be_nil
8
8
 
9
9
  processor.import @input
10
10
  end
11
11
 
12
12
  Given(/^the following abbreviations:$/) do |string|
13
13
  processor.abbreviations = JSON.parse(string)
14
- processor.abbreviations[:default].should_not be_empty
14
+ expect(processor.abbreviations[:default]).not_to be_empty
15
15
  end
16
16
 
17
17
  When(/^I render the entire bibliography$/) do
18
18
  @bibliography = processor.bibliography
19
- @bibliography.errors.should == []
19
+ expect(@bibliography.errors).to eq([])
20
20
  end
21
21
 
22
22
  When(/^I render the following bibliography selection:$/) do |string|
23
23
  selection = JSON.parse(string)
24
- selection.should_not be_nil
24
+ expect(selection).not_to be_nil
25
25
 
26
26
  @bibliography = processor.bibliography(selection)
27
- @bibliography.errors.should == []
27
+ expect(@bibliography.errors).to eq([])
28
28
  end
29
29
 
30
30
  Then(/^the bibliography should be:$/) do |string|
31
31
  string.gsub!(/\n\s*/m, '') # strip newlines
32
- @bibliography.join.should == string
32
+ expect(@bibliography.join).to eq(string)
33
33
  end
34
34
 
35
35
  When(/^I cite the following items:$/) do |string|
@@ -46,14 +46,14 @@ Then(/^the bibliography's options should match:$/) do |table|
46
46
  headers = table.headers.map(&:to_sym)
47
47
  expected = table.rows[0]
48
48
 
49
- @bibliography.options.values_at(*headers).should == expected
49
+ expect(@bibliography.options.values_at(*headers)).to eq(expected)
50
50
  end
51
51
 
52
52
  Then(/^the results should be:$/) do |table|
53
- @results.should == table.raw.map(&:first)
53
+ expect(@results).to eq(table.raw.map(&:first))
54
54
  end
55
55
 
56
56
  Then(/^the result should be:$/) do |string|
57
- @result.should == string
57
+ expect(@result).to eq(string)
58
58
  end
59
59
 
@@ -6,13 +6,15 @@ end
6
6
 
7
7
  begin
8
8
  case
9
- when RUBY_PLATFORM < 'java'
10
- require 'debug'
11
- Debugger.start
9
+ when RUBY_PLATFORM == 'java'
10
+ # require 'debug'
11
+ # Debugger.start
12
12
  when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
13
13
  require 'rubinius/debugger'
14
- else
14
+ when RUBY_VERSION < '2.0'
15
15
  require 'debugger'
16
+ else
17
+ require 'byebug'
16
18
  end
17
19
  rescue LoadError
18
20
  # ignore
@@ -108,6 +108,11 @@ module CiteProc
108
108
  notify_observers :read, key, value
109
109
  end
110
110
 
111
+ def simulate_read_attribute(key, value)
112
+ changed
113
+ notify_observers :read, key, value
114
+ end
115
+
111
116
  alias original_read_attribute read_attribute
112
117
  alias unobservable_read_attribute read_attribute
113
118
 
@@ -1,3 +1,3 @@
1
1
  module CiteProc
2
- VERSION = '1.0.1'.freeze
2
+ VERSION = '1.0.2'.freeze
3
3
  end
@@ -11,8 +11,8 @@ module CiteProc
11
11
  let(:abbrev) { Hash[:foo, :bar] }
12
12
  it 'uses the hash as the new set of abbreviations' do
13
13
  subject.abbreviations = abbrev
14
- subject.abbreviations.should == abbrev
15
- subject.abbreviations.should_not equal(abbrev)
14
+ expect(subject.abbreviations).to eq(abbrev)
15
+ expect(subject.abbreviations).not_to equal(abbrev)
16
16
  end
17
17
  end
18
18
 
@@ -20,16 +20,16 @@ module CiteProc
20
20
  let(:abbrev) { '{"foo":"bar"}' }
21
21
  it 'uses the hash as the new set of abbreviations' do
22
22
  subject.abbreviations = abbrev
23
- subject.abbreviations.should == Hash[:foo,'bar']
23
+ expect(subject.abbreviations).to eq(Hash[:foo,'bar'])
24
24
  end
25
25
  end
26
26
  end
27
27
 
28
28
  describe '#abbreviate' do
29
29
  it 'looks up abbreviations in the default namespace by default' do
30
- subject.abbreviate(:title, 'foo').should == nil
30
+ expect(subject.abbreviate(:title, 'foo')).to eq(nil)
31
31
  subject.abbreviations[:default][:title] = { 'foo' => 'bar' }
32
- subject.abbreviate(:title, 'foo').should == 'bar'
32
+ expect(subject.abbreviate(:title, 'foo')).to eq('bar')
33
33
  end
34
34
  end
35
35
 
@@ -30,40 +30,40 @@ module CiteProc
30
30
  end
31
31
 
32
32
  it 'should not be open by default' do
33
- Style.new.should_not be_open
33
+ expect(Style.new).not_to be_open
34
34
  end
35
35
 
36
36
  describe '.open' do
37
37
 
38
38
  it 'accepts an absolute file name' do
39
- Style.open(@file.path).to_s.should == "asset content\n"
39
+ expect(Style.open(@file.path).to_s).to eq("asset content\n")
40
40
  end
41
41
 
42
42
  it 'accepts a file name' do
43
- Style.open(@name).to_s.should == "asset content\n"
43
+ expect(Style.open(@name).to_s).to eq("asset content\n")
44
44
  end
45
45
 
46
46
  it 'accepts a file name without extension' do
47
- Style.open(@name.sub(/#{@extension}$/,'')).to_s.should == "asset content\n"
47
+ expect(Style.open(@name.sub(/#{@extension}$/,'')).to_s).to eq("asset content\n")
48
48
  end
49
49
 
50
50
 
51
51
  it 'accepts an io object' do
52
- Style.open(@file.open).to_s.should == "asset content\n"
52
+ expect(Style.open(@file.open).to_s).to eq("asset content\n")
53
53
  end
54
54
 
55
55
  it 'returns the given string if it looks like XML' do
56
- Style.open('<b>foo bar!</b>').to_s.should == '<b>foo bar!</b>'
56
+ expect(Style.open('<b>foo bar!</b>').to_s).to eq('<b>foo bar!</b>')
57
57
  end
58
58
  end
59
59
 
60
60
  describe '.extend_name' do
61
61
  it 'adds the default extension if the file does not already end with it' do
62
- Style.extend_name(@name.sub(/#{@extension}$/,'')).should == @name
62
+ expect(Style.extend_name(@name.sub(/#{@extension}$/,''))).to eq(@name)
63
63
  end
64
64
 
65
65
  it 'does not add the default extension if the file already ends with it' do
66
- Style.extend_name(@name).should == @name
66
+ expect(Style.extend_name(@name)).to eq(@name)
67
67
  end
68
68
  end
69
69
 
@@ -33,18 +33,18 @@ module CiteProc
33
33
  end
34
34
 
35
35
  it 'generates no other setters' do
36
- lambda { A.new.some_other_value }.should raise_error
36
+ expect { A.new.some_other_value }.to raise_error
37
37
  end
38
38
  end
39
39
 
40
40
  describe '#merge' do
41
41
 
42
42
  it 'merges non-existent values from other object' do
43
- A.new.merge(other)[:foo].should == 'bar'
43
+ expect(A.new.merge(other)[:foo]).to eq('bar')
44
44
  end
45
45
 
46
46
  it 'does not overwrite existing values when merging other object' do
47
- instance.merge(other)[:bar].should == 'foo'
47
+ expect(instance.merge(other)[:bar]).to eq('foo')
48
48
  end
49
49
 
50
50
  end
@@ -10,29 +10,29 @@ module CiteProc
10
10
  describe '#to_citeproc conversion' do
11
11
 
12
12
  it 'returns an array' do
13
- subject.to_citeproc.should be_a(Array)
13
+ expect(subject.to_citeproc).to be_a(Array)
14
14
  end
15
15
 
16
16
  it 'returns exactly two elements' do
17
- subject.to_citeproc.should have(2).elements
17
+ expect(subject.to_citeproc.size).to eq(2)
18
18
  end
19
19
 
20
20
  it 'returns formatting options as the first element' do
21
- subject.to_citeproc.first.should be_a(Hash)
21
+ expect(subject.to_citeproc.first).to be_a(Hash)
22
22
  end
23
23
 
24
24
  describe 'the formatting options' do
25
25
  let(:options) { subject.to_citeproc[0] }
26
26
 
27
27
  it 'contains a the error list' do
28
- options.should have_key('bibliography_errors')
29
- options['bibliography_errors'].should be_empty
28
+ expect(options).to have_key('bibliography_errors')
29
+ expect(options['bibliography_errors']).to be_empty
30
30
  end
31
31
 
32
32
  end
33
33
 
34
34
  it 'returns the list of references as the second element' do
35
- subject.to_citeproc.last.should be_a(Array)
35
+ expect(subject.to_citeproc.last).to be_a(Array)
36
36
  end
37
37
 
38
38
  end
@@ -59,10 +59,10 @@ module CiteProc
59
59
 
60
60
  it 'parses citeproc/json strings' do
61
61
  b = Bibliography.create!(js)
62
- b.should be_a(Bibliography)
63
- b.should have(2).references
64
- b.should_not have_errors
65
- b.options[:'second-field-align'].should be true
62
+ expect(b).to be_a(Bibliography)
63
+ expect(b.references.size).to eq(2)
64
+ expect(b).not_to have_errors
65
+ expect(b.options[:'second-field-align']).to be true
66
66
  end
67
67
 
68
68
  end
@@ -25,25 +25,25 @@ module CiteProc
25
25
  it { should be_empty }
26
26
 
27
27
  it 'has not been processed by default' do
28
- CitationData.new.should_not be_processed
28
+ expect(CitationData.new).not_to be_processed
29
29
  end
30
30
 
31
31
  describe '.new' do
32
32
 
33
33
  it 'accepts a citeproc hash' do
34
34
  d = CitationData.new(hash)
35
- d.should be_footnote
36
- d.should_not be_empty
37
- d[0].should be_a(CitationItem)
38
- d.index.should == 1
35
+ expect(d).to be_footnote
36
+ expect(d).not_to be_empty
37
+ expect(d[0]).to be_a(CitationItem)
38
+ expect(d.index).to eq(1)
39
39
  end
40
40
 
41
41
  it 'accepts an array of items' do
42
- CitationData.new([CitationItem.new(:id => 'id')]).should have(1).items
42
+ expect(CitationData.new([CitationItem.new(:id => 'id')]).items.size).to eq(1)
43
43
  end
44
44
 
45
45
  it 'accepts an array of hashes' do
46
- CitationData.new([{:id => 'id'}])[0].should be_a(CitationItem)
46
+ expect(CitationData.new([{:id => 'id'}])[0]).to be_a(CitationItem)
47
47
  end
48
48
 
49
49
  end
@@ -51,7 +51,7 @@ module CiteProc
51
51
  describe '#to_citeproc' do
52
52
 
53
53
  it 'returns empty an empty/default citation data element by default' do
54
- CitationData.new.to_citeproc.should == { 'citationItems' => [], 'properties' => { 'noteIndex' => 0}}
54
+ expect(CitationData.new.to_citeproc).to eq({ 'citationItems' => [], 'properties' => { 'noteIndex' => 0}})
55
55
  end
56
56
 
57
57
 
@@ -67,7 +67,7 @@ module CiteProc
67
67
  describe '.new' do
68
68
 
69
69
  it 'accepts a hash as input' do
70
- CitationItem.new(:label => 'chapter').should have_label
70
+ expect(CitationItem.new(:label => 'chapter')).to have_label
71
71
  end
72
72
 
73
73
  end
@@ -75,15 +75,15 @@ module CiteProc
75
75
  describe '#to_citeproc' do
76
76
 
77
77
  it 'returns empty citation data by default' do
78
- CitationItem.new.to_citeproc.should == {}
78
+ expect(CitationItem.new.to_citeproc).to eq({})
79
79
  end
80
80
 
81
81
  it 'returns a hash with stringified keys' do
82
- CitationItem.new(:type => :article).to_citeproc.should have_key('type')
82
+ expect(CitationItem.new(:type => :article).to_citeproc).to have_key('type')
83
83
  end
84
84
 
85
85
  it 'returns a hash with stringified values' do
86
- CitationItem.new(:type => :article).to_citeproc.should have_value('article')
86
+ expect(CitationItem.new(:type => :article).to_citeproc).to have_value('article')
87
87
  end
88
88
 
89
89
  end
@@ -10,31 +10,31 @@ module CiteProc
10
10
 
11
11
  describe 'sorting' do
12
12
  it 'treats [2003] as less than [2003,1]' do
13
- DateParts.new(2003).should be < DateParts.new(2003,1)
13
+ expect(DateParts.new(2003)).to be < DateParts.new(2003,1)
14
14
  end
15
15
 
16
16
  it 'treats [1992,9,23] as less than [1993,8,22]' do
17
- DateParts.new(1992,9,23).should be < DateParts.new(1993,8,22)
17
+ expect(DateParts.new(1992,9,23)).to be < DateParts.new(1993,8,22)
18
18
  end
19
19
 
20
20
  it 'treats [1992,9,23] as less than [1992,10,22]' do
21
- DateParts.new(1992,9,23).should be < DateParts.new(1992,10,22)
21
+ expect(DateParts.new(1992,9,23)).to be < DateParts.new(1992,10,22)
22
22
  end
23
23
 
24
24
  it 'treats [1992,9,23] as less than [1992,9,24]' do
25
- DateParts.new(1992,9,23).should be < DateParts.new(1992,9,24)
25
+ expect(DateParts.new(1992,9,23)).to be < DateParts.new(1992,9,24)
26
26
  end
27
27
 
28
28
  it 'treats [-50] as less than [-25]' do
29
- DateParts.new(-50).should be < DateParts.new(-25)
29
+ expect(DateParts.new(-50)).to be < DateParts.new(-25)
30
30
  end
31
31
 
32
32
  it 'treats [-50] as less than [-50,12]' do
33
- DateParts.new(-50).should be < DateParts.new(-50,12)
33
+ expect(DateParts.new(-50)).to be < DateParts.new(-50,12)
34
34
  end
35
35
 
36
36
  it 'treats [1994,1,23] as less than today' do
37
- DateParts.new(1994,1,23).should be < ::Date.today
37
+ expect(DateParts.new(1994,1,23)).to be < ::Date.today
38
38
  end
39
39
  end
40
40
 
@@ -42,56 +42,56 @@ module CiteProc
42
42
  let(:date) { DateParts.new(1991,8,22) }
43
43
 
44
44
  it 'creates a copy that contains the same parts' do
45
- date.dup.to_a.should == [1991,8,22]
45
+ expect(date.dup.to_a).to eq([1991,8,22])
46
46
  end
47
47
 
48
48
  it 'does not return self' do
49
- date.dup.should_not equal(date)
50
- date.dup.should == date
49
+ expect(date.dup).not_to equal(date)
50
+ expect(date.dup).to eq(date)
51
51
  end
52
52
  end
53
53
 
54
54
  describe '#update' do
55
55
  it 'accepts a hash' do
56
- DateParts.new.update(:month => 2, :year => 80).to_a.should == [80,2,nil]
56
+ expect(DateParts.new.update(:month => 2, :year => 80).to_a).to eq([80,2,nil])
57
57
  end
58
58
 
59
59
  it 'accepts an array' do
60
- DateParts.new.update([80,2]).to_a.should == [80,2,nil]
60
+ expect(DateParts.new.update([80,2]).to_a).to eq([80,2,nil])
61
61
  end
62
62
  end
63
63
 
64
64
  describe '#strftime' do
65
65
  it 'formats the date parts according to the format string' do
66
- DateParts.new(1998,2,4).strftime('FOO %0m%0d%y').should == 'FOO 020498'
66
+ expect(DateParts.new(1998,2,4).strftime('FOO %0m%0d%y')).to eq('FOO 020498')
67
67
  end
68
68
  end
69
69
 
70
70
  describe 'to_citeproc' do
71
71
  it 'returns an empty list by default' do
72
- DateParts.new.to_citeproc.should == []
72
+ expect(DateParts.new.to_citeproc).to eq([])
73
73
  end
74
74
 
75
75
  it 'returns a list with the year if only the year is set' do
76
- DateParts.new(2001).to_citeproc.should == [2001]
76
+ expect(DateParts.new(2001).to_citeproc).to eq([2001])
77
77
  end
78
78
 
79
79
  it 'supports zero parts' do
80
- DateParts.new(0,0).to_citeproc.should == [0,0]
80
+ expect(DateParts.new(0,0).to_citeproc).to eq([0,0])
81
81
  end
82
82
  end
83
83
 
84
84
  describe '#open?' do
85
85
  it 'returns false by default' do
86
- DateParts.new.should_not be_open
86
+ expect(DateParts.new).not_to be_open
87
87
  end
88
88
 
89
89
  it 'returns false for [1999,8,24]' do
90
- DateParts.new(1999, 8, 24).should_not be_open
90
+ expect(DateParts.new(1999, 8, 24)).not_to be_open
91
91
  end
92
92
 
93
93
  it 'returns true for [0]' do
94
- DateParts.new(0).should be_open
94
+ expect(DateParts.new(0)).to be_open
95
95
  end
96
96
  end
97
97
  end
@@ -113,80 +113,80 @@ module CiteProc
113
113
 
114
114
  describe '.new' do
115
115
  it 'accepts a hash as input' do
116
- Date.new(:literal => 'Summer').to_s.should == 'Summer'
116
+ expect(Date.new(:literal => 'Summer').to_s).to eq('Summer')
117
117
  end
118
118
 
119
119
  it 'accepts a hash as input and converts date parts' do
120
- Date.new(:'date-parts' => [[2003,2]]).parts[0].should be_a(Date::DateParts)
120
+ expect(Date.new(:'date-parts' => [[2003,2]]).parts[0]).to be_a(Date::DateParts)
121
121
  end
122
122
 
123
123
  it 'accepts a fixnum and treats it as the year' do
124
- Date.new(1666).year.should == 1666
124
+ expect(Date.new(1666).year).to eq(1666)
125
125
  end
126
126
 
127
127
  it 'accepts a date' do
128
- Date.new(::Date.new(1980,4)).month.should == 4
128
+ expect(Date.new(::Date.new(1980,4)).month).to eq(4)
129
129
  end
130
130
 
131
131
  it 'accepts a date and creates date parts' do
132
- Date.new(::Date.new(1980,4)).parts[0].to_citeproc.should == [1980,4,1]
132
+ expect(Date.new(::Date.new(1980,4)).parts[0].to_citeproc).to eq([1980,4,1])
133
133
  end
134
134
 
135
135
  it 'is empty by default' do
136
- Date.new.should be_empty
136
+ expect(Date.new).to be_empty
137
137
  end
138
138
 
139
139
  it 'accepts date strings' do
140
- Date.new('2009-03-19').day.should == 19
140
+ expect(Date.new('2009-03-19').day).to eq(19)
141
141
  end
142
142
 
143
143
  it 'accepts JSON strings' do
144
- Date.new('{ "date-parts": [[2001,1,19]]}').day.should == 19
144
+ expect(Date.new('{ "date-parts": [[2001,1,19]]}').day).to eq(19)
145
145
  end
146
146
 
147
147
  it 'accepts date parts in an array' do
148
- Date.new([2009,3]).month.should == 3
148
+ expect(Date.new([2009,3]).month).to eq(3)
149
149
  end
150
150
 
151
151
  it 'accepts ranges as an array' do
152
- Date.new([[2009],[2012]]).should be_range
152
+ expect(Date.new([[2009],[2012]])).to be_range
153
153
  end
154
154
 
155
155
  it 'accepts year ranges' do
156
- Date.new(2009..2012).should be_range
156
+ expect(Date.new(2009..2012)).to be_range
157
157
  end
158
158
 
159
159
  it 'accepts exclusive date ranges' do
160
- Date.new(::Date.new(2009) ... ::Date.new(2011)).end_date.year.should == 2010
160
+ expect(Date.new(::Date.new(2009) ... ::Date.new(2011)).end_date.year).to eq(2010)
161
161
  end
162
162
 
163
163
  it 'accepts inclusive date ranges' do
164
- Date.new(::Date.new(2009) .. ::Date.new(2011)).end_date.year.should == 2011
164
+ expect(Date.new(::Date.new(2009) .. ::Date.new(2011)).end_date.year).to eq(2011)
165
165
  end
166
166
 
167
167
  it 'accepts EDTF date strings' do
168
- Date.new('2009?-03-19').should be_uncertain
168
+ expect(Date.new('2009?-03-19')).to be_uncertain
169
169
  end
170
170
 
171
171
  it 'accepts EDTF intervals' do
172
- Date.new('2009-03-19/2010-11-21').parts.map(&:to_citeproc).should == [[2009,3,19],[2010,11,21]]
172
+ expect(Date.new('2009-03-19/2010-11-21').parts.map(&:to_citeproc)).to eq([[2009,3,19],[2010,11,21]])
173
173
  end
174
174
  end
175
175
 
176
176
  describe '.parse' do
177
177
  it 'returns nil by default' do
178
- Date.parse('').should be nil
179
- Date.parse(nil).should be nil
178
+ expect(Date.parse('')).to be nil
179
+ expect(Date.parse(nil)).to be nil
180
180
  end
181
181
 
182
182
  it 'parses date strings' do
183
- Date.parse('2004-10-26').year.should == 2004
183
+ expect(Date.parse('2004-10-26').year).to eq(2004)
184
184
  end
185
185
  end
186
186
 
187
187
  describe '.create' do
188
188
  it 'should accept parameters and return a new instance' do
189
- Date.create('date-parts' => [[2001, 1]]).year.should == 2001
189
+ expect(Date.create('date-parts' => [[2001, 1]]).year).to eq(2001)
190
190
  end
191
191
  end
192
192
 
@@ -194,12 +194,12 @@ module CiteProc
194
194
  let(:date) { Date.new([1991,8]) }
195
195
 
196
196
  it 'creates a copy that contains the same parts' do
197
- date.dup.parts.map(&:to_citeproc).should == [[1991,8]]
197
+ expect(date.dup.parts.map(&:to_citeproc)).to eq([[1991,8]])
198
198
  end
199
199
 
200
200
  it 'copies uncertainty' do
201
- date.dup.should_not be_uncertain
202
- date.uncertain!.dup.should be_uncertain
201
+ expect(date.dup).not_to be_uncertain
202
+ expect(date.uncertain!.dup).to be_uncertain
203
203
  end
204
204
 
205
205
  it 'makes a deep copy of attributes' do
@@ -211,95 +211,95 @@ module CiteProc
211
211
  end
212
212
 
213
213
  it 'does not return self' do
214
- date.dup.should_not equal(date)
215
- date.dup.should == date
214
+ expect(date.dup).not_to equal(date)
215
+ expect(date.dup).to eq(date)
216
216
  end
217
217
  end
218
218
 
219
219
  describe 'literal dates' do
220
220
  it 'is not literal by default' do
221
- Date.new.should_not be_literal
221
+ expect(Date.new).not_to be_literal
222
222
  end
223
223
 
224
224
  it 'is literal if it contains only a literal field' do
225
- Date.create(:literal => 'foo').should be_literal
225
+ expect(Date.create(:literal => 'foo')).to be_literal
226
226
  end
227
227
 
228
228
  it 'is literal if it contains a literal field' do
229
- Date.create('date-parts' => [[2000]], :literal => 'foo').should be_literal
229
+ expect(Date.create('date-parts' => [[2000]], :literal => 'foo')).to be_literal
230
230
  end
231
231
  end
232
232
 
233
233
  describe 'seasons' do
234
234
  it 'is no season by default' do
235
- Date.new.should_not be_season
235
+ expect(Date.new).not_to be_season
236
236
  end
237
237
 
238
238
  it 'is a season if contains only a season field' do
239
- Date.new(:season => 'Winter').should be_season
239
+ expect(Date.new(:season => 'Winter')).to be_season
240
240
  end
241
241
 
242
242
  it 'is a season if contains a season field' do
243
- Date.new(:'date-parts' => [[2001]], :season => 'Winter').should be_season
243
+ expect(Date.new(:'date-parts' => [[2001]], :season => 'Winter')).to be_season
244
244
  end
245
245
  end
246
246
 
247
247
  describe 'uncertain dates' do
248
248
  it 'are uncertain' do
249
- Date.new({ 'date-parts' => [[-225]], 'circa' => '1' }).should be_uncertain
250
- Date.new { |d| d.parts = [[-225]]; d.uncertain! }.should_not be_certain
249
+ expect(Date.new({ 'date-parts' => [[-225]], 'circa' => '1' })).to be_uncertain
250
+ expect(Date.new { |d| d.parts = [[-225]]; d.uncertain! }).not_to be_certain
251
251
  end
252
252
 
253
253
  describe '#(un)certain!' do
254
254
  it 'returns self' do
255
- ad2k.uncertain!.should equal(ad2k)
256
- ad2k.certain!.should equal(ad2k)
255
+ expect(ad2k.uncertain!).to equal(ad2k)
256
+ expect(ad2k.certain!).to equal(ad2k)
257
257
  end
258
258
  end
259
259
  end
260
260
 
261
261
  describe 'sorting' do
262
262
  it 'dates with more date-parts will come after those with fewer parts' do
263
- (ad2k < may && may < first_of_may).should be true
263
+ expect(ad2k < may && may < first_of_may).to be true
264
264
  end
265
265
 
266
266
  it 'negative years are sorted inversely' do
267
- [ad50, bc100, bc50, ad100].sort.map(&:year).should == [-100, -50, 50, 100]
267
+ expect([ad50, bc100, bc50, ad100].sort.map(&:year)).to eq([-100, -50, 50, 100])
268
268
  end
269
269
 
270
270
  it 'can be compared to dates' do
271
- ad50.should be < ::Date.new(50,2)
272
- ad50.should be > ::Date.new(49)
271
+ expect(ad50).to be < ::Date.new(50,2)
272
+ expect(ad50).to be > ::Date.new(49)
273
273
  end
274
274
  end
275
275
 
276
276
  describe '#start_date' do
277
277
  it 'returns nil by default' do
278
- Date.new.start_date.should be_nil
278
+ expect(Date.new.start_date).to be_nil
279
279
  end
280
280
 
281
281
  it 'returns a ruby date when date-parts are set' do
282
- Date.new(1999).start_date.year.should == 1999
282
+ expect(Date.new(1999).start_date.year).to eq(1999)
283
283
  end
284
284
  end
285
285
 
286
286
  describe '#end_date' do
287
287
  it 'returns nil by default' do
288
- Date.new.end_date.should be_nil
288
+ expect(Date.new.end_date).to be_nil
289
289
  end
290
290
 
291
291
  it 'returns nil when there is a single date-parts set' do
292
- Date.new(1312).end_date.should be_nil
292
+ expect(Date.new(1312).end_date).to be_nil
293
293
  end
294
294
 
295
295
  it 'returns a ruby date when date-parts are a closed range' do
296
- Date.new(1999..2000).end_date.year.should == 2000
296
+ expect(Date.new(1999..2000).end_date.year).to eq(2000)
297
297
  end
298
298
  end
299
299
 
300
300
  describe '#-@' do
301
301
  it 'inverts the year' do
302
- (-ad50).should == bc50
302
+ expect(-ad50).to eq(bc50)
303
303
  end
304
304
  end
305
305
 
@@ -312,112 +312,112 @@ module CiteProc
312
312
  describe 'b.c. and a.d.' do
313
313
 
314
314
  it 'the year 993 is a.d.' do
315
- Date.new(993).should be_ad
315
+ expect(Date.new(993)).to be_ad
316
316
  end
317
317
 
318
318
  it 'the year 1000 is not a.d.' do
319
- Date.new(1000).should_not be_ad
319
+ expect(Date.new(1000)).not_to be_ad
320
320
  end
321
321
 
322
322
  it 'the year 993 is not b.c.' do
323
- Date.new(993).should_not be_bc
323
+ expect(Date.new(993)).not_to be_bc
324
324
  end
325
325
 
326
326
  it 'the year 0 is a.d.' do
327
- Date.new(0).should be_ad
327
+ expect(Date.new(0)).to be_ad
328
328
  end
329
329
 
330
330
  it 'the year 0 is not b.c.' do
331
- Date.new(0).should_not be_bc
331
+ expect(Date.new(0)).not_to be_bc
332
332
  end
333
333
 
334
334
  it 'the year -33 is not a.d.' do
335
- Date.new(-33).should_not be_ad
335
+ expect(Date.new(-33)).not_to be_ad
336
336
  end
337
337
 
338
338
  it 'the year -33 is b.c.' do
339
- Date.new(-33).should be_bc
339
+ expect(Date.new(-33)).to be_bc
340
340
  end
341
341
 
342
342
  it 'today is not a.d.' do
343
- Date.today.should_not be_ad
343
+ expect(Date.today).not_to be_ad
344
344
  end
345
345
 
346
346
  it 'today is not b.c.' do
347
- Date.today.should_not be_bc
347
+ expect(Date.today).not_to be_bc
348
348
  end
349
349
 
350
350
  it 'the year 2000 is not a.d.' do
351
- ad2k.should_not be_ad
351
+ expect(ad2k).not_to be_ad
352
352
  end
353
353
 
354
354
  end
355
355
 
356
356
  describe '#empty?' do
357
357
  it 'returns true by default' do
358
- Date.new.should be_empty
358
+ expect(Date.new).to be_empty
359
359
  end
360
360
 
361
361
  it 'returns true when it contains no date parts' do
362
- Date.new({}).should be_empty
362
+ expect(Date.new({})).to be_empty
363
363
  end
364
364
 
365
365
  it 'returns false for today' do
366
- Date.today.should_not be_empty
366
+ expect(Date.today).not_to be_empty
367
367
  end
368
368
 
369
369
  it 'returns false for literal dates' do
370
- Date.new(:literal => 'foo').should_not be_empty
370
+ expect(Date.new(:literal => 'foo')).not_to be_empty
371
371
  end
372
372
 
373
373
  it 'returns false for seasons' do
374
- Date.new(:season => 'Summer').should_not be_empty
374
+ expect(Date.new(:season => 'Summer')).not_to be_empty
375
375
  end
376
376
  end
377
377
 
378
378
  describe '#to_json' do
379
379
  it 'supports simple parts' do
380
- Date.new(%w{2000 1 15}).to_json.should == '{"date-parts":[[2000,1,15]]}'
380
+ expect(Date.new(%w{2000 1 15}).to_json).to eq('{"date-parts":[[2000,1,15]]}')
381
381
  end
382
382
 
383
383
  it 'supports string parts' do
384
- Date.new(['2000', '1', '15']).to_json.should == '{"date-parts":[[2000,1,15]]}'
384
+ expect(Date.new(['2000', '1', '15']).to_json).to eq('{"date-parts":[[2000,1,15]]}')
385
385
  end
386
386
 
387
387
  it 'supports integer parts' do
388
- Date.new([2000, 1, 15]).to_json.should == '{"date-parts":[[2000,1,15]]}'
388
+ expect(Date.new([2000, 1, 15]).to_json).to eq('{"date-parts":[[2000,1,15]]}')
389
389
  end
390
390
 
391
391
  it 'supports mixed parts' do
392
- Date.new(['2000', 1, '15']).to_json.should == '{"date-parts":[[2000,1,15]]}'
392
+ expect(Date.new(['2000', 1, '15']).to_json).to eq('{"date-parts":[[2000,1,15]]}')
393
393
  end
394
394
 
395
395
  it 'supports negative years' do
396
- Date.new(-200).to_json.should == '{"date-parts":[[-200]]}'
396
+ expect(Date.new(-200).to_json).to eq('{"date-parts":[[-200]]}')
397
397
  end
398
398
 
399
399
  it 'treats seasons as a strings' do
400
- Date.create({:season => '1', 'date-parts' => [[1950]]}).to_json.should =~ /"season":"1"/
400
+ expect(Date.create({:season => '1', 'date-parts' => [[1950]]}).to_json).to match(/"season":"1"/)
401
401
  end
402
402
 
403
403
  it 'supports seasons' do
404
- Date.create({:season => 'Trinity', 'date-parts' => [[1975]]}).to_json.should =~ /"season":"Trinity"/
404
+ expect(Date.create({:season => 'Trinity', 'date-parts' => [[1975]]}).to_json).to match(/"season":"Trinity"/)
405
405
  end
406
406
 
407
407
  it 'supports string literals' do
408
- Date.new(:literal => '13th century').to_json.should == '{"literal":"13th century"}'
408
+ expect(Date.new(:literal => '13th century').to_json).to eq('{"literal":"13th century"}')
409
409
  end
410
410
 
411
411
  it 'supports raw strings' do
412
- Date.new(:raw => '23 May 1955').to_json.should == '{"date-parts":[[1955,5,23]]}'
412
+ expect(Date.new(:raw => '23 May 1955').to_json).to eq('{"date-parts":[[1955,5,23]]}')
413
413
  end
414
414
 
415
415
  it 'supports closed ranges' do
416
- Date.new([[2000,11],[2000,12]]).to_json.should == '{"date-parts":[[2000,11],[2000,12]]}'
416
+ expect(Date.new([[2000,11],[2000,12]]).to_json).to eq('{"date-parts":[[2000,11],[2000,12]]}')
417
417
  end
418
418
 
419
419
  it 'supports open ranges' do
420
- Date.new([[2000,11],[0,0]]).to_json.should == '{"date-parts":[[2000,11],[0,0]]}'
420
+ expect(Date.new([[2000,11],[0,0]]).to_json).to eq('{"date-parts":[[2000,11],[0,0]]}')
421
421
  end
422
422
  end
423
423