ruby_ext 0.4.21 → 0.4.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rspec_ext/xhtml.rb +48 -0
- data/lib/rspec_ext.rb +6 -23
- data/lib/ruby_ext/core/string.rb +0 -4
- metadata +3 -2
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#
|
|
2
|
+
# FuzzyHash, to_fuzzy_hash, to_html
|
|
3
|
+
#
|
|
4
|
+
begin
|
|
5
|
+
require 'nokogiri'
|
|
6
|
+
|
|
7
|
+
class RSpec::FuzzyHash < Hash
|
|
8
|
+
def == o
|
|
9
|
+
return true if super
|
|
10
|
+
|
|
11
|
+
if o.respond_to? :each
|
|
12
|
+
o.each do |k, v|
|
|
13
|
+
return false if (self[k.to_sym] || self[k.to_s]) != v
|
|
14
|
+
end
|
|
15
|
+
return true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
false
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
::Nokogiri::XML::Node.class_eval do
|
|
23
|
+
def to_fuzzy_hash
|
|
24
|
+
h = RSpec::FuzzyHash.new
|
|
25
|
+
attributes.each{|n, v| h[n] = v.value}
|
|
26
|
+
h[:content] = content
|
|
27
|
+
h
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
class String
|
|
32
|
+
def to_xhtml css = nil
|
|
33
|
+
require 'nokogiri'
|
|
34
|
+
|
|
35
|
+
node = Nokogiri::HTML(self)
|
|
36
|
+
unless css
|
|
37
|
+
node
|
|
38
|
+
else
|
|
39
|
+
nodes = node.css(css)
|
|
40
|
+
raise "Elements for '#{css}' CSS query not found!" if nodes.size < 1
|
|
41
|
+
raise "Found more than one elment for '#{css}' CSS query!" if nodes.size > 1
|
|
42
|
+
nodes.first
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
rescue LoadError
|
|
47
|
+
warn "WARN: some specs require the 'nokogiri' gem, but there's no such gem on this system, these specs will be scipped!"
|
|
48
|
+
end
|
data/lib/rspec_ext.rb
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
#
|
|
17
|
-
#
|
|
17
|
+
# RSpec
|
|
18
18
|
#
|
|
19
19
|
require 'rspec'
|
|
20
20
|
require 'fileutils'
|
|
@@ -112,31 +112,14 @@ rspec do
|
|
|
112
112
|
# end
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
+
|
|
116
|
+
#
|
|
117
|
+
# dirname, parent_dirname
|
|
118
|
+
#
|
|
115
119
|
class String
|
|
116
|
-
unless
|
|
120
|
+
unless method_defined? :dirname
|
|
117
121
|
def dirname
|
|
118
122
|
File.expand_path(File.dirname(self))
|
|
119
123
|
end
|
|
120
124
|
end
|
|
121
|
-
|
|
122
|
-
unless "".respond_to? :parent_dirname
|
|
123
|
-
def parent_dirname
|
|
124
|
-
File.expand_path(self + "/..")
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
class Rspec::FuzzyHash < Hash
|
|
130
|
-
def == o
|
|
131
|
-
return true if super
|
|
132
|
-
|
|
133
|
-
if o.respond_to? :each
|
|
134
|
-
o.each do |k, v|
|
|
135
|
-
return false if (self[k.to_sym] || self[k.to_s]) != v
|
|
136
|
-
end
|
|
137
|
-
return true
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
false
|
|
141
|
-
end
|
|
142
125
|
end
|
data/lib/ruby_ext/core/string.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_ext
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.22
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2011-07-
|
|
13
|
+
date: 2011-07-30 00:00:00 +04:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies: []
|
|
16
16
|
|
|
@@ -27,6 +27,7 @@ files:
|
|
|
27
27
|
- readme.md
|
|
28
28
|
- lib/rake_ext/project.rb
|
|
29
29
|
- lib/rake_ext.rb
|
|
30
|
+
- lib/rspec_ext/xhtml.rb
|
|
30
31
|
- lib/rspec_ext.rb
|
|
31
32
|
- lib/ruby_ext/core/array.rb
|
|
32
33
|
- lib/ruby_ext/core/basic_object.rb
|