csl 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,15 +6,15 @@ module CSL
6
6
 
7
7
  let(:date) { Locale::Date.new }
8
8
 
9
- it { should_not be_nil }
9
+ it { is_expected.not_to be_nil }
10
10
 
11
- it { should be_text }
12
- it { should_not be_numeric }
11
+ it { is_expected.to be_text }
12
+ it { is_expected.not_to be_numeric }
13
13
 
14
14
  describe '#parts' do
15
15
 
16
16
  it 'returns nil by default' do
17
- date.parts.should be_empty
17
+ expect(date.parts).to be_empty
18
18
  end
19
19
 
20
20
  end
@@ -22,11 +22,11 @@ module CSL
22
22
  describe '#to_xml' do
23
23
 
24
24
  it 'returns <date/> by default' do
25
- Locale::Date.new.to_xml.should == '<date/>'
25
+ expect(Locale::Date.new.to_xml).to eq('<date/>')
26
26
  end
27
27
 
28
28
  it 'returns <date form="numeric"/> for an empty numeric date' do
29
- Locale::Date.new(:form => 'numeric').to_xml.should == '<date form="numeric"/>'
29
+ expect(Locale::Date.new(:form => 'numeric').to_xml).to eq('<date form="numeric"/>')
30
30
  end
31
31
 
32
32
  end
@@ -35,24 +35,24 @@ module CSL
35
35
 
36
36
  describe Locale::DatePart do
37
37
 
38
- it { should_not be_nil }
38
+ it { is_expected.not_to be_nil }
39
39
 
40
- it { should_not be_day }
41
- it { should_not be_month }
42
- it { should_not be_year }
40
+ it { is_expected.not_to be_day }
41
+ it { is_expected.not_to be_month }
42
+ it { is_expected.not_to be_year }
43
43
 
44
44
  describe '#to_xml' do
45
45
 
46
46
  it 'returns <date-part/> by default' do
47
- Locale::DatePart.new.to_xml.should == "<date-part/>"
47
+ expect(Locale::DatePart.new.to_xml).to eq("<date-part/>")
48
48
  end
49
49
 
50
50
  it 'returns <date-part name="year"/> when the name is "year"' do
51
- Locale::DatePart.new(:name => 'year').to_xml.should == '<date-part name="year"/>'
51
+ expect(Locale::DatePart.new(:name => 'year').to_xml).to eq('<date-part name="year"/>')
52
52
  end
53
53
 
54
54
  it 'returns <date-part name="month" form="numeric" prefix="-"/> for a numeric month with prefix "-"' do
55
- Locale::DatePart.new(:name => 'month', :form => 'numeric', :prefix => '-').to_xml.should match(/(\s(name|form|prefix)="[^"]+"){3}/)
55
+ expect(Locale::DatePart.new(:name => 'month', :form => 'numeric', :prefix => '-').to_xml).to match(/(\s(name|form|prefix)="[^"]+"){3}/)
56
56
  end
57
57
 
58
58
  end
@@ -3,15 +3,15 @@ require 'spec_helper'
3
3
  module CSL
4
4
  describe Locale::StyleOptions do
5
5
 
6
- it { should_not be nil }
6
+ it { is_expected.not_to be nil }
7
7
 
8
8
  it 'punctuation-in-quote is false by default' do
9
- subject[:'punctuation-in-quote'].should be false
9
+ expect(subject[:'punctuation-in-quote']).to be false
10
10
  end
11
11
 
12
12
  describe '#to_xml' do
13
13
  it 'returns <style-options punctuation-in-quote="false"/> by default' do
14
- subject.to_xml.should =~ /<style-options\/>/
14
+ expect(subject.to_xml).to match(/<style-options\/>/)
15
15
  end
16
16
  end
17
17
 
@@ -4,17 +4,17 @@ require 'spec_helper'
4
4
  module CSL
5
5
  describe Locale::Terms do
6
6
 
7
- it { should_not be nil }
7
+ it { is_expected.not_to be nil }
8
8
 
9
9
  describe '#to_xml' do
10
10
  it 'returns <terms/> by default' do
11
- subject.to_xml.should == '<terms/>'
11
+ expect(subject.to_xml).to eq('<terms/>')
12
12
  end
13
13
  end
14
14
 
15
15
  describe '.specialize' do
16
16
  it 'filters the passed in hash to contain only match-able entries' do
17
- Locale::Term.specialize({ :form => 'short', :foo => 'bar' }).should == { :form => 'short' }
17
+ expect(Locale::Term.specialize({ :form => 'short', :foo => 'bar' })).to eq({ :form => 'short' })
18
18
  end
19
19
  end
20
20
 
@@ -39,7 +39,7 @@ module CSL
39
39
  ordinal ordinal-01 ordinal-02 ordinal-03 ordinal
40
40
  }.each_with_index do |ordinal, number|
41
41
  it "returns #{ordinal.inspect} for #{number}" do
42
- en.ordinalize(number)[:name].should == ordinal
42
+ expect(en.ordinalize(number)[:name]).to eq(ordinal)
43
43
  end
44
44
  end
45
45
  end
@@ -84,32 +84,32 @@ module CSL
84
84
  end
85
85
 
86
86
  it 'returns nil if there is no matching term' do
87
- en.lookup(:foo).should be_nil
87
+ expect(en.lookup(:foo)).to be_nil
88
88
  end
89
89
 
90
90
  it 'returns the long form by default' do
91
- en.lookup(:page).should be_long
91
+ expect(en.lookup(:page)).to be_long
92
92
  end
93
93
 
94
94
  it 'returns the term in the passed-in form if available' do
95
- en.lookup(:section, :form => 'long').should be_long
96
- en.lookup(:section, :form => 'short').should be_short
97
- en.lookup(:section, :form => 'symbol').should be_symbol
95
+ expect(en.lookup(:section, :form => 'long')).to be_long
96
+ expect(en.lookup(:section, :form => 'short')).to be_short
97
+ expect(en.lookup(:section, :form => 'symbol')).to be_symbol
98
98
 
99
- en.lookup(:editor).should be_long
100
- en.lookup(:editor, :form => 'long').should be_long
101
- en.lookup(:editor, :form => 'verb').should be_verb
102
- en.lookup(:editor, :form => 'verb-short').should be_verb_short
99
+ expect(en.lookup(:editor)).to be_long
100
+ expect(en.lookup(:editor, :form => 'long')).to be_long
101
+ expect(en.lookup(:editor, :form => 'verb')).to be_verb
102
+ expect(en.lookup(:editor, :form => 'verb-short')).to be_verb_short
103
103
  end
104
104
 
105
105
  it 'returns the right fallback form if the passed-in form is not available' do
106
- en.lookup(:page, :form => 'verb').should be_long
107
- en.lookup(:page, :form => 'verb-short').should be_long
108
- en.lookup(:page, :form => 'symbol').should be_short
106
+ expect(en.lookup(:page, :form => 'verb')).to be_long
107
+ expect(en.lookup(:page, :form => 'verb-short')).to be_long
108
+ expect(en.lookup(:page, :form => 'symbol')).to be_short
109
109
  end
110
110
 
111
111
  it 'ignores irrelevant options' do
112
- en.lookup(:page, :plural => true).should_not be_nil
112
+ expect(en.lookup(:page, :plural => true)).not_to be_nil
113
113
  end
114
114
  end
115
115
 
@@ -118,23 +118,23 @@ module CSL
118
118
 
119
119
  describe Locale::Term do
120
120
 
121
- it { should_not be_nil }
121
+ it { is_expected.not_to be_nil }
122
122
 
123
- it { should_not be_gendered }
124
- it { should be_neutral }
123
+ it { is_expected.not_to be_gendered }
124
+ it { is_expected.to be_neutral }
125
125
 
126
- it { should be_long }
126
+ it { is_expected.to be_long }
127
127
 
128
- it { should_not be_ordinal }
129
- it { should_not be_short_ordinal }
130
- it { should_not be_long_ordinal }
128
+ it { is_expected.not_to be_ordinal }
129
+ it { is_expected.not_to be_short_ordinal }
130
+ it { is_expected.not_to be_long_ordinal }
131
131
 
132
132
  it 'is not a textnode by default' do
133
- subject.should_not be_textnode
133
+ expect(subject).not_to be_textnode
134
134
  end
135
135
 
136
136
  it 'is a textnode when the text is "foo"' do
137
- Locale::Term.new { |t| t.text = 'foo' }.should be_textnode
137
+ expect(Locale::Term.new { |t| t.text = 'foo' }).to be_textnode
138
138
  end
139
139
 
140
140
  describe 'gender attribute is set' do
@@ -142,72 +142,72 @@ module CSL
142
142
  let(:f) { Locale::Term.new(:name => 'edition') { |t| t.feminine!; t.text = 'Ausgabe' } }
143
143
 
144
144
  it 'is gendered' do
145
- m.should be_gendered
146
- f.should be_gendered
145
+ expect(m).to be_gendered
146
+ expect(f).to be_gendered
147
147
  end
148
148
 
149
149
  it 'is feminine or masculine' do
150
- m.should be_masculine
151
- f.should be_feminine
150
+ expect(m).to be_masculine
151
+ expect(f).to be_feminine
152
152
  end
153
153
 
154
154
  it 'is not neutral' do
155
- m.should_not be_neutral
156
- f.should_not be_neutral
155
+ expect(m).not_to be_neutral
156
+ expect(f).not_to be_neutral
157
157
  end
158
158
 
159
159
  describe '#to_xml' do
160
160
  it 'contains the correct gender' do
161
- m.to_xml.should =~ /gender="masculine"/
162
- f.to_xml.should =~ /gender="feminine"/
161
+ expect(m.to_xml).to match(/gender="masculine"/)
162
+ expect(f.to_xml).to match(/gender="feminine"/)
163
163
  end
164
164
  end
165
165
 
166
166
  describe '#match?' do
167
167
  it 'matches the name when passed a string' do
168
- m.should be_match(:name => 'month-05')
168
+ expect(m).to be_match(:name => 'month-05')
169
169
  end
170
170
 
171
171
  it 'matches the name when passed a pattern' do
172
- m.should be_match(:name => /month-\d\d/)
172
+ expect(m).to be_match(:name => /month-\d\d/)
173
173
  end
174
174
 
175
175
  it 'matches when passed a matching hash without gender' do
176
- f.should be_match(:name => 'edition')
176
+ expect(f).to be_match(:name => 'edition')
177
177
  end
178
178
 
179
179
  it 'does not match when passed a matching hash with wrong gender' do
180
- f.matches?(:name => 'edition', :gender => 'masculine').should_not be_true
180
+ expect(f.matches?(:name => 'edition', :gender => 'masculine')).not_to be_truthy
181
181
  end
182
182
 
183
183
  it 'matches when passed a matching hash with matching gender' do
184
- f.matches?(:name => 'edition', :gender => 'feminine').should be_true
184
+ expect(f.matches?(:name => 'edition', :gender => 'feminine')).to be_truthy
185
185
  end
186
186
  end
187
187
 
188
188
  describe '#exact_match?' do
189
189
  it 'does not match when passed a matching hash without gender' do
190
- f.should_not be_exact_match(:name => 'edition')
190
+ expect(f).not_to be_exact_match(:name => 'edition')
191
191
  end
192
192
  end
193
193
 
194
194
  describe 'attributes#to_a' do
195
195
  it 'returns an array of all attribute values of underlying struct' do
196
- f.attributes.to_a.should == ['edition', 'long', 'feminine', nil, nil]
196
+ expect(f.attributes.to_a).to eq(['edition', 'long', 'feminine', nil, nil])
197
197
  end
198
198
  end
199
199
  end
200
200
 
201
201
  describe '#to_s' do
202
202
  it 'returns an empty string by default' do
203
- Locale::Term.new.to_s.should == ''
203
+ expect(Locale::Term.new.to_s).to eq('')
204
204
  end
205
205
 
206
206
  describe 'given a simple term' do
207
207
  let(:node) { Locale::Term.new { |t| t.text = 'foo' } }
208
208
 
209
209
  it "returns the term's text" do
210
- node.to_s.should == node.text
210
+ expect(node.to_s).to eq(node.text)
211
211
  end
212
212
  end
213
213
 
@@ -215,23 +215,23 @@ module CSL
215
215
  let(:node) { Locale::Term.new { |t| t.single = 'shoe'; t.multiple = 'shoes' } }
216
216
 
217
217
  it "returns the term's singular form by default" do
218
- node.to_s.should == node.singularize
218
+ expect(node.to_s).to eq(node.singularize)
219
219
  end
220
220
 
221
221
  it "returns the term's plural form when passed :number => :plural" do
222
- node.to_s(:number => :plural).should == node.pluralize
222
+ expect(node.to_s(:number => :plural)).to eq(node.pluralize)
223
223
  end
224
224
 
225
225
  it "returns the term's plural form when passed :number => 2" do
226
- node.to_s(:number => 2).should == node.pluralize
226
+ expect(node.to_s(:number => 2)).to eq(node.pluralize)
227
227
  end
228
228
 
229
229
  it "returns the term's singular form when passed :number => 1" do
230
- node.to_s(:number => 1).should == node.singularize
230
+ expect(node.to_s(:number => 1)).to eq(node.singularize)
231
231
  end
232
232
 
233
233
  it "returns the term's plural form when passed :plural => true" do
234
- node.to_s(:plural => true).should == node.pluralize
234
+ expect(node.to_s(:plural => true)).to eq(node.pluralize)
235
235
  end
236
236
 
237
237
  end
@@ -239,15 +239,15 @@ module CSL
239
239
 
240
240
  describe '#to_xml' do
241
241
  it 'returns <term/> by default' do
242
- subject.to_xml.should == '<term/>'
242
+ expect(subject.to_xml).to eq('<term/>')
243
243
  end
244
244
 
245
245
  it 'returns <term>foo</term> when the text is "foo"' do
246
- Locale::Term.new { |t| t.text = 'foo' }.to_xml.should == '<term>foo</term>'
246
+ expect(Locale::Term.new { |t| t.text = 'foo' }.to_xml).to eq('<term>foo</term>')
247
247
  end
248
248
 
249
249
  it 'returns <term><multiple>foo</multiple></term> when multiple is "foo"' do
250
- Locale::Term.new { |t| t.multiple = 'foo' }.to_xml.should == '<term><multiple>foo</multiple></term>'
250
+ expect(Locale::Term.new { |t| t.multiple = 'foo' }.to_xml).to eq('<term><multiple>foo</multiple></term>')
251
251
  end
252
252
 
253
253
  end
@@ -15,7 +15,7 @@ module CSL
15
15
  describe '.regions' do
16
16
 
17
17
  it 'returns the default region when passed a language symbol' do
18
- Locale.regions[:en].should == :US
18
+ expect(Locale.regions[:en]).to eq(:US)
19
19
  end
20
20
 
21
21
  end
@@ -25,7 +25,7 @@ module CSL
25
25
  describe 'the language hash' do
26
26
  it 'returns the default language when passed a region string' do
27
27
  %w{ US en GB en AT de DE de }.map(&:to_sym).each_slice(2) do |region, language|
28
- Locale.languages[region].should == language
28
+ expect(Locale.languages[region]).to eq(language)
29
29
  end
30
30
  end
31
31
  end
@@ -40,28 +40,28 @@ module CSL
40
40
  'de-AT' => 'de-AT'
41
41
  }.each_pair do |tag, expected|
42
42
  it "converts #{tag.inspect} to #{expected.inspect}" do
43
- Locale.normalize(tag).should == expected
43
+ expect(Locale.normalize(tag)).to eq(expected)
44
44
  end
45
45
  end
46
46
  end
47
47
 
48
48
  describe '.new' do
49
- it { should_not be_nil }
49
+ it { is_expected.not_to be_nil }
50
50
 
51
51
  it 'defaults to default language' do
52
- Locale.new.language.should == Locale.default.split(/-/)[0].to_sym
52
+ expect(Locale.new.language).to eq(Locale.default.split(/-/)[0].to_sym)
53
53
  end
54
54
 
55
55
  it 'defaults to default region' do
56
- Locale.new.region.should == Locale.default.split(/-/)[1].to_sym
56
+ expect(Locale.new.region).to eq(Locale.default.split(/-/)[1].to_sym)
57
57
  end
58
58
 
59
59
  it 'contains no dates by default' do
60
- Locale.new.dates.should be_nil
60
+ expect(Locale.new.dates).to be_nil
61
61
  end
62
62
 
63
63
  it 'contains no terms by default' do
64
- Locale.new.terms.should be_nil
64
+ expect(Locale.new.terms).to be_nil
65
65
  end
66
66
 
67
67
  end
@@ -72,15 +72,15 @@ module CSL
72
72
  let(:locale) { Locale.load('en-GB') }
73
73
 
74
74
  it 'the returned locale has the correct IETF tag' do
75
- locale.to_s.should == 'en-GB'
75
+ expect(locale.to_s).to eq('en-GB')
76
76
  end
77
77
 
78
78
  it 'the locale has language :en' do
79
- locale.language.should == :en
79
+ expect(locale.language).to eq(:en)
80
80
  end
81
81
 
82
82
  it 'the locale has region :GB' do
83
- locale.region.should == :GB
83
+ expect(locale.region).to eq(:GB)
84
84
  end
85
85
 
86
86
  end
@@ -91,17 +91,17 @@ module CSL
91
91
 
92
92
  it 'when passed "en-GB" sets language to :en and region to :GB' do
93
93
  locale.set('en-GB')
94
- [locale.language, locale.region].should == [:en, :GB]
94
+ expect([locale.language, locale.region]).to eq([:en, :GB])
95
95
  end
96
96
 
97
97
  it 'when passed "de" sets language to :de and region to :DE' do
98
98
  locale.set('de')
99
- [locale.language, locale.region].should == [:de, :DE]
99
+ expect([locale.language, locale.region]).to eq([:de, :DE])
100
100
  end
101
101
 
102
102
  it 'when passed "-AT" sets language to :de and region to :AT' do
103
103
  locale.set('-AT')
104
- [locale.language, locale.region].should == [:de, :AT]
104
+ expect([locale.language, locale.region]).to eq([:de, :AT])
105
105
  end
106
106
 
107
107
  end
@@ -115,11 +115,11 @@ module CSL
115
115
  end
116
116
 
117
117
  it 'creates a duplicate option element if the first locale has no options' do
118
- locale.should_not have_options
118
+ expect(locale).not_to have_options
119
119
  locale.merge!(locale_with_options)
120
- locale.should have_options
121
- locale.options[:foo].should == 'bar'
122
- locale.options.should_not equal(locale_with_options.options)
120
+ expect(locale).to have_options
121
+ expect(locale.options[:foo]).to eq('bar')
122
+ expect(locale.options).not_to equal(locale_with_options.options)
123
123
  end
124
124
 
125
125
  it 'merges the options if both locales have options' do
@@ -127,15 +127,15 @@ module CSL
127
127
 
128
128
  expect { locale.merge!(locale_with_options) }.not_to change { locale.options.object_id }
129
129
 
130
- locale.options[:foo].should == 'bar'
131
- locale.options[:bar].should == 'foo'
130
+ expect(locale.options[:foo]).to eq('bar')
131
+ expect(locale.options[:bar]).to eq('foo')
132
132
  end
133
133
 
134
134
  it 'overrides the options with those in the other locale' do
135
135
  locale << Locale::StyleOptions.new(:bar => 'foo', :foo => 'foo')
136
136
  locale.merge!(locale_with_options)
137
- locale.options[:foo].should == 'bar'
138
- locale.options[:bar].should == 'foo'
137
+ expect(locale.options[:foo]).to eq('bar')
138
+ expect(locale.options[:bar]).to eq('foo')
139
139
  end
140
140
  end
141
141
 
@@ -146,19 +146,19 @@ module CSL
146
146
 
147
147
  it 'creates duplicate date elements if the first locale has no options' do
148
148
  locale.merge!(Locale.load('en-US'))
149
- locale.should have_dates
149
+ expect(locale).to have_dates
150
150
  end
151
151
  end
152
152
  end
153
153
 
154
154
  describe '#legacy?' do
155
155
  it 'returns false by default' do
156
- locale.should_not be_legacy
156
+ expect(locale).not_to be_legacy
157
157
  end
158
158
 
159
159
  it 'returns true if the version is less than 1.0.1' do
160
160
  locale.version = '0.8'
161
- locale.should be_legacy
161
+ expect(locale).to be_legacy
162
162
  end
163
163
  end
164
164
 
@@ -168,30 +168,30 @@ module CSL
168
168
  locale.store 'open-quote', '»'
169
169
  locale.store 'close-quote', '«'
170
170
 
171
- locale.quote('foo').should == '»foo«'
171
+ expect(locale.quote('foo')).to eq('»foo«')
172
172
  end
173
173
 
174
174
  it 'does not alter the string if there are no quotes in the locale' do
175
- locale.quote('foo').should == 'foo'
175
+ expect(locale.quote('foo')).to eq('foo')
176
176
  end
177
177
 
178
178
  it 'adds quotes inside final punctuation if punctuation-in-quote option is set' do
179
179
  locale.store 'open-quote', '»'
180
180
  locale.store 'close-quote', '«'
181
181
 
182
- locale.quote('foo.').should == '»foo«.'
183
- locale.quote('foo,').should == '»foo«,'
182
+ expect(locale.quote('foo.')).to eq('»foo«.')
183
+ expect(locale.quote('foo,')).to eq('»foo«,')
184
184
 
185
- locale.quote('foo!').should == '»foo!«'
186
- locale.quote('foo?').should == '»foo?«'
185
+ expect(locale.quote('foo!')).to eq('»foo!«')
186
+ expect(locale.quote('foo?')).to eq('»foo?«')
187
187
 
188
188
  locale.punctuation_in_quotes!
189
189
 
190
- locale.quote('foo.').should == '»foo.«'
191
- locale.quote('foo,').should == '»foo,«'
190
+ expect(locale.quote('foo.')).to eq('»foo.«')
191
+ expect(locale.quote('foo,')).to eq('»foo,«')
192
192
 
193
- locale.quote('foo!').should == '»foo!«'
194
- locale.quote('foo?').should == '»foo?«'
193
+ expect(locale.quote('foo!')).to eq('»foo!«')
194
+ expect(locale.quote('foo?')).to eq('»foo?«')
195
195
  end
196
196
 
197
197
  it 'replaces existing quotes with inner quotes' do
@@ -200,7 +200,7 @@ module CSL
200
200
  locale.store 'open-inner-quote', '‘'
201
201
  locale.store 'close-inner-quote', '’'
202
202
 
203
- locale.quote('“foo”').should == '“‘foo’”'
203
+ expect(locale.quote('“foo”')).to eq('“‘foo’”')
204
204
  end
205
205
  end
206
206
  end