csl 1.2.3 → 1.3.0

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: c2440f83717e0f6837afcc83266cd4a3840a3616
4
- data.tar.gz: 8b23cc4a6b0d37be88b2ab89db161a1a807e6ffa
3
+ metadata.gz: f0c6bac5a4e0a88bd83e78fc8acac300a9d8a122
4
+ data.tar.gz: 6cae82297a9550d275d92c8f1b86ca34b67fe181
5
5
  SHA512:
6
- metadata.gz: 4b4b1ba0f7ca04742e7366595629000cb1bf40ca526a3fee6d637beb91632794b9cb63e39fbaad6b41813daa71a3a394fd3c25e770200eef5081dc3d8d839ba6
7
- data.tar.gz: dfed6689b3b10f021634deb117dd81f740f8ebf9a4c87f3e1b0552b28a41dd1eb2055a59f1f44d6abecc383d3b124d86f10f019b2ed6b0b35bf392d5d49b23fa
6
+ metadata.gz: 27597362d702c9ff06902e59386ed237050f63aa238c336318cfc9012e7576d7e0299b6e053cbd35861799e734338e1a69eb38113149578c2f65e42999e5a2a1
7
+ data.tar.gz: 42e659e3de7d61a556317178a031a0cd5b0305aa8c6c804627d40a5a4e2ecf6551f69dabdb3a3413276f649e7d7058ba5dba509a531d6fa34b7aa526aeb031fa
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
1
  --color
2
2
  --format progress
3
- --require spec_helper.rb
3
+ --require spec_helper.rb
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ gemspec
3
3
 
4
4
  group :development, :test do
5
5
  gem 'rake', '~>10.0'
6
- gem 'rspec', '~>2.13'
6
+ gem 'rspec', '~>3.0'
7
7
  gem 'cucumber', '~>1.2'
8
8
  gem 'simplecov', '~>0.8', :require => false
9
9
  gem 'rubinius-coverage', :platform => :rbx
@@ -11,8 +11,14 @@ group :development, :test do
11
11
  end
12
12
 
13
13
  group :debug do
14
- gem 'ruby-debug', :require => false, :platforms => [:jruby]
15
- gem 'debugger', :require => false, :platforms => [:mri]
14
+ if RUBY_VERSION >= '2.0'
15
+ gem 'byebug', :require => false, :platforms => :mri
16
+ else
17
+ gem 'debugger', :require => false, :platforms => :mri
18
+ end
19
+
20
+ gem 'ruby-debug', :require => false, :platforms => :jruby
21
+
16
22
  gem 'rubinius-debugger', :require => false, :platforms => :rbx
17
23
  gem 'rubinius-compiler', :require => false, :platforms => :rbx
18
24
  end
@@ -24,14 +30,13 @@ end
24
30
  group :extra do
25
31
  gem 'guard', '~>2.2'
26
32
  gem 'guard-rspec'
33
+ gem 'guard-cucumber'
27
34
  gem 'bond'
28
35
  gem 'diff-lcs'
29
36
  gem 'pry'
30
- gem 'guard-cucumber'
31
- gem 'rb-fsevent', '~>0.9', :platforms => [:ruby]
32
-
33
- gem 'yard', '~>0.8', :platforms => [:mri]
34
- gem 'redcarpet', '~>3.0', :platforms => [:mri]
37
+ gem 'rb-fsevent', '~>0.9', :platforms => :ruby
38
+ gem 'yard', '~>0.8', :platforms => :mri
39
+ gem 'redcarpet', '~>3.0', :platforms => :mri
35
40
  end
36
41
 
37
42
  group :rbx do
data/Guardfile CHANGED
@@ -1,7 +1,4 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- guard 'rspec' do
1
+ guard 'rspec', :cmd => 'bundle exec rspec' do
5
2
  watch(%r{^spec/.+_spec\.rb$})
6
3
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
4
  watch('spec/spec_helper.rb') { 'spec' }
@@ -9,6 +6,10 @@ end
9
6
 
10
7
  guard 'cucumber' do
11
8
  watch(%r{^features/.+\.feature$})
12
- watch(%r{^features/support/.+$}) { 'features' }
13
- watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
9
+ watch(%r{^features/support/.+$}) { 'features' }
10
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m|
11
+ Dir[File.join("**/#{m[1]}.feature")][0] || 'features'
12
+ }
14
13
  end
14
+
15
+ # vim: syntax=ruby
@@ -12,8 +12,10 @@ begin
12
12
  Debugger.start
13
13
  when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
14
14
  require 'rubinius/debugger'
15
- else
15
+ when defined?(RUBY_VERSION) && RUBY_VERSION < '2.0'
16
16
  require 'debugger'
17
+ else
18
+ require 'byebug'
17
19
  end
18
20
  rescue LoadError
19
21
  # ignore
@@ -475,9 +475,10 @@ module CSL
475
475
  end
476
476
 
477
477
  def <=>(other)
478
+ return nil unless other.is_a?(Node)
479
+ return 1 if other.textnode?
480
+
478
481
  [nodename, attributes, children] <=> [other.nodename, other.attributes, other.children]
479
- rescue
480
- nil
481
482
  end
482
483
 
483
484
  # Returns the node' XML tags (including attribute assignments) as an
@@ -603,6 +604,13 @@ module CSL
603
604
  ["<#{attribute_assignments.unshift(nodename).join(' ')}>#{to_s}</#{nodename}>"]
604
605
  end
605
606
 
607
+ def <=>(other)
608
+ return nil unless other.is_a?(Node)
609
+ return -1 unless other.textnode?
610
+
611
+ [nodename, attributes, text] <=> [other.nodename, other.attributes, other.text]
612
+ end
613
+
606
614
  def inspect
607
615
  "#<#{[self.class.name, text.inspect, *attribute_assignments].join(' ')}>"
608
616
  end
@@ -1,3 +1,3 @@
1
1
  module CSL
2
- VERSION = '1.2.3'.freeze
2
+ VERSION = '1.3.0'.freeze
3
3
  end
@@ -2,13 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  module CSL
4
4
 
5
- describe Node do
5
+ describe Node do
6
6
 
7
7
  it { is_expected.not_to be nil }
8
8
  it { is_expected.not_to have_children }
9
- it { is_expected.not_to have_attributes }
9
+ it { is_expected.to have_attributes(:attributes => {}) }
10
10
 
11
- describe 'given a FooBarNode with attributes :foo and :bar and a TestNode without defined attributes' do
11
+ describe 'given a FooBarNode with attributes :foo and :bar and a TestNode without defined attributes' do
12
12
  before(:all) do
13
13
  class FooBarNode < Node
14
14
  attr_struct :foo, :bar
@@ -25,110 +25,121 @@ module CSL
25
25
  expect(TestNode.const_defined?(:Attributes)).not_to be_truthy
26
26
  end
27
27
 
28
- it 'TestNode attributes are a regular Hash' do
29
- expect(TestNode.new.attributes).to be_a(Hash)
30
- end
28
+ it 'TestNode attributes are a regular Hash' do
29
+ expect(TestNode.new.attributes).to be_a(Hash)
30
+ end
31
31
 
32
- it 'FooBarNode attributes are a Struct' do
33
- expect(FooBarNode.new.attributes).to be_a(Struct)
34
- end
32
+ it 'FooBarNode attributes are a Struct' do
33
+ expect(FooBarNode.new.attributes).to be_a(Struct)
34
+ end
35
35
 
36
- describe '#match?' do
37
- it 'matches an empty query' do
38
- expect(FooBarNode.new.match?({})).to be_truthy
39
- expect(FooBarNode.new(:foo => 'Foo').match?({})).to be_truthy
40
- expect(TestNode.new.match?({})).to be_truthy
41
- expect(TestNode.new(:foo => 'Foo').match?({})).to be_truthy
42
- end
36
+ describe '#match?' do
37
+ it 'matches an empty query' do
38
+ expect(FooBarNode.new.match?({})).to be_truthy
39
+ expect(FooBarNode.new(:foo => 'Foo').match?({})).to be_truthy
40
+ expect(TestNode.new.match?({})).to be_truthy
41
+ expect(TestNode.new(:foo => 'Foo').match?({})).to be_truthy
42
+ end
43
43
 
44
44
  it 'returns true for a matching query' do
45
- expect(FooBarNode.new(:foo => 'bar').match?(:foo => 'bar')).to be_truthy
46
- expect(FooBarNode.new(:bar => 'b', :foo => 'f').match?(:foo => 'f', :bar => 'b')).to be_truthy
45
+ expect(FooBarNode.new(:foo => 'bar').match?(:foo => 'bar')).to be_truthy
46
+ expect(FooBarNode.new(:bar => 'b', :foo => 'f').match?(:foo => 'f', :bar => 'b')).to be_truthy
47
47
  end
48
48
 
49
49
  it 'returns false for non-matching query' do
50
- expect(FooBarNode.new.match?(:foo => 'bar')).to be_falsey
51
- expect(FooBarNode.new(:foo => 'f').match?(:foo => 'f', :bar => 'b')).to be_falsey
50
+ expect(FooBarNode.new.match?(:foo => 'bar')).to be_falsey
51
+ expect(FooBarNode.new(:foo => 'f').match?(:foo => 'f', :bar => 'b')).to be_falsey
52
52
  end
53
53
 
54
54
  it 'returns false if the query contains unknown attributes' do
55
- expect(FooBarNode.new(:foo => 'f').match?(:foo => 'f', :unknown => 'u')).to be_falsey
55
+ expect(FooBarNode.new(:foo => 'f').match?(:foo => 'f', :unknown => 'u')).to be_falsey
56
56
  end
57
57
 
58
58
  it 'matches irrespective of order' do
59
- expect(FooBarNode.new(:bar => 'b', :foo => 'f').match?(:foo => 'f', :bar => 'b')).to be_truthy
60
- expect(FooBarNode.new(:foo => 'f', :bar => 'b').match?(:foo => 'f', :bar => 'b')).to be_truthy
61
- expect(FooBarNode.new(:foo => 'f', :bar => 'b').match?(:bar => 'b', :foo => 'f')).to be_truthy
62
- expect(FooBarNode.new(:bar => 'b', :foo => 'f').match?(:bar => 'b', :foo => 'f')).to be_truthy
63
- end
64
-
65
- it 'matches an empty query with the correct node name' do
66
- expect(FooBarNode.new.match?('foo-bar-node', {})).to be_truthy
67
- expect(FooBarNode.new(:foo => 'Foo').match?('foo-bar-node', {})).to be_truthy
68
- expect(TestNode.new.match?('test-node', {})).to be_truthy
69
- expect(TestNode.new(:foo => 'Foo').match?('test-node', {})).to be_truthy
70
- end
71
-
72
- it 'does not match other node names' do
73
- expect(FooBarNode.new.match?(:name, {})).not_to be_truthy
74
- expect(FooBarNode.new(:foo => 'Foo').match?(:name, {})).not_to be_truthy
75
- expect(TestNode.new.match?(:name, {})).not_to be_truthy
76
- expect(TestNode.new(:foo => 'Foo').match?(:name, {})).not_to be_truthy
77
- end
78
- end
79
-
80
- describe '#attributes_for' do
81
- it 'returns an empty hash when there no attributes are set' do
82
- expect(TestNode.new.attributes_for).to be_empty
83
- expect(TestNode.new.attributes_for(:x, :y)).to be_empty
84
-
85
- expect(FooBarNode.new.attributes_for).to be_empty
86
- expect(FooBarNode.new.attributes_for(:x, :y)).to be_empty
87
- expect(FooBarNode.new.attributes_for(:foo, :bar)).to be_empty
88
- end
89
-
90
- it 'returns an empty hash when no attributes match the filter' do
91
- expect(TestNode.new(:foo => 'foo').attributes_for).to be_empty
92
- expect(TestNode.new(:foo => 'foo').attributes_for(:x, :y)).to be_empty
93
-
94
- expect(FooBarNode.new(:foo => 'foo').attributes_for).to be_empty
95
- expect(FooBarNode.new(:foo => 'foo').attributes_for(:x, :y)).to be_empty
96
- end
97
-
98
- it 'returns a hash of all set attributes that match the filter' do
99
- expect(TestNode.new(:foo => 'foo', :bar => 'bar').attributes_for(:x, :foo)).to eq({ :foo => 'foo' })
100
- expect(FooBarNode.new(:foo => 'foo', :bar => 'bar').attributes_for(:x, :foo)).to eq({ :foo => 'foo' })
101
- end
102
- end
103
-
104
- describe '#formatting_options' do
105
- it 'returns an empty hash by default' do
106
- expect(TestNode.new.formatting_options).to be_empty
107
- expect(FooBarNode.new.formatting_options).to be_empty
108
- end
109
-
110
- it 'returns an empty hash if there are no formatting attributes' do
111
- expect(TestNode.new(:foo => 'foo', :bar => 'bar').formatting_options).to be_empty
112
- expect(FooBarNode.new(:foo => 'foo', :bar => 'bar').formatting_options).to be_empty
113
- end
114
-
115
- it "returns a hash of the node's formatting attributes" do
116
- expect(TestNode.new(:foo => 'foo', :'font-style' => 'italic').formatting_options).to eq({ :'font-style' => 'italic' })
117
- end
118
- end
119
-
120
- describe '#values_at' do
121
- it 'FooBarNode accepts attribute names' do
122
- expect(FooBarNode.new(:foo => 'Foo', :bar => 'Bar').values_at(:bar, :foo)).to eq(%w{ Bar Foo })
123
- expect(FooBarNode.new(:foo => 'Foo').values_at(:bar, :foo)).to eq([nil, 'Foo'])
124
- expect(FooBarNode.new(:foo => 'Foo').values_at(:unknown, :foo)).to eq([nil, 'Foo'])
125
- end
126
-
127
- it 'TestNode accepts attribute names' do
128
- expect(TestNode.new(:foo => 'Foo', :bar => 'Bar').values_at(:bar, :foo)).to eq(%w{ Bar Foo })
129
- expect(TestNode.new(:foo => 'Foo').values_at(:bar, :foo)).to eq([nil, 'Foo'])
130
- expect(TestNode.new(:foo => 'Foo').values_at(:unknown, :foo)).to eq([nil, 'Foo'])
131
- end
59
+ expect(FooBarNode.new(:bar => 'b', :foo => 'f').match?(:foo => 'f', :bar => 'b')).to be_truthy
60
+ expect(FooBarNode.new(:foo => 'f', :bar => 'b').match?(:foo => 'f', :bar => 'b')).to be_truthy
61
+ expect(FooBarNode.new(:foo => 'f', :bar => 'b').match?(:bar => 'b', :foo => 'f')).to be_truthy
62
+ expect(FooBarNode.new(:bar => 'b', :foo => 'f').match?(:bar => 'b', :foo => 'f')).to be_truthy
63
+ end
64
+
65
+ it 'matches an empty query with the correct node name' do
66
+ expect(FooBarNode.new.match?('foo-bar-node', {})).to be_truthy
67
+ expect(FooBarNode.new(:foo => 'Foo').match?('foo-bar-node', {})).to be_truthy
68
+ expect(TestNode.new.match?('test-node', {})).to be_truthy
69
+ expect(TestNode.new(:foo => 'Foo').match?('test-node', {})).to be_truthy
70
+ end
71
+
72
+ it 'does not match other node names' do
73
+ expect(FooBarNode.new.match?(:name, {})).not_to be_truthy
74
+ expect(FooBarNode.new(:foo => 'Foo').match?(:name, {})).not_to be_truthy
75
+ expect(TestNode.new.match?(:name, {})).not_to be_truthy
76
+ expect(TestNode.new(:foo => 'Foo').match?(:name, {})).not_to be_truthy
77
+ end
78
+ end
79
+
80
+ describe '#attributes_for' do
81
+ it 'returns an empty hash when there no attributes are set' do
82
+ expect(TestNode.new.attributes_for).to be_empty
83
+ expect(TestNode.new.attributes_for(:x, :y)).to be_empty
84
+
85
+ expect(FooBarNode.new.attributes_for).to be_empty
86
+ expect(FooBarNode.new.attributes_for(:x, :y)).to be_empty
87
+ expect(FooBarNode.new.attributes_for(:foo, :bar)).to be_empty
88
+ end
89
+
90
+ it 'returns an empty hash when no attributes match the filter' do
91
+ expect(TestNode.new(:foo => 'foo').attributes_for).to be_empty
92
+ expect(TestNode.new(:foo => 'foo').attributes_for(:x, :y)).to be_empty
93
+
94
+ expect(FooBarNode.new(:foo => 'foo').attributes_for).to be_empty
95
+ expect(FooBarNode.new(:foo => 'foo').attributes_for(:x, :y)).to be_empty
96
+ end
97
+
98
+ it 'returns a hash of all set attributes that match the filter' do
99
+ expect(TestNode.new(:foo => 'foo', :bar => 'bar').attributes_for(:x, :foo)).to eq({ :foo => 'foo' })
100
+ expect(FooBarNode.new(:foo => 'foo', :bar => 'bar').attributes_for(:x, :foo)).to eq({ :foo => 'foo' })
101
+ end
102
+ end
103
+
104
+ describe '#formatting_options' do
105
+ it 'returns an empty hash by default' do
106
+ expect(TestNode.new.formatting_options).to be_empty
107
+ expect(FooBarNode.new.formatting_options).to be_empty
108
+ end
109
+
110
+ it 'returns an empty hash if there are no formatting attributes' do
111
+ expect(TestNode.new(:foo => 'foo', :bar => 'bar').formatting_options).to be_empty
112
+ expect(FooBarNode.new(:foo => 'foo', :bar => 'bar').formatting_options).to be_empty
113
+ end
114
+
115
+ it "returns a hash of the node's formatting attributes" do
116
+ expect(
117
+ TestNode.new(:foo => 'foo', :'font-style' => 'italic').formatting_options
118
+ ).to eq({ :'font-style' => 'italic' })
119
+ end
120
+ end
121
+
122
+ describe '#values_at' do
123
+ it 'FooBarNode accepts attribute names' do
124
+ expect(FooBarNode.new(:foo => 'Foo', :bar => 'Bar').values_at(:bar, :foo))
125
+ .to eq(%w{ Bar Foo })
126
+
127
+ expect(FooBarNode.new(:foo => 'Foo').values_at(:bar, :foo))
128
+ .to eq([nil, 'Foo'])
129
+
130
+ expect(FooBarNode.new(:foo => 'Foo').values_at(:unknown, :foo))
131
+ .to eq([nil, 'Foo'])
132
+ end
133
+
134
+ it 'TestNode accepts attribute names' do
135
+ expect(TestNode.new(:foo => 'Foo', :bar => 'Bar').values_at(:bar, :foo))
136
+ .to eq(%w{ Bar Foo })
137
+
138
+ expect(TestNode.new(:foo => 'Foo').values_at(:bar, :foo))
139
+ .to eq([nil, 'Foo'])
140
+ expect(TestNode.new(:foo => 'Foo').values_at(:unknown, :foo))
141
+ .to eq([nil, 'Foo'])
142
+ end
132
143
  end
133
144
 
134
145
  describe '#to_a' do
@@ -160,17 +171,54 @@ module CSL
160
171
  end
161
172
  end
162
173
  end
163
- end
174
+
175
+ describe 'comparing nodes' do
176
+ it 'empty nodes are equal' do
177
+ expect(Node.new).to eq(Node.new)
178
+ end
179
+
180
+ it 'considers node names' do
181
+ expect(Node.new).not_to eq(Node.new { |n| n.nodename = 'foo' })
182
+ end
183
+
184
+ it 'considers attributes' do
185
+ expect(Node.new(:foo => 'bar')).to eq(Node.new(:foo => 'bar'))
186
+ expect(Node.new(:foo => 'bar')).not_to eq(Node.new(:foo => 'baz'))
187
+
188
+ expect(Node.new(:foo => 'bar', :baz => 'qux'))
189
+ .not_to eq(Node.new(:foo => 'bar'))
190
+
191
+ expect(Node.new(:foo => 'bar', :baz => 'qux'))
192
+ .to eq(Node.new(:baz => 'qux', :foo => 'bar'))
193
+ end
194
+
195
+ it 'considers children' do
196
+ n1, n2 = Node.new, Node.new
197
+
198
+ n1 << Node.new
199
+ expect(n1).not_to eq(n2)
200
+
201
+ n2 << Node.new
202
+ expect(n1).to eq(n2)
203
+
204
+ n2.children[0][:foo] = 'bar'
205
+ expect(n1).not_to eq(n2)
206
+
207
+ n1.children[0][:foo] = 'bar'
208
+ expect(n1).to eq(n2)
209
+ end
210
+ end
211
+ end
164
212
 
165
213
  describe TextNode do
166
214
 
167
215
  it { is_expected.not_to be nil }
168
216
  it { is_expected.not_to have_children }
169
- it { is_expected.not_to have_attributes }
217
+ it { is_expected.to have_attributes(:attributes => {}) }
170
218
 
171
219
  describe '.new' do
172
220
  it 'accepts a hash of attributes' do
173
- expect(TextNode.new(:foo => 'bar')).to have_attributes
221
+ expect(TextNode.new(:foo => 'bar').attributes).to have_key(:foo)
174
222
  end
175
223
 
176
224
  it 'yields itself to the optional block' do
@@ -178,13 +226,51 @@ module CSL
178
226
  end
179
227
 
180
228
  it 'accepts hash and yields itself to the optional block' do
181
- expect(TextNode.new(:foo => 'bar') { |n| n.text = 'foo' }.to_xml).to eq('<text-node foo="bar">foo</text-node>')
229
+ expect(TextNode.new(:foo => 'bar') { |n| n.text = 'foo' }.to_xml)
230
+ .to eq('<text-node foo="bar">foo</text-node>')
182
231
  end
183
232
  end
184
233
 
185
234
  describe '#pretty_print' do
186
235
  it 'prints the text node as XML' do
187
- expect(TextNode.new(:foo => 'bar') { |n| n.text = 'foo' }.pretty_print).to eq('<text-node foo="bar">foo</text-node>')
236
+ expect(TextNode.new(:foo => 'bar') { |n| n.text = 'foo' }.pretty_print)
237
+ .to eq('<text-node foo="bar">foo</text-node>')
238
+ end
239
+ end
240
+
241
+ describe 'comparing nodes' do
242
+ it 'empty nodes are equal' do
243
+ expect(TextNode.new).to eq(TextNode.new)
244
+ end
245
+
246
+ it 'considers node names' do
247
+ expect(TextNode.new).not_to eq(TextNode.new { |n| n.nodename = 'foo' })
248
+ end
249
+
250
+ it 'considers attributes' do
251
+ expect(TextNode.new(:foo => 'bar')).to eq(TextNode.new(:foo => 'bar'))
252
+ expect(TextNode.new(:foo => 'bar')).not_to eq(TextNode.new(:foo => 'baz'))
253
+
254
+ expect(TextNode.new(:foo => 'bar', :baz => 'qux'))
255
+ .not_to eq(TextNode.new(:foo => 'bar'))
256
+
257
+ expect(TextNode.new(:foo => 'bar', :baz => 'qux'))
258
+ .to eq(TextNode.new(:baz => 'qux', :foo => 'bar'))
259
+ end
260
+
261
+ it 'considers text' do
262
+ n1, n2 = TextNode.new, TextNode.new
263
+
264
+ n1.text = 'foo'
265
+ expect(n1).not_to eq(n2)
266
+
267
+ n2.text = 'foo'
268
+ expect(n1).to eq(n2)
269
+ end
270
+
271
+ it 'text nodes are less than other nodes' do
272
+ expect(TextNode.new).to be < Node.new
273
+ expect(Node.new).not_to be < TextNode.new
188
274
  end
189
275
  end
190
276
  end
@@ -28,7 +28,7 @@ module CSL
28
28
  end
29
29
 
30
30
  it 'returns a node with no attributes' do
31
- expect(Parser.instance.parse(source)).not_to have_attributes
31
+ expect(Parser.instance.parse(source).attributes).to be_empty
32
32
  end
33
33
 
34
34
  it 'returns a node with no children' do
@@ -57,26 +57,26 @@ module CSL
57
57
  end
58
58
 
59
59
  describe 'for <foo bar="x"/>' do
60
- let(:source) { '<foo bar="x"/>' }
60
+ let(:src) { '<foo bar="x"/>' }
61
61
 
62
62
  it 'returns a node with attributes' do
63
- expect(Parser.instance.parse(source)).to have_attributes
63
+ expect(Parser.instance.parse(src).attributes).not_to be_empty
64
64
  end
65
65
 
66
66
  it 'returns a node with attribute bar' do
67
- expect(Parser.instance.parse(source).attribute?(:bar)).to be
67
+ expect(Parser.instance.parse(src).attribute?(:bar)).to be
68
68
  end
69
69
 
70
70
  it 'bar should be "x"' do
71
- expect(Parser.instance.parse(source)[:bar]).to eq('x')
71
+ expect(Parser.instance.parse(src)[:bar]).to eq('x')
72
72
  end
73
73
  end
74
74
 
75
75
  describe 'for <foo>Foo Bar</foo>' do
76
- let(:source) { '<foo>Foo Bar</foo>' }
76
+ let(:src) { '<foo>Foo Bar</foo>' }
77
77
 
78
78
  it 'returns text node' do
79
- expect(Parser.instance.parse(source)).to be_textnode
79
+ expect(Parser.instance.parse(src)).to be_textnode
80
80
  end
81
81
  end
82
82
 
@@ -2,26 +2,26 @@ require 'spec_helper'
2
2
 
3
3
  module CSL
4
4
  describe Style::Number do
5
-
5
+
6
6
  describe '.new' do
7
7
  it 'returns an empty number tag by default' do
8
- expect(Style::Number.new).not_to have_attributes
8
+ expect(Style::Number.new.attributes).to be_empty
9
9
  end
10
-
10
+
11
11
  it 'accepts a form attribute' do
12
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
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
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
26
  expect(Style::Number.new(:form => 'numeric')).to be_numeric
27
27
  end
@@ -31,11 +31,11 @@ module CSL
31
31
  it 'returns false by default' do
32
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
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
40
  expect(Style::Number.new(:form => 'roman')).to be_roman
41
41
  end
@@ -45,11 +45,11 @@ module CSL
45
45
  it 'returns false by default' do
46
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
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
54
  expect(Style::Number.new(:form => 'ordinal')).to be_ordinal
55
55
  expect(Style::Number.new(:form => :ordinal)).to be_ordinal
@@ -60,26 +60,26 @@ module CSL
60
60
  it 'returns false by default' do
61
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
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
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
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
80
  expect(Style::Number.new(:form => 'roman').to_xml).to eq('<number form="roman"/>')
81
81
  end
82
82
  end
83
-
83
+
84
84
  end
85
- end
85
+ end
@@ -12,8 +12,10 @@ begin
12
12
  Debugger.start
13
13
  when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
14
14
  require 'rubinius/debugger'
15
- else
15
+ when defined?(RUBY_VERSION) && RUBY_VERSION < '2.0'
16
16
  require 'debugger'
17
+ else
18
+ require 'byebug'
17
19
  end
18
20
  rescue LoadError
19
21
  # ignore
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-07 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: namae
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.7'
27
27
  description: "\n\t\tA Ruby parser and full API for the Citation Style Language (CSL),\n\t\tan
@@ -32,11 +32,11 @@ executables: []
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
- - .document
36
- - .gitignore
37
- - .rspec
38
- - .simplecov
39
- - .yardopts
35
+ - ".document"
36
+ - ".gitignore"
37
+ - ".rspec"
38
+ - ".simplecov"
39
+ - ".yardopts"
40
40
  - AGPL
41
41
  - BSDL
42
42
  - Gemfile
@@ -129,17 +129,17 @@ require_paths:
129
129
  - lib
130
130
  required_ruby_version: !ruby/object:Gem::Requirement
131
131
  requirements:
132
- - - '>='
132
+ - - ">="
133
133
  - !ruby/object:Gem::Version
134
134
  version: 1.9.3
135
135
  required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - '>='
137
+ - - ">="
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  requirements: []
141
141
  rubyforge_project:
142
- rubygems_version: 2.2.2
142
+ rubygems_version: 2.4.5
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: A Ruby CSL parser and library