niceogiri 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Niceogiri
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,83 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Nokogiri::XML::Node' do
4
+ before { @doc = Nokogiri::XML::Document.new }
5
+
6
+ it 'aliases #name to #element_name' do
7
+ node = Nokogiri::XML::Node.new 'foo', @doc
8
+ node.must_respond_to :element_name
9
+ node.element_name.must_equal node.name
10
+ end
11
+
12
+ it 'aliases #name= to #element_name=' do
13
+ node = Nokogiri::XML::Node.new 'foo', @doc
14
+ node.must_respond_to :element_name=
15
+ node.element_name.must_equal node.name
16
+ node.element_name = 'bar'
17
+ node.element_name.must_equal 'bar'
18
+ end
19
+
20
+ it 'allows symbols as hash keys for attributes' do
21
+ attrs = Nokogiri::XML::Node.new('foo', @doc)
22
+ attrs['foo'] = 'bar'
23
+
24
+ attrs['foo'].must_equal 'bar'
25
+ attrs[:foo].must_equal 'bar'
26
+ end
27
+
28
+ it 'ensures a string is passed to the attribute setter' do
29
+ attrs = Nokogiri::XML::Node.new('foo', @doc)
30
+ attrs[:foo] = 1
31
+ attrs[:foo].must_equal '1'
32
+
33
+ attrs[:some_attr] = [:bah, :boo]
34
+ attrs[:some_attr].must_equal 'bahboo'
35
+ end
36
+
37
+ it 'removes an attribute when set to nil' do
38
+ attrs = Nokogiri::XML::Node.new('foo', @doc)
39
+ attrs['foo'] = 'bar'
40
+
41
+ attrs['foo'].must_equal 'bar'
42
+ attrs['foo'] = nil
43
+ attrs['foo'].must_be_nil
44
+ end
45
+
46
+ it 'allows attribute values to change' do
47
+ attrs = Nokogiri::XML::Node.new('foo', @doc)
48
+ attrs['foo'] = 'bar'
49
+
50
+ attrs['foo'].must_equal 'bar'
51
+ attrs['foo'] = 'baz'
52
+ attrs['foo'].must_equal 'baz'
53
+ end
54
+
55
+ it 'allows symbols as the path in #xpath' do
56
+ node = Nokogiri::XML::Node.new('foo', @doc)
57
+ node.must_respond_to :find
58
+ @doc.root = node
59
+ @doc.xpath(:foo).first.wont_be_nil
60
+ @doc.xpath(:foo).first.must_equal @doc.xpath('/foo').first
61
+ end
62
+
63
+ it 'allows symbols as namespace names in #xpath' do
64
+ node = Nokogiri::XML::Node.new('foo', @doc)
65
+ node.namespace = node.add_namespace('bar', 'baz')
66
+ @doc.root = node
67
+ node.xpath('/bar:foo', :bar => 'baz').first.wont_be_nil
68
+ end
69
+
70
+ it 'aliases #xpath to #find' do
71
+ node = Nokogiri::XML::Node.new('foo', @doc)
72
+ node.must_respond_to :find
73
+ @doc.root = node
74
+ node.find('/foo').first.wont_be_nil
75
+ end
76
+
77
+ it 'has a helper function #find_first' do
78
+ node = Nokogiri::XML::Node.new('foo', @doc)
79
+ node.must_respond_to :find
80
+ @doc.root = node
81
+ node.find_first('/foo').must_equal node.find('/foo').first
82
+ end
83
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: niceogiri
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 23
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 3
9
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - Ben Langfeld
@@ -26,6 +27,7 @@ dependencies:
26
27
  requirements:
27
28
  - - ">="
28
29
  - !ruby/object:Gem::Version
30
+ hash: 7
29
31
  segments:
30
32
  - 1
31
33
  - 4
@@ -41,6 +43,7 @@ dependencies:
41
43
  requirements:
42
44
  - - ~>
43
45
  - !ruby/object:Gem::Version
46
+ hash: 9
44
47
  segments:
45
48
  - 1
46
49
  - 7
@@ -56,6 +59,7 @@ dependencies:
56
59
  requirements:
57
60
  - - ~>
58
61
  - !ruby/object:Gem::Version
62
+ hash: 23
59
63
  segments:
60
64
  - 1
61
65
  - 0
@@ -71,6 +75,7 @@ dependencies:
71
75
  requirements:
72
76
  - - ~>
73
77
  - !ruby/object:Gem::Version
78
+ hash: 41
74
79
  segments:
75
80
  - 0
76
81
  - 9
@@ -86,6 +91,7 @@ dependencies:
86
91
  requirements:
87
92
  - - ~>
88
93
  - !ruby/object:Gem::Version
94
+ hash: 5
89
95
  segments:
90
96
  - 0
91
97
  - 6
@@ -101,6 +107,7 @@ dependencies:
101
107
  requirements:
102
108
  - - ~>
103
109
  - !ruby/object:Gem::Version
110
+ hash: 11
104
111
  segments:
105
112
  - 2
106
113
  - 1
@@ -116,6 +123,7 @@ dependencies:
116
123
  requirements:
117
124
  - - ">="
118
125
  - !ruby/object:Gem::Version
126
+ hash: 3
119
127
  segments:
120
128
  - 0
121
129
  version: "0"
@@ -143,6 +151,7 @@ files:
143
151
  - lib/niceogiri/version.rb
144
152
  - lib/niceogiri/xml/node.rb
145
153
  - niceogiri.gemspec
154
+ - spec/niceogiri/core_ext/nokogiri_spec.rb
146
155
  - spec/niceogiri/xml/node_spec.rb
147
156
  - spec/spec_helper.rb
148
157
  has_rdoc: true
@@ -159,6 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
168
  requirements:
160
169
  - - ">="
161
170
  - !ruby/object:Gem::Version
171
+ hash: 3
162
172
  segments:
163
173
  - 0
164
174
  version: "0"
@@ -167,16 +177,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
177
  requirements:
168
178
  - - ">="
169
179
  - !ruby/object:Gem::Version
180
+ hash: 3
170
181
  segments:
171
182
  - 0
172
183
  version: "0"
173
184
  requirements: []
174
185
 
175
186
  rubyforge_project:
176
- rubygems_version: 1.3.7
187
+ rubygems_version: 1.4.2
177
188
  signing_key:
178
189
  specification_version: 3
179
190
  summary: Some additional niceties atop Nokogiri
180
191
  test_files:
192
+ - spec/niceogiri/core_ext/nokogiri_spec.rb
181
193
  - spec/niceogiri/xml/node_spec.rb
182
194
  - spec/spec_helper.rb