bibtex-ruby 2.1.2 → 2.2.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.

@@ -87,6 +87,20 @@ module BibTeX
87
87
  end
88
88
  end
89
89
 
90
+ describe '#merge!' do
91
+ it 'does not merge duplicates' do
92
+ n1 = Names.new(@poe)
93
+ n2 = Names.new(@poe)
94
+ assert_equal @poe.to_s, n1.merge!(n2).to_s
95
+ end
96
+
97
+ it 'merges different names' do
98
+ n1 = Names.new(@poe)
99
+ n2 = Names.new(Name.new(:last => 'Plato'))
100
+ assert_equal "#{@poe.to_s} and Plato", n1.merge!(n2).to_s
101
+ end
102
+ end
103
+
90
104
  describe '#extend_initials' do
91
105
  it 'extends the first name if the last name and initials match' do
92
106
  Name.new(:first => 'E.A.', :last => 'Poe').extend_initials('Edgar Allen', 'Poe').first.must_equal 'Edgar Allen'
@@ -16,7 +16,7 @@ module BibTeX
16
16
  assert_equal Value.new('value'), Value.create('value')
17
17
  end
18
18
  end
19
-
19
+
20
20
  describe "when empty" do
21
21
  it "should be equal to an empty string" do
22
22
  assert Value.new == ''
@@ -31,7 +31,7 @@ module BibTeX
31
31
  assert Value.new('') =~ //
32
32
  end
33
33
  end
34
-
34
+
35
35
  describe "#join" do
36
36
  it "should return empty string when empty" do
37
37
  assert_equal '', Value.new.join.to_s
@@ -61,7 +61,17 @@ module BibTeX
61
61
  assert_equal value, value.join
62
62
  end
63
63
  end
64
-
64
+
65
+ describe '#merge!' do
66
+ it 'merges two strings by combining them' do
67
+ assert_equal '"foo" # "bar"', Value.new('foo').merge!(Value.new('bar')).to_s
68
+ end
69
+
70
+ it 'does not duplicate existing tokens' do
71
+ assert_equal 'foo', Value.new('foo').merge!(Value.new('foo')).to_s
72
+ end
73
+ end
74
+
65
75
  describe "#to_s" do
66
76
  it "should return the string if atomic" do
67
77
  assert_equal 'foo bar', Value.new('foo bar').to_s
@@ -80,7 +90,7 @@ module BibTeX
80
90
  assert_equal '"foo" # bar', Value.new('foo', :bar).to_s
81
91
  end
82
92
  end
83
-
93
+
84
94
  describe "conversions" do
85
95
  before do
86
96
  class Upcase < BibTeX::Filter
@@ -90,12 +100,12 @@ module BibTeX
90
100
  end
91
101
  @values = [Value.new('foo'), Value.new('foo', :bar)]
92
102
  end
93
-
103
+
94
104
  describe "#convert" do
95
105
  it "converts the value when given a filter instance" do
96
106
  assert_equal ['FOO', '"FOO" # bar'], @values.map { |v| v.convert(Upcase.instance).to_s }
97
107
  end
98
-
108
+
99
109
  it "converts the value when given a filter class" do
100
110
  assert_equal ['FOO', '"FOO" # bar'], @values.map { |v| v.convert(Upcase).to_s }
101
111
  end
@@ -108,7 +118,7 @@ module BibTeX
108
118
  it "converts the value when using a ghost method" do
109
119
  assert_equal ['FOO', '"FOO" # bar'], @values.map { |v| v.convert_upcase.to_s }
110
120
  end
111
-
121
+
112
122
  it "does not alter the value when using a filter name" do
113
123
  @values.each { |v| v.convert(:upcase) }
114
124
  assert_equal ['foo', '"foo" # bar'], @values.map(&:to_s)
@@ -119,12 +129,12 @@ module BibTeX
119
129
  assert_equal ['foo', '"foo" # bar'], @values.map(&:to_s)
120
130
  end
121
131
  end
122
-
132
+
123
133
  describe "#convert!" do
124
134
  it "converts the value when given the name of a filter" do
125
135
  assert_equal ['FOO', '"FOO" # bar'], @values.map { |v| v.convert!(:upcase).to_s }
126
136
  end
127
-
137
+
128
138
  it "alters the value when given the name of a filter" do
129
139
  @values.each { |v| v.convert!(:upcase) }
130
140
  assert_equal ['FOO', '"FOO" # bar'], @values.map(&:to_s)
@@ -134,9 +144,9 @@ module BibTeX
134
144
  @values.each { |v| v.convert_upcase! }
135
145
  assert_equal ['FOO', '"FOO" # bar'], @values.map(&:to_s)
136
146
  end
137
-
147
+
138
148
  end
139
-
149
+
140
150
  describe "#to_s" do
141
151
  it 'accepts a :filter option and convert the values accordingly without changing the value' do
142
152
  assert_equal '"FOO" # bar', @values[1].to_s(:filter => :upcase)
@@ -144,6 +154,6 @@ module BibTeX
144
154
  end
145
155
  end
146
156
  end
147
-
157
+
148
158
  end
149
159
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibtex-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-02 00:00:00.000000000 Z
12
+ date: 2012-12-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: latex-decode
@@ -162,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
162
  version: '0'
163
163
  segments:
164
164
  - 0
165
- hash: 3159089786637859707
165
+ hash: 3526166777560005
166
166
  required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  none: false
168
168
  requirements:
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  version: '0'
172
172
  segments:
173
173
  - 0
174
- hash: 3159089786637859707
174
+ hash: 3526166777560005
175
175
  requirements: []
176
176
  rubyforge_project:
177
177
  rubygems_version: 1.8.24