InlineTester 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dfa8eab0b0edc262020d149d928b11e8c379f79c
4
+ data.tar.gz: bd64e31e4073bc95ea42a32155dbc88cb48d79a9
5
+ SHA512:
6
+ metadata.gz: 9914c721a40092ef19b998dc6c293d087ad67521efbe4275ebe92b1679a56c2d03e9cf1a4e944c9b58e13f203454bf614da2abe3581c09a24d381d6cc68685c8
7
+ data.tar.gz: bd0c3522c7de07d9ea2e7a90484340e9074f59835d40804cf7fdec23f49195f263eba69d6895320279916179449566ad04b6f89506ab8581859413d41c63945a
data/lib/assertions.rb ADDED
@@ -0,0 +1,72 @@
1
+ module InlineTester
2
+
3
+ module Assertions
4
+
5
+ $__stack_ = 2
6
+
7
+ public
8
+ def assert boolean, message=nil
9
+ unless boolean
10
+ # MESSAGE::: Assertion did not pass.
11
+ $stdout.print(message ||
12
+ "Expected a truthy value, but instead got #{boolean}")
13
+ stack_trace_print
14
+ else
15
+
16
+ end
17
+ end
18
+
19
+ def refute boolean, message=nil
20
+ if boolean
21
+ # MESSAGE::: Refution did not pass.
22
+ $stdout.print(message ||
23
+ "Expected a falsy value, but instead got #{boolean}")
24
+ stack_trace_print
25
+ else
26
+
27
+ end
28
+ end
29
+
30
+ def assert_something_raised message=nil, &block
31
+ begin
32
+ yield
33
+ # Message::: Nothing raised.
34
+ $stdout.print(message ||
35
+ "Expected #{block} to raise an Exception, but it did not.")
36
+ stack_trace_print
37
+ rescue => e
38
+
39
+ end
40
+ end
41
+
42
+ def assert_matches string, pattern, message=nil
43
+ $__stack_+=1
44
+ assert(string =~ pattern, message ||
45
+ "Expected #{string} to match #{pattern}, but it did not.")
46
+ $__stack_-=1
47
+ end
48
+
49
+ def skip message=nil, &block
50
+ $stdout.print message || "Skipped assertion."
51
+ if block_given?
52
+ yield
53
+ end
54
+ end
55
+
56
+ def todo message=nil
57
+ $stdout.print message || "TODO!"
58
+ stack_trace_print
59
+ end
60
+
61
+ private
62
+ def stack_trace_print
63
+ puts " from:"
64
+ # Print stack trace from _stack_ with at most 3 more deep
65
+ caller_locations($__stack_, 3).map do |call|
66
+ $stdout.puts "===> #{call.to_s}"
67
+ end
68
+ end
69
+
70
+ end
71
+
72
+ end
@@ -0,0 +1,7 @@
1
+ require_relative 'assertions'
2
+
3
+ module InlineTester
4
+
5
+ end
6
+
7
+ include InlineTester::Assertions
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: InlineTester
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Christian Tschoepe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: An amazingly simple way to test & debug with assertions -- right in your
14
+ code! Allows you to test inline without writing any seperate unit tests as everything
15
+ is mixed into pour code. This helps ensure, for web apps like Rails, that if something
16
+ has gone wrong that shouldn't it gets reported in your logs without having to worry
17
+ about exception raising and rescuing. Want a unit testing library? This small library
18
+ can get you started in the right direction!
19
+ email: tschoepe.christian@gmail.com
20
+ executables: []
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - lib/assertions.rb
25
+ - lib/inline_tester.rb
26
+ homepage: http://rubygems.org/gems/inlinetester
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.2.2
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: An amazingly simple way to test & debug with assertions -- right in your
50
+ code!
51
+ test_files: []
52
+ has_rdoc: