citeproc-ruby 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,7 +15,7 @@ module CiteProc
15
15
  let(:node) { CSL::Style::Choose.new }
16
16
 
17
17
  it 'returns an empty string by default' do
18
- renderer.render(item, node).should == ''
18
+ expect(renderer.render(item, node)).to eq('')
19
19
  end
20
20
 
21
21
  describe 'when there is a single nested block' do
@@ -30,12 +30,12 @@ module CiteProc
30
30
  it 'returns the content of the nested node when the condition evaluates' do
31
31
  block[:variable] = 'issue'
32
32
  item.data[:issue] = 1
33
- renderer.render(item, node).should == 'retrieved'
33
+ expect(renderer.render(item, node)).to eq('retrieved')
34
34
  end
35
35
 
36
36
  it 'returns an empty string when the condition does not hold' do
37
37
  block[:variable] = 'issue'
38
- renderer.render(item, node).should == ''
38
+ expect(renderer.render(item, node)).to eq('')
39
39
  end
40
40
  end
41
41
  end
@@ -44,14 +44,14 @@ module CiteProc
44
44
  let(:node) { CSL::Style::Choose::Block.new }
45
45
 
46
46
  it 'returns an empty string by default' do
47
- renderer.render(item, node).should == ''
47
+ expect(renderer.render(item, node)).to eq('')
48
48
  end
49
49
 
50
50
  describe 'when there is a text node in the block' do
51
51
  before(:each) { node << CSL::Style::Text.new( :term => 'retrieved') }
52
52
 
53
53
  it 'returns the content of the nested node when there is no condition' do
54
- renderer.render(item, node).should == 'retrieved'
54
+ expect(renderer.render(item, node)).to eq('retrieved')
55
55
  end
56
56
  end
57
57
  end
@@ -60,38 +60,38 @@ module CiteProc
60
60
  let(:node) { CSL::Style::Choose::Block.new }
61
61
 
62
62
  it 'returns true by default (else block)' do
63
- renderer.evaluates?(item, node).should be_true
63
+ expect(renderer.evaluates?(item, node)).to be_truthy
64
64
  end
65
65
 
66
66
  it 'fails if there is an unknown condition type' do
67
- node.stub(:conditions).and_return([[:unknown, :all?, 'x']])
68
- lambda { renderer.evaluates?(item, node) }.should raise_error
67
+ allow(node).to receive(:conditions).and_return([[:unknown, :all?, 'x']])
68
+ expect { renderer.evaluates?(item, node) }.to raise_error
69
69
  end
70
70
 
71
71
  it 'returns false for disambiguate (implementation pending)' do
72
72
  node[:disambiguate] = true
73
- renderer.evaluates?(item, node).should be_false
73
+ expect(renderer.evaluates?(item, node)).to be_falsey
74
74
  end
75
75
 
76
76
  it 'returns false for position (implementation pending)' do
77
77
  node[:position] = 'first'
78
- renderer.evaluates?(item, node).should be_false
78
+ expect(renderer.evaluates?(item, node)).to be_falsey
79
79
  end
80
80
 
81
81
  describe 'for is-numeric conditions' do
82
82
  before { node[:'is-numeric'] = 'note archive' }
83
83
 
84
84
  it 'returns false unless all variables are numeric' do
85
- renderer.evaluates?(item, node).should be_false
85
+ expect(renderer.evaluates?(item, node)).to be_falsey
86
86
 
87
87
  item.data[:archive] = 1
88
- renderer.evaluates?(item, node).should be_false
88
+ expect(renderer.evaluates?(item, node)).to be_falsey
89
89
 
90
90
  item.data[:note] = 'L2d'
91
- renderer.evaluates?(item, node).should be_true
91
+ expect(renderer.evaluates?(item, node)).to be_truthy
92
92
 
93
93
  item.data[:archive] = 'second'
94
- renderer.evaluates?(item, node).should be_false
94
+ expect(renderer.evaluates?(item, node)).to be_falsey
95
95
  end
96
96
  end
97
97
 
@@ -99,13 +99,13 @@ module CiteProc
99
99
  before { node[:'is-uncertain-date'] = 'issued' }
100
100
 
101
101
  it 'returns false unless all variables contain uncertain dates' do
102
- renderer.evaluates?(item, node).should be_false
102
+ expect(renderer.evaluates?(item, node)).to be_falsey
103
103
 
104
104
  item.data[:issued] = 2012
105
- renderer.evaluates?(item, node).should be_false
105
+ expect(renderer.evaluates?(item, node)).to be_falsey
106
106
 
107
107
  item.data[:issued].uncertain!
108
- renderer.evaluates?(item, node).should be_true
108
+ expect(renderer.evaluates?(item, node)).to be_truthy
109
109
  end
110
110
  end
111
111
 
@@ -113,40 +113,40 @@ module CiteProc
113
113
  before { node[:locator] = 'figure book sub-verbo' }
114
114
 
115
115
  it 'returns false unless the locator matches all of the given locators' do
116
- renderer.evaluates?(item, node).should be_false
116
+ expect(renderer.evaluates?(item, node)).to be_falsey
117
117
 
118
118
  item.locator = :book
119
- renderer.evaluates?(item, node).should be_false
119
+ expect(renderer.evaluates?(item, node)).to be_falsey
120
120
 
121
121
  item.locator = 'volume'
122
- renderer.evaluates?(item, node).should be_false
122
+ expect(renderer.evaluates?(item, node)).to be_falsey
123
123
 
124
124
  item.locator = 'figure'
125
- renderer.evaluates?(item, node).should be_false
125
+ expect(renderer.evaluates?(item, node)).to be_falsey
126
126
  end
127
127
 
128
128
  describe 'when the match attribute is set to "any"' do
129
129
  before { node[:match] = 'any' }
130
130
 
131
131
  it 'returns false unless the locator matches any of the given locators' do
132
- renderer.evaluates?(item, node).should be_false
132
+ expect(renderer.evaluates?(item, node)).to be_falsey
133
133
 
134
134
  item.locator = :book
135
- renderer.evaluates?(item, node).should be_true
135
+ expect(renderer.evaluates?(item, node)).to be_truthy
136
136
 
137
137
  item.locator = 'volume'
138
- renderer.evaluates?(item, node).should be_false
138
+ expect(renderer.evaluates?(item, node)).to be_falsey
139
139
 
140
140
  item.locator = 'figure'
141
- renderer.evaluates?(item, node).should be_true
141
+ expect(renderer.evaluates?(item, node)).to be_truthy
142
142
  end
143
143
 
144
144
  it 'matches "sub verbo" as "sub-verbo"' do
145
145
  item.locator = 'sub-verbo'
146
- renderer.evaluates?(item, node).should be_true
146
+ expect(renderer.evaluates?(item, node)).to be_truthy
147
147
 
148
148
  item.locator = 'sub verbo'
149
- renderer.evaluates?(item, node).should be_true
149
+ expect(renderer.evaluates?(item, node)).to be_truthy
150
150
  end
151
151
  end
152
152
  end
@@ -155,32 +155,32 @@ module CiteProc
155
155
  before { node[:type] = 'book treaty' }
156
156
 
157
157
  it 'returns false unless the type matches all of the given types' do
158
- renderer.evaluates?(item, node).should be_false
158
+ expect(renderer.evaluates?(item, node)).to be_falsey
159
159
 
160
160
  item.data[:type] = :book
161
- renderer.evaluates?(item, node).should be_false
161
+ expect(renderer.evaluates?(item, node)).to be_falsey
162
162
 
163
163
  item.data[:type] = 'article'
164
- renderer.evaluates?(item, node).should be_false
164
+ expect(renderer.evaluates?(item, node)).to be_falsey
165
165
 
166
166
  item.data[:type] = 'treaty'
167
- renderer.evaluates?(item, node).should be_false
167
+ expect(renderer.evaluates?(item, node)).to be_falsey
168
168
  end
169
169
 
170
170
  describe 'when the match attribute is set to "any"' do
171
171
  before { node[:match] = 'any' }
172
172
 
173
173
  it 'returns false unless the locator matches any of the given locators' do
174
- renderer.evaluates?(item, node).should be_false
174
+ expect(renderer.evaluates?(item, node)).to be_falsey
175
175
 
176
176
  item.data[:type] = :book
177
- renderer.evaluates?(item, node).should be_true
177
+ expect(renderer.evaluates?(item, node)).to be_truthy
178
178
 
179
179
  item.data[:type] = 'article'
180
- renderer.evaluates?(item, node).should be_false
180
+ expect(renderer.evaluates?(item, node)).to be_falsey
181
181
 
182
182
  item.data[:type] = 'treaty'
183
- renderer.evaluates?(item, node).should be_true
183
+ expect(renderer.evaluates?(item, node)).to be_truthy
184
184
  end
185
185
  end
186
186
  end
@@ -189,32 +189,32 @@ module CiteProc
189
189
  before { node[:variable] = 'volume issue' }
190
190
 
191
191
  it 'returns false unless the item has all variables' do
192
- renderer.evaluates?(item, node).should be_false
192
+ expect(renderer.evaluates?(item, node)).to be_falsey
193
193
 
194
194
  item.data[:volume] = 1
195
- renderer.evaluates?(item, node).should be_false
195
+ expect(renderer.evaluates?(item, node)).to be_falsey
196
196
 
197
197
  item.data[:issue] = 1
198
- renderer.evaluates?(item, node).should be_true
198
+ expect(renderer.evaluates?(item, node)).to be_truthy
199
199
 
200
200
  item.data[:volume] = nil
201
- renderer.evaluates?(item, node).should be_false
201
+ expect(renderer.evaluates?(item, node)).to be_falsey
202
202
  end
203
203
 
204
204
  describe 'with internal negations' do
205
205
  before { node[:variable] = 'volume not:issue' }
206
206
 
207
207
  it 'returns false unless the item has (or does not have) all variables' do
208
- renderer.evaluates?(item, node).should be_false
208
+ expect(renderer.evaluates?(item, node)).to be_falsey
209
209
 
210
210
  item.data[:volume] = 1
211
- renderer.evaluates?(item, node).should be_true
211
+ expect(renderer.evaluates?(item, node)).to be_truthy
212
212
 
213
213
  item.data[:issue] = 1
214
- renderer.evaluates?(item, node).should be_false
214
+ expect(renderer.evaluates?(item, node)).to be_falsey
215
215
 
216
216
  item.data[:volume] = nil
217
- renderer.evaluates?(item, node).should be_false
217
+ expect(renderer.evaluates?(item, node)).to be_falsey
218
218
  end
219
219
  end
220
220
 
@@ -222,32 +222,32 @@ module CiteProc
222
222
  before { node[:match] = 'any' }
223
223
 
224
224
  it 'returns false unless the item has any of the variables' do
225
- renderer.evaluates?(item, node).should be_false
225
+ expect(renderer.evaluates?(item, node)).to be_falsey
226
226
 
227
227
  item.data[:volume] = 1
228
- renderer.evaluates?(item, node).should be_true
228
+ expect(renderer.evaluates?(item, node)).to be_truthy
229
229
 
230
230
  item.data[:issue] = 1
231
- renderer.evaluates?(item, node).should be_true
231
+ expect(renderer.evaluates?(item, node)).to be_truthy
232
232
 
233
233
  item.data[:volume] = nil
234
- renderer.evaluates?(item, node).should be_true
234
+ expect(renderer.evaluates?(item, node)).to be_truthy
235
235
  end
236
236
 
237
237
  describe 'with internal negations' do
238
238
  before { node[:variable] = 'volume not:issue' }
239
239
 
240
240
  it 'returns false unless the item has (or does not have) any of the variables' do
241
- renderer.evaluates?(item, node).should be_true
241
+ expect(renderer.evaluates?(item, node)).to be_truthy
242
242
 
243
243
  item.data[:volume] = 1
244
- renderer.evaluates?(item, node).should be_true
244
+ expect(renderer.evaluates?(item, node)).to be_truthy
245
245
 
246
246
  item.data[:issue] = 1
247
- renderer.evaluates?(item, node).should be_true
247
+ expect(renderer.evaluates?(item, node)).to be_truthy
248
248
 
249
249
  item.data[:volume] = nil
250
- renderer.evaluates?(item, node).should be_false
250
+ expect(renderer.evaluates?(item, node)).to be_falsey
251
251
  end
252
252
  end
253
253
  end
@@ -256,32 +256,32 @@ module CiteProc
256
256
  before { node[:match] = 'none' }
257
257
 
258
258
  it 'returns false unless the item has none of the variables' do
259
- renderer.evaluates?(item, node).should be_true
259
+ expect(renderer.evaluates?(item, node)).to be_truthy
260
260
 
261
261
  item.data[:volume] = 1
262
- renderer.evaluates?(item, node).should be_false
262
+ expect(renderer.evaluates?(item, node)).to be_falsey
263
263
 
264
264
  item.data[:issue] = 1
265
- renderer.evaluates?(item, node).should be_false
265
+ expect(renderer.evaluates?(item, node)).to be_falsey
266
266
 
267
267
  item.data[:volume] = nil
268
- renderer.evaluates?(item, node).should be_false
268
+ expect(renderer.evaluates?(item, node)).to be_falsey
269
269
  end
270
270
 
271
271
  describe 'with internal negations' do
272
272
  before { node[:variable] = 'volume not:issue' }
273
273
 
274
274
  it 'returns false unless the item has (or does not have) none of the variables' do
275
- renderer.evaluates?(item, node).should be_false
275
+ expect(renderer.evaluates?(item, node)).to be_falsey
276
276
 
277
277
  item.data[:volume] = 1
278
- renderer.evaluates?(item, node).should be_false
278
+ expect(renderer.evaluates?(item, node)).to be_falsey
279
279
 
280
280
  item.data[:issue] = 1
281
- renderer.evaluates?(item, node).should be_false
281
+ expect(renderer.evaluates?(item, node)).to be_falsey
282
282
 
283
283
  item.data[:volume] = nil
284
- renderer.evaluates?(item, node).should be_true
284
+ expect(renderer.evaluates?(item, node)).to be_truthy
285
285
  end
286
286
  end
287
287
  end
@@ -19,7 +19,7 @@ module CiteProc
19
19
  before(:each) { item.data[:issued] = '2012-01-27' }
20
20
 
21
21
  it "uses the locale's date parts to render the date" do
22
- renderer.render(item, node).should == '01/27/2012'
22
+ expect(renderer.render(item, node)).to eq('01/27/2012')
23
23
  end
24
24
  end
25
25
  end
@@ -31,39 +31,39 @@ module CiteProc
31
31
  before(:each) { item.data[:issued] = '2012-01-27' }
32
32
 
33
33
  it 'returns an empty string by default' do
34
- renderer.render_date(item, node).should == ''
34
+ expect(renderer.render_date(item, node)).to eq('')
35
35
  end
36
36
 
37
37
  describe 'and given a node with a year part' do
38
38
  before(:each) { node << CSL::Style::DatePart.new(:name => 'year') }
39
39
 
40
40
  it 'returns the year as "2012"' do
41
- renderer.render_date(item, node).should == '2012'
41
+ expect(renderer.render_date(item, node)).to eq('2012')
42
42
  end
43
43
 
44
44
  describe 'and a day part' do
45
45
  before(:each) { node << CSL::Style::DatePart.new(:name => 'day') }
46
46
 
47
47
  it 'returns "201227"' do
48
- renderer.render_date(item, node).should == '201227'
48
+ expect(renderer.render_date(item, node)).to eq('201227')
49
49
  end
50
50
 
51
51
  it 'applies delimiters when set on the node' do
52
52
  node[:delimiter] = '/'
53
- renderer.render_date(item, node).should == '2012/27'
53
+ expect(renderer.render_date(item, node)).to eq('2012/27')
54
54
  end
55
55
 
56
56
  describe 'and a month part' do
57
57
  before(:each) { node << CSL::Style::DatePart.new(:name => 'month') }
58
58
 
59
59
  it 'returns "201227January"' do
60
- renderer.render_date(item, node).should == '201227January'
60
+ expect(renderer.render_date(item, node)).to eq('201227January')
61
61
  end
62
62
 
63
63
  it 'returns "2012/27/01" when the month form set to "numeric-leading-zeros" and the node has a delimiter "/"' do
64
64
  node.parts.last[:form] = 'numeric-leading-zeros'
65
65
  node[:delimiter] = '/'
66
- renderer.render_date(item, node).should == '2012/27/01'
66
+ expect(renderer.render_date(item, node)).to eq('2012/27/01')
67
67
  end
68
68
  end
69
69
  end
@@ -84,25 +84,25 @@ module CiteProc
84
84
  let(:independence) { CiteProc::Date.new([1776, 7, 4]) }
85
85
 
86
86
  it 'returns an empty string by default' do
87
- renderer.render_date_part(CiteProc::Date.today, node).should == ''
87
+ expect(renderer.render_date_part(CiteProc::Date.today, node)).to eq('')
88
88
  end
89
89
 
90
90
  describe 'when the name is set to "day"' do
91
91
  before(:each) { node[:name] = 'day' }
92
92
 
93
93
  it 'renders the day as number by default' do
94
- renderer.render_date_part(today, node).should == today.day.to_s
94
+ expect(renderer.render_date_part(today, node)).to eq(today.day.to_s)
95
95
  end
96
96
 
97
97
  it 'renders the day as an ordinal number when the form is set to "ordinal"' do
98
98
  node[:form] = 'ordinal'
99
- renderer.render_date_part(independence, node).should == '4th'
99
+ expect(renderer.render_date_part(independence, node)).to eq('4th')
100
100
 
101
101
  renderer.locale.limit_day_ordinals!
102
- renderer.render_date_part(independence, node).should == '4'
102
+ expect(renderer.render_date_part(independence, node)).to eq('4')
103
103
 
104
104
  independence.day = 1
105
- renderer.render_date_part(independence, node).should == '1st'
105
+ expect(renderer.render_date_part(independence, node)).to eq('1st')
106
106
  end
107
107
  end
108
108
 
@@ -110,34 +110,34 @@ module CiteProc
110
110
  before(:each) { node[:name] = 'month' }
111
111
 
112
112
  it "renders the month's full name by default" do
113
- renderer.render_date_part(january, node).should == 'January'
114
- renderer.render_date_part(december, node).should == 'December'
113
+ expect(renderer.render_date_part(january, node)).to eq('January')
114
+ expect(renderer.render_date_part(december, node)).to eq('December')
115
115
  end
116
116
 
117
117
  it "renders the month's full name as the long form" do
118
118
  node[:form] = 'long'
119
- renderer.render_date_part(january, node).should == 'January'
119
+ expect(renderer.render_date_part(january, node)).to eq('January')
120
120
  end
121
121
 
122
122
  it "renders the month's short name as the short form" do
123
123
  node[:form] = 'short'
124
- renderer.render_date_part(january, node).should == 'Jan.'
124
+ expect(renderer.render_date_part(january, node)).to eq('Jan.')
125
125
  end
126
126
 
127
127
  it 'renders the month as number as the numeric form' do
128
128
  node[:form] = 'numeric'
129
- renderer.render_date_part(january, node).should == '1'
129
+ expect(renderer.render_date_part(january, node)).to eq('1')
130
130
  end
131
131
 
132
132
  it 'renders the month as number with a leading zero when form is set to numeric-leading-zeros' do
133
133
  node[:form] = 'numeric-leading-zeros'
134
- renderer.render_date_part(january, node).should == '01'
135
- renderer.render_date_part(december, node).should == '12'
134
+ expect(renderer.render_date_part(january, node)).to eq('01')
135
+ expect(renderer.render_date_part(december, node)).to eq('12')
136
136
  end
137
137
 
138
138
  it 'renders the name of the season when a season is set' do
139
139
  january.season = 4
140
- renderer.render_date_part(january, node).should == 'Winter'
140
+ expect(renderer.render_date_part(january, node)).to eq('Winter')
141
141
  end
142
142
  end
143
143
 
@@ -145,17 +145,17 @@ module CiteProc
145
145
  before(:each) { node[:name] = 'year' }
146
146
 
147
147
  it 'renders the full year by default' do
148
- renderer.render_date_part(today, node).should == today.year.to_s
148
+ expect(renderer.render_date_part(today, node)).to eq(today.year.to_s)
149
149
  end
150
150
 
151
151
  it 'renders the full year when form is set to long' do
152
152
  node[:form] = 'long'
153
- renderer.render_date_part(january, node).should == '2012'
153
+ expect(renderer.render_date_part(january, node)).to eq('2012')
154
154
  end
155
155
 
156
156
  it 'renders the short year when form is set to short' do
157
157
  node[:form] = 'short'
158
- renderer.render_date_part(january, node).should == '12'
158
+ expect(renderer.render_date_part(january, node)).to eq('12')
159
159
  end
160
160
 
161
161
  it 'adds AD if applicable' do