futest 0.0.2 → 0.0.3
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 +8 -74
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3141c2f5c21a663adbb2326ddc21976a06a1400
|
4
|
+
data.tar.gz: f1893bfbb44190da5b48134a1e9be0e3729d12ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b441d76f59e02aa53acf6979ed2028d456fc1afd206c73ac736a75be452e127fdb714c6bf4d8b162abb538156ac015a1d4413cd976c2606d0df9b234face1cbd
|
7
|
+
data.tar.gz: b7257e16f4c0751373948b345985a26cc9c39cbf32e813bae120bce194cea84ebc541ca55ba32158d508f378e47b3215111773142e543da7b252ef861360bc67
|
data/lib/futest.rb
CHANGED
@@ -1,77 +1,11 @@
|
|
1
1
|
module Futest
|
2
|
-
module Helpers
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
m = "#{n}: #{str}"
|
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('","', '", "')
|
15
|
-
end
|
16
|
-
puts red(%{#{m}})
|
17
|
-
puts
|
18
|
-
exit(0)
|
19
|
-
end
|
20
|
-
|
21
|
-
# Prints the test and runs setup methods
|
22
|
-
def test(*args)
|
23
|
-
n = args[-1].is_a?(Integer) ? args[-1] : x(caller)
|
24
|
-
args.select{|r| r.is_a?(Symbol)}.each{|k| send(k)}
|
25
|
-
puts green("#{n}: #{args[0]}")
|
26
|
-
end
|
27
|
-
|
28
|
-
# Equality tester
|
29
|
-
def is(v1, v2, n = x(caller))
|
30
|
-
v2 = {:eq => v2} unless v2.is_a?(Hash)
|
31
|
-
# Extract options here with delete.
|
32
|
-
# No options available at the moment.
|
33
|
-
|
34
|
-
# For key output
|
35
|
-
def fs(y);{:eq => '==', :gt => '>', :lt => '<', :a? => 'is a'}[y] rescue y;end
|
36
|
-
|
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
|
52
|
-
end
|
53
|
-
|
54
|
-
##############
|
55
|
-
# HELPER METHODS
|
56
|
-
##############
|
57
|
-
|
58
|
-
# Colorize input red
|
59
|
-
def red(text);"\e[31m#{text}\e[0m";end
|
60
|
-
|
61
|
-
# Colorize input green
|
62
|
-
def green(text);"\e[33m#{text}\e[0m";end
|
63
|
-
|
64
|
-
# Print error message
|
65
|
-
def e(y)
|
66
|
-
y.backtrace.first.match(/(\/.+\/.*.rb):(\d{1,9}):/)
|
67
|
-
halt(%{#{y.message}\n=> ~/#{$1.split('/')[3..-1].join('/')}}, nil, $2) if $1 and $2
|
68
|
-
halt(%{#{y.message}\n=> #{y.backtrace.join("\n")}})
|
69
|
-
end
|
70
|
-
|
71
|
-
# Get the line number
|
72
|
-
def x(q)
|
73
|
-
q.first.split(':')[1]
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
3
|
+
# # # # # #
|
4
|
+
# Futest flexible testing helpers for Ruby
|
5
|
+
# @homepage: https://github.com/fugroup/futest
|
6
|
+
# @author: Vidar <vidar@fugroup.net>, Fugroup Ltd.
|
7
|
+
# @license: MIT, contributions are welcome.
|
8
|
+
# # # # # #
|
77
9
|
end
|
10
|
+
|
11
|
+
require_relative 'futest/helpers'
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
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.3
|
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-
|
12
|
-
dependencies:
|
11
|
+
date: 2016-12-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
description: Program your tests as normal scripts without dependencies, mocks, stubs
|
14
28
|
and rules.
|
15
29
|
email: mail@fugroup.net
|