futest 0.0.1

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 +7 -0
  2. data/lib/futest.rb +65 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c02550d3a79fd48b5707e6764d207645d7ecfc90
4
+ data.tar.gz: e8ef4c6177b957dd742d5d57d4fbf4af85ebfd07
5
+ SHA512:
6
+ metadata.gz: fff0bec4d45a6d0c7150ee59ca2c0454e710ddb2d8d634f1afb10c9d589a83ae673bdf53cc9da2596e23d4fd82de1df32343d28039e54dca1b2b9443d3f8edd4
7
+ data.tar.gz: 59479094d301dfa2ad9bc368a57f7b6365da3cf6bb4e369d4795f24da959f8dff0efc6a2a777d680a8364cbee76651b98c86b44cbebce068d1c7ef1907a14718
data/lib/futest.rb ADDED
@@ -0,0 +1,65 @@
1
+ module Futest
2
+ module Helpers
3
+
4
+ ##############
5
+ # TEST METHODS
6
+ ##############
7
+
8
+ # Prints error message and stops execution
9
+ def halt(str, obj = nil, n = x(caller))
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('","', '", "')
14
+ end
15
+ puts red(%{#{m}})
16
+ puts
17
+ exit(0)
18
+ end
19
+
20
+ # Prints the test and runs setup methods
21
+ def test(*args)
22
+ n = args[-1].is_a?(Integer) ? args[-1] : x(caller)
23
+ args.select{|r| r.is_a?(Symbol)}.each{|k| send(k)}
24
+ puts green("#{n}: #{args[0]}")
25
+ end
26
+
27
+ # Equality tester
28
+ def is(v1, v2, n = x(caller))
29
+ halt("#{v1} is #{v2}", nil, n) unless v1 == v2
30
+ end
31
+
32
+ # Greater than tester
33
+ def gt(v1, v2, n = x(caller))
34
+ halt("#{v1} gt #{v2}", nil, n) unless v1 > v2
35
+ end
36
+
37
+ # Less than tester
38
+ def lt(v1, v2, n = x(caller))
39
+ halt("#{v1} lt #{v2}", nil, n) unless v1 < v2
40
+ end
41
+
42
+ ##############
43
+ # HELPER METHODS
44
+ ##############
45
+
46
+ # Colorize input red
47
+ def red(text);"\e[31m#{text}\e[0m";end
48
+
49
+ # Colorize input green
50
+ def green(text);"\e[33m#{text}\e[0m";end
51
+
52
+ # Print error message
53
+ def e(y)
54
+ 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?
56
+ halt(%{#{y.message}\n=> #{y.backtrace.join("\n")}})
57
+ end
58
+
59
+ # Get the line number
60
+ def x(q)
61
+ q.first.split(':')[1]
62
+ end
63
+
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: futest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Fugroup Limited
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Program your tests as normal scripts without dependencies, mocks, stubs
14
+ and rules.
15
+ email: mail@fugroup.net
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/futest.rb
21
+ homepage: https://github.com/fugroup/futest
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.5.1
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Futest flexible testing for Ruby
45
+ test_files: []