futest 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/futest.rb +25 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8850fe934a2e18c66630fe2c567d5d79bbc9c816
|
4
|
+
data.tar.gz: 9386f5dccf59dd019fcc4ffb30f64ee04ffbb1d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c36054e94dbd1e77271a7b4c7810e00c8d2a24b67d874b25f3ea9982efa02edbb430721a52b8a69b24153af527ba9f77be68724c804f884e2ea54bfbd615ca29
|
7
|
+
data.tar.gz: c153c95d2e09ccd370d0d36395583a4c5af9e38469bf76514dfbb7fdbd1af1b82a0f34d3e34eb0fcd6d3cf8b60e4a873a780c9fd6830650cd3988c14c7b0dc4f
|
data/lib/futest.rb
CHANGED
@@ -8,9 +8,10 @@ module Futest
|
|
8
8
|
# Prints error message and stops execution
|
9
9
|
def halt(str, obj = nil, n = x(caller))
|
10
10
|
m = "#{n}: #{str}"
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
# Support for errors when using Object DB ORM
|
12
|
+
if obj and obj.errors and obj.errors.any? and obj.errors.messages
|
13
|
+
q = obj.errors.messages
|
14
|
+
m += ":\n=> " + q.each{|k, v| q[k] = v.join(', ')}.to_json[1..-2].gsub('","', '", "')
|
14
15
|
end
|
15
16
|
puts red(%{#{m}})
|
16
17
|
puts
|
@@ -26,17 +27,28 @@ module Futest
|
|
26
27
|
|
27
28
|
# Equality tester
|
28
29
|
def is(v1, v2, n = x(caller))
|
29
|
-
|
30
|
-
|
30
|
+
v2 = {:eq => v2} unless v2.is_a?(Hash)
|
31
|
+
# Extract options here with delete.
|
32
|
+
# No options available at the moment.
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
halt("#{v1} gt #{v2}", nil, n) unless v1 > v2
|
35
|
-
end
|
34
|
+
# For key output
|
35
|
+
def fs(y);{:eq => '==', :gt => '>', :lt => '<', :a? => 'is a'}[y] rescue y;end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
# Symbolize keys and extract values
|
38
|
+
k, v = v2.inject({}){|q,(k,v)|q[k.to_sym] = v; q}.to_a.flatten
|
39
|
+
s = ["#{v1.class} #{v1} #{fs(k)} #{v}", nil, n]
|
40
|
+
case k
|
41
|
+
when :eq
|
42
|
+
halt(*s) unless v1 == v
|
43
|
+
when :gt
|
44
|
+
halt(*s) unless v1 > v
|
45
|
+
when :lt
|
46
|
+
halt(*s) unless v1 < v
|
47
|
+
when :a?
|
48
|
+
halt(*s) unless v1.is_a?(v)
|
49
|
+
else
|
50
|
+
puts "#{k}: Command not supported."
|
51
|
+
end
|
40
52
|
end
|
41
53
|
|
42
54
|
##############
|
@@ -52,7 +64,7 @@ module Futest
|
|
52
64
|
# Print error message
|
53
65
|
def e(y)
|
54
66
|
y.backtrace.first.match(/(\/.+\/.*.rb):(\d{1,9}):/)
|
55
|
-
halt(%{#{y.message}\n=> ~/#{$1.split('/')[3..-1].join('/')}}, nil, $2) if $1
|
67
|
+
halt(%{#{y.message}\n=> ~/#{$1.split('/')[3..-1].join('/')}}, nil, $2) if $1 and $2
|
56
68
|
halt(%{#{y.message}\n=> #{y.backtrace.join("\n")}})
|
57
69
|
end
|
58
70
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: futest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fugroup Limited
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Program your tests as normal scripts without dependencies, mocks, stubs
|
14
14
|
and rules.
|