testdata 0.3.0 → 0.3.1
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/testdata.rb +8 -5
- metadata +2 -2
data/lib/testdata.rb
CHANGED
@@ -22,7 +22,7 @@ class Path
|
|
22
22
|
output_values = XPath.match(node, "records/io/summary[type='output']/*").map(&stringify)
|
23
23
|
|
24
24
|
path_no = node.text('summary/path')
|
25
|
-
actual = XPath.first(@log.root, "records/result[path_no='#{path_no}']/actual")
|
25
|
+
actual = XPath.first(@log.root, "records/result[path_no='#{path_no}']/actual") if @log
|
26
26
|
|
27
27
|
|
28
28
|
result = nil
|
@@ -40,7 +40,7 @@ class Path
|
|
40
40
|
if raw_result then
|
41
41
|
a = [raw_result].flatten.map(&:strip)
|
42
42
|
b = expected.map(&:strip)
|
43
|
-
actual.text = a.join("\n")[/</] ? CData.new("\n%s\n" % a.join("\n")) : a.join("\n")
|
43
|
+
actual.text = a.join("\n")[/</] ? CData.new("\n%s\n" % a.join("\n")) : a.join("\n") if @log
|
44
44
|
|
45
45
|
# puts 'a : ' + a.inspect + ' a :' + a[0].length.to_s
|
46
46
|
# puts 'b : ' + b.inspect + ' b :' + b[0].length.to_s
|
@@ -66,23 +66,26 @@ class Testdata
|
|
66
66
|
|
67
67
|
attr_reader :success
|
68
68
|
|
69
|
-
def initialize(s)
|
69
|
+
def initialize(s, options={})
|
70
70
|
#puts 'filex : ' + $0
|
71
71
|
#puts 'filez : ' + __FILE__
|
72
72
|
#puts 'pwd : ' + Dir.pwd
|
73
73
|
#exit
|
74
|
+
|
75
|
+
o = {log: false}.merge(options)
|
76
|
+
|
74
77
|
@filepath = File.dirname s
|
75
78
|
buffer = self.send('read_' + (s[/https?:\/\//] ? 'file' : 'url'), s)
|
76
79
|
@doc = Document.new(buffer)
|
77
80
|
raise "Testdata error: doc %s not found" % s unless @doc
|
78
81
|
@success = []
|
79
82
|
|
80
|
-
@log = Document.new(tests)
|
83
|
+
@log = o[:log] == true ? Document.new(tests) : nil
|
81
84
|
end
|
82
85
|
|
83
86
|
def paths()
|
84
87
|
yield(path = Path.new(@doc, @log, @success))
|
85
|
-
File.open(Dir.pwd + '/.test_log.xml','w'){|f| f.write @log }
|
88
|
+
File.open(Dir.pwd + '/.test_log.xml','w'){|f| f.write @log } if @log
|
86
89
|
end
|
87
90
|
|
88
91
|
def read_file(s) File.open(s, 'r').read end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testdata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors: []
|
7
7
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2011-01-
|
12
|
+
date: 2011-01-10 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|