csl 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,21 +11,21 @@ module CSL
11
11
 
12
12
  describe '#conditions' do
13
13
  it 'returns an empty list by default' do
14
- Choose::Block.new.conditions.should be_empty
14
+ expect(Choose::Block.new.conditions).to be_empty
15
15
  end
16
16
 
17
17
  describe 'when the node has a single condition' do
18
18
  let(:node) { Choose::Block.new(:'is-numeric' => 'edition' )}
19
19
 
20
20
  it 'returns an array with an array containing the type, matcher and values of the condition' do
21
- node.conditions.should == [[:'is-numeric', :all?, ['edition']]]
21
+ expect(node.conditions).to eq([[:'is-numeric', :all?, ['edition']]])
22
22
  end
23
23
 
24
24
  describe 'when the condition has multiple values' do
25
25
  before { node[:'is-numeric'] << ' issue' }
26
26
 
27
27
  it 'it splits the values in the conditions list' do
28
- node.conditions.should == [[:'is-numeric', :all?, ['edition', 'issue']]]
28
+ expect(node.conditions).to eq([[:'is-numeric', :all?, ['edition', 'issue']]])
29
29
  end
30
30
  end
31
31
 
@@ -33,12 +33,12 @@ module CSL
33
33
  before { node[:disambiguate] = 'true' }
34
34
 
35
35
  it 'returns an array with two elements' do
36
- node.conditions.should have_exactly(2).items
36
+ expect(node.conditions.size).to eq(2)
37
37
  end
38
38
 
39
39
  it 'returns both conditions as arrays' do
40
- node.conditions.map(&:first).sort.should == [:disambiguate, :'is-numeric']
41
- node.conditions.map(&:last).sort.should == [['edition'], ['true']]
40
+ expect(node.conditions.map(&:first).sort).to eq([:disambiguate, :'is-numeric'])
41
+ expect(node.conditions.map(&:last).sort).to eq([['edition'], ['true']])
42
42
  end
43
43
  end
44
44
  end
@@ -47,14 +47,14 @@ module CSL
47
47
  let(:node) { Choose::Block.new(:'variable-any' => 'author editor' )}
48
48
 
49
49
  it 'strips the match override from the type name and inserts it as the matcher' do
50
- node.conditions.should == [[:variable, :any?, ['author', 'editor']]]
50
+ expect(node.conditions).to eq([[:variable, :any?, ['author', 'editor']]])
51
51
  end
52
52
 
53
53
  describe 'other conditions' do
54
54
  before { node[:position] = 'false' }
55
55
 
56
56
  it 'are not affected by the override' do
57
- node.conditions.map { |c| c[1].to_s }.sort.should == %w{ all? any? }
57
+ expect(node.conditions.map { |c| c[1].to_s }.sort).to eq(%w{ all? any? })
58
58
  end
59
59
  end
60
60
  end
@@ -9,11 +9,11 @@ module CSL
9
9
 
10
10
  describe '#numeric-leading-zeros?' do
11
11
 
12
- it { should_not be_numeric_leading_zeros }
12
+ it { is_expected.not_to be_numeric_leading_zeros }
13
13
 
14
14
  it 'returns true when the form is set accordingly' do
15
15
  subject[:form] = 'numeric-leading-zeros'
16
- subject.should be_numeric_leading_zeros
16
+ expect(subject).to be_numeric_leading_zeros
17
17
  end
18
18
  end
19
19
 
@@ -3,9 +3,9 @@ require 'spec_helper'
3
3
  module CSL
4
4
  describe Style::Label do
5
5
 
6
- it { should_not be_names_label }
7
- it { should_not be_always_pluralize }
8
- it { should_not be_never_pluralize }
6
+ it { is_expected.not_to be_names_label }
7
+ it { is_expected.not_to be_always_pluralize }
8
+ it { is_expected.not_to be_never_pluralize }
9
9
 
10
10
  describe '.terms' do
11
11
  Hash[*%w{
@@ -17,7 +17,7 @@ module CSL
17
17
  chapter-number chapter
18
18
  }].each do |variable, term|
19
19
  it "returns #{term.inspect} for #{variable.inspect}" do
20
- Style::Label.terms[variable].should == term
20
+ expect(Style::Label.terms[variable]).to eq(term)
21
21
  end
22
22
  end
23
23
  end
@@ -25,18 +25,18 @@ module CSL
25
25
  describe 'a label inside a names node' do
26
26
  before(:each) { Style::Names.new << subject }
27
27
 
28
- it { should be_names_label }
28
+ it { is_expected.to be_names_label }
29
29
  end
30
30
 
31
31
  describe '#term' do
32
- it { should be_empty }
32
+ it { is_expected.to be_empty }
33
33
 
34
34
  it 'returns the term for the current variable' do
35
35
  subject[:variable] = 'page'
36
- subject.term.should == 'page'
36
+ expect(subject.term).to eq('page')
37
37
 
38
38
  subject[:variable] = 'number-of-volumes'
39
- subject.term.should == 'volume'
39
+ expect(subject.term).to eq('volume')
40
40
  end
41
41
  end
42
42
 
@@ -7,7 +7,7 @@ module CSL
7
7
 
8
8
  describe Style::Name do
9
9
 
10
- it { should be_delimiter_contextually_precedes_last }
10
+ it { is_expected.to be_delimiter_contextually_precedes_last }
11
11
 
12
12
  [:never, :always, :contextually].each do |setting|
13
13
  setter = "delimiter_#{setting}_precedes_last!"
@@ -15,7 +15,7 @@ module CSL
15
15
 
16
16
  describe "##{setter}" do
17
17
  it 'sets the delimiter precedes last option accordingly' do
18
- subject.send(setter).send(predicate).should == true
18
+ expect(subject.send(setter).send(predicate)).to eq(true)
19
19
  end
20
20
  end
21
21
  end
@@ -5,79 +5,79 @@ module CSL
5
5
 
6
6
  describe '.new' do
7
7
  it 'returns an empty number tag by default' do
8
- Style::Number.new.should_not have_attributes
8
+ expect(Style::Number.new).not_to have_attributes
9
9
  end
10
10
 
11
11
  it 'accepts a form attribute' do
12
- Style::Number.new(:form => 'roman').should be_roman
12
+ expect(Style::Number.new(:form => 'roman')).to be_roman
13
13
  end
14
14
  end
15
15
 
16
16
  describe '#numeric?' do
17
17
  it 'returns true by default' do
18
- Style::Number.new.should be_numeric
18
+ expect(Style::Number.new).to be_numeric
19
19
  end
20
20
 
21
21
  it 'returns false if the form attribute is set to a value other than :numeric' do
22
- Style::Number.new(:form => 'foo').should_not be_numeric
22
+ expect(Style::Number.new(:form => 'foo')).not_to be_numeric
23
23
  end
24
24
 
25
25
  it 'returns false if the form attribute is set to :numeric' do
26
- Style::Number.new(:form => 'numeric').should be_numeric
26
+ expect(Style::Number.new(:form => 'numeric')).to be_numeric
27
27
  end
28
28
  end
29
29
 
30
30
  describe '#roman?' do
31
31
  it 'returns false by default' do
32
- Style::Number.new.should_not be_roman
32
+ expect(Style::Number.new).not_to be_roman
33
33
  end
34
34
 
35
35
  it 'returns false if the form attribute is set to a value other than :numeric' do
36
- Style::Number.new(:form => 'ordinal').should_not be_roman
36
+ expect(Style::Number.new(:form => 'ordinal')).not_to be_roman
37
37
  end
38
38
 
39
39
  it 'returns false if the form attribute is set to :roman' do
40
- Style::Number.new(:form => 'roman').should be_roman
40
+ expect(Style::Number.new(:form => 'roman')).to be_roman
41
41
  end
42
42
  end
43
43
 
44
44
  describe '#ordinal?' do
45
45
  it 'returns false by default' do
46
- Style::Number.new.should_not be_ordinal
46
+ expect(Style::Number.new).not_to be_ordinal
47
47
  end
48
48
 
49
49
  it 'returns false if the form attribute is set to a value other than :ordinal' do
50
- Style::Number.new(:form => 'long-ordinal').should_not be_ordinal
50
+ expect(Style::Number.new(:form => 'long-ordinal')).not_to be_ordinal
51
51
  end
52
52
 
53
53
  it 'returns false if the form attribute is set to :ordinal' do
54
- Style::Number.new(:form => 'ordinal').should be_ordinal
55
- Style::Number.new(:form => :ordinal).should be_ordinal
54
+ expect(Style::Number.new(:form => 'ordinal')).to be_ordinal
55
+ expect(Style::Number.new(:form => :ordinal)).to be_ordinal
56
56
  end
57
57
  end
58
58
 
59
59
  describe '#long_ordinal?' do
60
60
  it 'returns false by default' do
61
- Style::Number.new.should_not be_long_ordinal
61
+ expect(Style::Number.new).not_to be_long_ordinal
62
62
  end
63
63
 
64
64
  it 'returns false if the form attribute is set to a value other than :"long-ordinal"' do
65
- Style::Number.new(:form => 'ordinal').should_not be_long_ordinal
65
+ expect(Style::Number.new(:form => 'ordinal')).not_to be_long_ordinal
66
66
  end
67
67
 
68
68
  it 'returns false if the form attribute is set to :ordinal' do
69
- Style::Number.new(:form => 'long-ordinal').should be_long_ordinal
69
+ expect(Style::Number.new(:form => 'long-ordinal')).to be_long_ordinal
70
70
  end
71
71
  end
72
72
 
73
73
 
74
74
  describe '#to_xml' do
75
75
  it 'returns an empty number tag by default' do
76
- Style::Number.new.to_xml.should == '<number/>'
76
+ expect(Style::Number.new.to_xml).to eq('<number/>')
77
77
  end
78
78
 
79
79
  it 'returns a tag with a all attribute assignments' do
80
- Style::Number.new(:form => 'roman').to_xml.should == '<number form="roman"/>'
80
+ expect(Style::Number.new(:form => 'roman').to_xml).to eq('<number form="roman"/>')
81
81
  end
82
82
  end
83
83
 
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  module CSL
4
4
  describe Style::Sort do
5
- it { should_not have_sort_keys }
5
+ it { is_expected.not_to have_sort_keys }
6
6
  end
7
7
 
8
8
  describe Style::Sort::Key do
@@ -7,78 +7,78 @@ module CSL
7
7
  end
8
8
 
9
9
  it 'has a 1.x version by default' do
10
- @style[:version].should match(/1\.\d+(\.\d+)?/)
10
+ expect(@style[:version]).to match(/1\.\d+(\.\d+)?/)
11
11
  end
12
12
 
13
13
  it 'has the default version' do
14
- @style.default_attribute?(:version).should be_true
14
+ expect(@style.default_attribute?(:version)).to be_truthy
15
15
  end
16
16
 
17
17
  it 'has a the default namespace attribute' do
18
- @style[:xmlns].should == CSL::Schema.namespace
19
- @style.default_attribute?(:xmlns).should be_true
18
+ expect(@style[:xmlns]).to eq(CSL::Schema.namespace)
19
+ expect(@style.default_attribute?(:xmlns)).to be_truthy
20
20
  end
21
21
 
22
22
  describe '#to_xml' do
23
23
  it 'returns an empty style' do
24
- @style.to_xml.should match(/^<style[^>]*\/>/)
24
+ expect(@style.to_xml).to match(/^<style[^>]*\/>/)
25
25
  end
26
26
 
27
27
  it 'includes the xml namespace' do
28
- @style.to_xml.should match(CSL::Schema.namespace)
28
+ expect(@style.to_xml).to match(CSL::Schema.namespace)
29
29
  end
30
30
 
31
31
  it 'supports round-trip for apa style' do
32
32
  apa = Style.load(:apa)
33
- apa.should be_a(Style)
33
+ expect(apa).to be_a(Style)
34
34
 
35
35
  xml = apa.to_xml
36
- xml.should match(/^<style[^>]*>/)
36
+ expect(xml).to match(/^<style[^>]*>/)
37
37
 
38
- Style.parse(xml).should be_a(Style)
38
+ expect(Style.parse(xml)).to be_a(Style)
39
39
  end
40
40
  end
41
41
 
42
42
  describe '#deep_copy' do
43
43
  it 'works on apa style' do
44
44
  apa = Style.load(:apa)
45
- apa.should be_a(Style)
45
+ expect(apa).to be_a(Style)
46
46
 
47
47
  xml = apa.to_xml
48
48
 
49
49
  copy = apa.deep_copy
50
50
 
51
- apa.to_xml.should == xml # original unchanged!
52
- copy.to_xml.should == xml
51
+ expect(apa.to_xml).to eq(xml) # original unchanged!
52
+ expect(copy.to_xml).to eq(xml)
53
53
  end
54
54
  end
55
55
 
56
56
  describe '#children' do
57
57
 
58
- it { should_not have_info }
59
- it { should_not have_locale }
60
- it { should_not have_macro }
61
- it { should_not have_citation }
62
- it { should_not have_bibliography }
58
+ it { is_expected.not_to have_info }
59
+ it { is_expected.not_to have_locale }
60
+ it { is_expected.not_to have_macro }
61
+ it { is_expected.not_to have_citation }
62
+ it { is_expected.not_to have_bibliography }
63
63
 
64
64
  describe 'when it has a title' do
65
65
  before { @style.title = 'foo' }
66
66
 
67
- it { @style.should have_info }
67
+ it { expect(@style).to have_info }
68
68
 
69
69
  it 'info.title is a text node' do
70
- @style.info.title.should be_a(TextNode)
70
+ expect(@style.info.title).to be_a(TextNode)
71
71
  end
72
72
 
73
73
  it '#title returns the title as a string' do
74
- @style.title.should be_a(String)
74
+ expect(@style.title).to be_a(String)
75
75
  end
76
76
  end
77
77
  end
78
78
 
79
79
  describe '#id accessor' do
80
80
  it 'returns nil by default' do
81
- @style.id.should be_nil
81
+ expect(@style.id).to be_nil
82
82
  end
83
83
 
84
84
  it 'writer sets the id to the passed-in string' do
@@ -88,11 +88,11 @@ module CSL
88
88
 
89
89
  describe 'independent and dependent styles' do
90
90
  it 'styles are independent by default' do
91
- @style.should be_independent
91
+ expect(@style).to be_independent
92
92
  end
93
93
 
94
94
  it 'styles do not have independent-parent links by default' do
95
- @style.should_not have_independent_parent_link
95
+ expect(@style).not_to have_independent_parent_link
96
96
  end
97
97
 
98
98
  it 'when setting an independet-parent link a style becomes dependent' do
@@ -102,7 +102,7 @@ module CSL
102
102
 
103
103
  describe 'macros' do
104
104
  it 'has no macros by default' do
105
- @style.should_not have_macros
105
+ expect(@style).not_to have_macros
106
106
  end
107
107
 
108
108
  it 'raises a validation error when adding a macro without name' do
@@ -113,12 +113,12 @@ module CSL
113
113
  before { @style << Style::Macro.new(:name => 'author') }
114
114
 
115
115
  it 'has macros' do
116
- @style.should have_macros
116
+ expect(@style).to have_macros
117
117
  end
118
118
 
119
119
  it 'the macro is registered in the macros hash' do
120
- @style.macros.should have_key('author')
121
- @style.macros['author'].should be_a(Style::Macro)
120
+ expect(@style.macros).to have_key('author')
121
+ expect(@style.macros['author']).to be_a(Style::Macro)
122
122
  end
123
123
 
124
124
  it 'raises a validation error when adding a macro with a duplicate name' do
@@ -19,17 +19,17 @@ module CSL
19
19
  let(:lvl2) { TestTree.new.add_child(TestTree.new).add_child(TestTree.new) }
20
20
 
21
21
  it 'has no children by default' do
22
- node.should_not have_children
22
+ expect(node).not_to have_children
23
23
  end
24
24
 
25
25
  it 'is empty by default' do
26
- node.should be_empty
26
+ expect(node).to be_empty
27
27
  end
28
28
 
29
29
  describe '#children' do
30
30
 
31
31
  it 'is empty by default' do
32
- node.children.should be_empty
32
+ expect(node.children).to be_empty
33
33
  end
34
34
 
35
35
  it 'grows when adding child nodes' do
@@ -40,58 +40,58 @@ module CSL
40
40
 
41
41
  describe '#nodename' do
42
42
  it 'returns the class name in attribute form by default' do
43
- node.nodename.should == 'test-tree'
43
+ expect(node.nodename).to eq('test-tree')
44
44
  end
45
45
  end
46
46
 
47
47
  describe '#ancestors' do
48
48
  it 'returns and empty list by default' do
49
- node.ancestors.should be_empty
49
+ expect(node.ancestors).to be_empty
50
50
  end
51
51
 
52
52
  it 'returns a list with one ancestor at level 1' do
53
- lvl1.ancestors.should have(1).element
53
+ expect(lvl1.ancestors.size).to eq(1)
54
54
  end
55
55
 
56
56
  it 'the last ancestor is also the root node at levels 1 and deeper' do
57
- lvl1.ancestors.last.should be_root
58
- lvl2.ancestors.last.should be_root
57
+ expect(lvl1.ancestors.last).to be_root
58
+ expect(lvl2.ancestors.last).to be_root
59
59
  end
60
60
 
61
61
  it 'returns a list with two ancestors at level 2' do
62
- lvl2.ancestors.should have(2).elements
62
+ expect(lvl2.ancestors.size).to eq(2)
63
63
  end
64
64
  end
65
65
 
66
66
  it 'is a root node by default' do
67
- node.should be_root
67
+ expect(node).to be_root
68
68
  end
69
69
 
70
70
  describe '#root' do
71
71
  it 'returns self at level 0' do
72
- node.root.should equal(node)
72
+ expect(node.root).to equal(node)
73
73
  end
74
74
 
75
75
  it 'returns the parent at level 1' do
76
- lvl1.root.should == lvl1.parent
76
+ expect(lvl1.root).to eq(lvl1.parent)
77
77
  end
78
78
 
79
79
  it 'returns parent.parent at level 2' do
80
- lvl2.root.should == lvl2.parent.parent
80
+ expect(lvl2.root).to eq(lvl2.parent.parent)
81
81
  end
82
82
  end
83
83
 
84
84
  describe '#depth' do
85
85
  it 'returns 0 by default' do
86
- node.depth.should == 0
86
+ expect(node.depth).to eq(0)
87
87
  end
88
88
 
89
89
  it 'returns 1 at level 1' do
90
- lvl1.depth.should == 1
90
+ expect(lvl1.depth).to eq(1)
91
91
  end
92
92
 
93
93
  it 'returns 2 at level 2' do
94
- lvl2.depth.should == 2
94
+ expect(lvl2.depth).to eq(2)
95
95
  end
96
96
 
97
97
  it 'grows when the node is added to another node' do
@@ -111,23 +111,23 @@ module CSL
111
111
  end
112
112
 
113
113
  it 'the class contains a children struct' do
114
- TestTree.const?(:Children).should be true
114
+ expect(TestTree.const?(:Children)).to be true
115
115
  end
116
116
 
117
117
  describe '.create_children' do
118
118
  it 'returns the children struct' do
119
- TestTree.create_children.should be_a(Struct)
119
+ expect(TestTree.create_children).to be_a(Struct)
120
120
  end
121
121
  end
122
122
 
123
123
  describe '#children' do
124
124
  it 'returns a children struct instance' do
125
- TestTree.new.children.should be_a(Struct)
125
+ expect(TestTree.new.children).to be_a(Struct)
126
126
  end
127
127
  end
128
128
 
129
129
  it 'has no children by default' do
130
- TestTree.new.should_not have_children
130
+ expect(TestTree.new).not_to have_children
131
131
  end
132
132
 
133
133
  it 'has children when adding child nodes' do