futest 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/futest.rb +25 -13
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c02550d3a79fd48b5707e6764d207645d7ecfc90
4
- data.tar.gz: e8ef4c6177b957dd742d5d57d4fbf4af85ebfd07
3
+ metadata.gz: 8850fe934a2e18c66630fe2c567d5d79bbc9c816
4
+ data.tar.gz: 9386f5dccf59dd019fcc4ffb30f64ee04ffbb1d3
5
5
  SHA512:
6
- metadata.gz: fff0bec4d45a6d0c7150ee59ca2c0454e710ddb2d8d634f1afb10c9d589a83ae673bdf53cc9da2596e23d4fd82de1df32343d28039e54dca1b2b9443d3f8edd4
7
- data.tar.gz: 59479094d301dfa2ad9bc368a57f7b6365da3cf6bb4e369d4795f24da959f8dff0efc6a2a777d680a8364cbee76651b98c86b44cbebce068d1c7ef1907a14718
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
- if obj and obj.errors.any?
12
- n = obj.errors.messages
13
- m += ":\n=> " + n.each{|k, v| n[k] = v.join(', ')}.to_json[1..-2].gsub('","', '", "')
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
- halt("#{v1} is #{v2}", nil, n) unless v1 == v2
30
- end
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
- # Greater than tester
33
- def gt(v1, v2, n = x(caller))
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
- # Less than tester
38
- def lt(v1, v2, n = x(caller))
39
- halt("#{v1} lt #{v2}", nil, n) unless v1 < v2
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.present? and $2.present?
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.1
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-04 00:00:00.000000000 Z
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.