testdata 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/testdata.rb +8 -11
- metadata +1 -1
data/lib/testdata.rb
CHANGED
@@ -32,12 +32,16 @@ end
|
|
32
32
|
class Path
|
33
33
|
include REXML
|
34
34
|
|
35
|
-
def initialize(doc) @doc = doc end
|
35
|
+
def initialize(doc, success) @doc, @success = doc, success end
|
36
36
|
|
37
37
|
def tested? description
|
38
38
|
node = XPath.first(@doc.root, "records/test[summary/description='#{description}']")
|
39
39
|
raise "Path error: node not found" unless node
|
40
|
-
|
40
|
+
begin
|
41
|
+
@success << yield(*%w(input output).map {|x| Select.new(x,node)})
|
42
|
+
rescue
|
43
|
+
@success << false
|
44
|
+
end
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
@@ -53,17 +57,10 @@ class Testdata
|
|
53
57
|
@success = []
|
54
58
|
end
|
55
59
|
|
56
|
-
def paths()
|
57
|
-
begin
|
58
|
-
@success << yield(path = Path.new(@doc))
|
59
|
-
rescue
|
60
|
-
@success << false
|
61
|
-
end
|
62
|
-
end
|
60
|
+
def paths() yield(path = Path.new(@doc, @success)) end
|
63
61
|
def read_file(s) File.open(s, 'r').read end
|
64
62
|
def read_url(xml_url) open(xml_url, 'UserAgent' => 'S-Rscript').read end
|
65
63
|
|
66
64
|
def passed?() @success.all? end
|
67
|
-
def score() [@success.grep(true), @success].map(&:length).join('/') end
|
68
|
-
|
65
|
+
def score() [@success.grep(true), @success].map(&:length).join('/') end
|
69
66
|
end
|