testdata 0.8.13 → 0.9.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f37a7ac7117e4069f4bdb53e02fbbc1687454ac9
4
- data.tar.gz: 4dae9b91de259f202ec3756e3787f1ce2fcab752
3
+ metadata.gz: 4976cedc862558c2920f3c5a56126ba955ffd558
4
+ data.tar.gz: 82bba8205b37746020a0caed150a2b3ea9ea4088
5
5
  SHA512:
6
- metadata.gz: dcf6724564a0b22eb19f8515610d171c8e1e621d9c168243e136680b43c9459c699dedb4d1341a41debde349c6cd50a7ebebe2d78bed690860764acad2622059
7
- data.tar.gz: aff6845ab2d06ef1f5cf4969922a117b78a5abbf841d3551e623d7600cfa6547e945be59371e698eeb3f94d62b6035ced85b17488fc4de5242ac9a68eafcfdfa
6
+ metadata.gz: b6ef582472a2ccdb68d16529947a25cf683f2acb0665da06d11cd6ba430501231a47d6caca0b2914fc989f0c769beb95b2b06e29a6c4dd5087ecc5a366d0963c
7
+ data.tar.gz: 56223c7eeabb76f4b34941900a3c48d1e2843eb5945c9c601acc10b5ffa84e706c0b60f1fac0386bc0d795ef9623001c798cd69e713a9e1c2e24b819a6a27036
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/testdata.rb CHANGED
@@ -5,8 +5,12 @@
5
5
  require 'rexml/document'
6
6
  require 'app-routes'
7
7
  require 'testdata_text'
8
+ require 'diffy'
8
9
 
9
10
 
11
+ class TestdataException < Exception
12
+ end
13
+
10
14
  class Testdata
11
15
  include REXML
12
16
  include AppRoutes
@@ -14,7 +18,7 @@ class Testdata
14
18
  attr_accessor :debug
15
19
 
16
20
  def initialize(s, options={})
17
-
21
+
18
22
  super()
19
23
 
20
24
  @params = {}
@@ -46,6 +50,17 @@ class Testdata
46
50
  @log = o[:log] == true ? Document.new(tests) : nil
47
51
  end
48
52
 
53
+ def run(x=nil, debug2=nil)
54
+ @debug2 = debug2 ? true : false
55
+ @success = []
56
+ procs = {NilClass: :test_all, Range: :test_all, String: :test_id, Fixnum: :test_id}
57
+
58
+ method(procs[x.class.to_s.to_sym]).call(x)
59
+ summary()
60
+ end
61
+
62
+ private
63
+
49
64
  def testdata_values(id)
50
65
 
51
66
  stringify = Proc.new do |x|
@@ -55,15 +70,18 @@ class Testdata
55
70
  end
56
71
 
57
72
  node = XPath.first(@doc.root, "records/test[summary/path='#{id}']")
58
- raise "Path error: node title not found" unless node
73
+ raise TestdataException, "Path error: node title not found" unless node
59
74
 
60
75
  path_no = node.text('summary/path').to_s
61
76
 
62
77
  xpath = "records/input/summary/*"
63
78
  input_nodes = XPath.match(node, xpath) #[1..-1]
79
+
64
80
  input_values = input_nodes.map(&stringify) + []
65
81
 
66
82
  input_names = input_nodes.map(&:name)
83
+ raise TestdataException, 'inputs not found' if input_values.empty? \
84
+ or input_names.empty?
67
85
 
68
86
  summary = XPath.first node, 'summary'
69
87
  type, desc = summary.text('type'), summary.text('description')
@@ -71,18 +89,12 @@ class Testdata
71
89
  xpath = "records/output/summary/*"
72
90
  raw_output = XPath.match(node, xpath)
73
91
  output_values = raw_output.length > 0 ? raw_output.map(&stringify) : []
74
-
92
+
75
93
  [path_no, input_values, input_names, type, output_values, desc]
94
+
76
95
  end
77
96
 
78
- def run(x=nil, debug2=nil)
79
- @debug2 = debug2 ? true : false
80
- @success = []
81
- procs = {NilClass: :test_all, Range: :test_all, String: :test_id, Fixnum: :test_id}
82
97
 
83
- method(procs[x.class.to_s.to_sym]).call(x)
84
- summary()
85
- end
86
98
 
87
99
  def test_all(x)
88
100
  x ||=(0..-1)
@@ -128,13 +140,18 @@ class Testdata
128
140
  end
129
141
 
130
142
  result = a == b
143
+
144
+ if (@debug == true or @debug2 == true) and result == false then
145
+ # diff the expected and actual valuess
146
+ puts Diffy::Diff.new(a.first, b.first)
147
+ end
131
148
  else
132
149
  result = [raw_actual].compact == expected
133
150
  end
134
151
 
135
152
  rescue Exception => e
136
153
  err_label = e.message + " :: \n" + e.backtrace.join("\n")
137
- raise 'testdata :' + err_label
154
+ raise TestdataException, err_label
138
155
  result = false
139
156
  ensure
140
157
  @success[-1][0] = result
@@ -181,4 +198,4 @@ class Testdata
181
198
  failed: @success.select{|x| x[0] == false}.map(&:last).sort
182
199
  }
183
200
  end
184
- end
201
+ 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.8.13
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  vWFtb5VPsjLRwClW20j7R9zEUv5XjYoyxcUn1W1xQINMVIQMtvMhouLBeWTXF7g4
32
32
  ab2xQAvsYawLTw==
33
33
  -----END CERTIFICATE-----
34
- date: 2014-09-08 00:00:00.000000000 Z
34
+ date: 2014-12-27 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: app-routes
@@ -73,6 +73,26 @@ dependencies:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.1.3
76
+ - !ruby/object:Gem::Dependency
77
+ name: diffy
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 3.0.7
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '3.0'
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 3.0.7
76
96
  description:
77
97
  email: james@r0bertson.co.uk
78
98
  executables: []
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- Iҫӣ����qM����qo?uA�M���zE��a�/� �!<��b�7dFy��d�h�ЊvҴ�<!A��Ȭ$!X>&{�r���wTҼ�)a�0h�L�X�|JuƢ�Q hg��،�6.M���0]��]���X�!6��}tO�Qg���'8��gTzL��E��(N�C��[ ��Wgp�y�&��pp5�z��zK� Qa�%���2Yt�Io�0�3�8 �֪=X?�D��:;��ӳ���;N��8t5N
1
+ C���D׋�fѦҏ�b ⶙�