testrocket 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/HISTORY +3 -0
- data/LICENSE +9 -0
- data/README.md +49 -0
- data/Rakefile +11 -0
- data/lib/testrocket/version.rb +3 -0
- data/lib/testrocket.rb +15 -0
- data/test/helper.rb +4 -0
- data/test/test_testrocket.rb +23 -0
- data/testrocket.gemspec +21 -0
- metadata +68 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/HISTORY
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
This is a modified MIT license.
|
2
|
+
|
3
|
+
Copyright © 2011 Peter Cooper (http://peterc.org/)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sub-license, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice, and every other copyright notice found in this software, and all the attributions in every file, and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
_ _ _ _
|
2
|
+
| |_ ___ ___| |_ _ __ ___ ___| | __ ___| |_
|
3
|
+
| __|/ _ | __| __| '__/ _ \ / __| |/ // _ \ __|
|
4
|
+
| |_| __|__ \ |_| | | (_) | (__| <| __/ |_
|
5
|
+
\__|\___|___/\__|_| \___/ \___|_|\_\\___|\__|
|
6
|
+
|
7
|
+
Testrocket is a super simple (as simple as it gets really) testing library for Ruby.
|
8
|
+
|
9
|
+
It was initially developed for [this CodeBrawl competition](http://codebrawl.com/articles/contest-rundown-ruby-testing-libraries) and it won! People then asked me to release it 'for real' so here we are.
|
10
|
+
|
11
|
+
To install:
|
12
|
+
|
13
|
+
gem install testrocket
|
14
|
+
|
15
|
+
As yet there are no useful bits and pieces for creating test files (look at the example, it's easy!) or Rake tasks. But it's all crazy simple. A few things may be added later on.
|
16
|
+
|
17
|
+
Dependencies
|
18
|
+
------------
|
19
|
+
|
20
|
+
- Ruby 1.9
|
21
|
+
- minitest/spec (part of MRI 1.9 stdlib)
|
22
|
+
- Unix/Unix-like/POSIX system
|
23
|
+
|
24
|
+
Example
|
25
|
+
-------
|
26
|
+
|
27
|
+
require 'testrocket'
|
28
|
+
|
29
|
+
# ===========================================================
|
30
|
+
# EXAMPLE TEST "SUITE" FOR "DIE"
|
31
|
+
#
|
32
|
+
# USAGE
|
33
|
+
# +-> { block that should succeed }
|
34
|
+
# --> { block that should fail }
|
35
|
+
|
36
|
+
+-> { Die.new(2) }
|
37
|
+
--> { raise }
|
38
|
+
+-> { 2 + 2 == 4 }
|
39
|
+
|
40
|
+
# These two tests will deliberately fail
|
41
|
+
+-> { raise }
|
42
|
+
--> { true }
|
43
|
+
|
44
|
+
Other Features
|
45
|
+
--------------
|
46
|
+
|
47
|
+
By default, output is written to STDOUT (as well as returned by the test expressions themselves). You can override where test output goes like so:
|
48
|
+
|
49
|
+
TestRocket.out = File.new('/dev/null', 'w')
|
data/Rakefile
ADDED
data/lib/testrocket.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module TestRocket
|
2
|
+
module Out; attr_accessor :out; end; extend Out
|
3
|
+
|
4
|
+
def _test(a, b)
|
5
|
+
send((call rescue()) ? a : b)
|
6
|
+
end
|
7
|
+
|
8
|
+
def +@; r = _test :_pass, :_fail; (TestRocket.out || $>).puts r; r end
|
9
|
+
def -@; r = _test :_fail, :_pass; (TestRocket.out || $>).puts r; r end
|
10
|
+
|
11
|
+
def _pass; ' OK'; end
|
12
|
+
def _fail; "FAIL @ #{source_location.join(':')}"; end
|
13
|
+
end
|
14
|
+
|
15
|
+
Proc.send :include, TestRocket
|
data/test/helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe TestRocket do
|
4
|
+
it "should find emptiness non-truthful by default" do
|
5
|
+
(+->{}).must_match(/FAIL/)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should pass a simple positive assertion" do
|
9
|
+
(+->{ 2 + 2 == 4 }).must_match(/OK/)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should pass a simple negative assertion" do
|
13
|
+
(-->{ 2 + 2 == 5 }).must_match(/OK/)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should fail a simple erroneous assertion" do
|
17
|
+
(+->{ 2 + 2 == 5 }).must_match(/FAIL/)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should fail a simple correct assertion assumed to fail" do
|
21
|
+
(-->{ 2 + 2 == 4 }).must_match(/FAIL/)
|
22
|
+
end
|
23
|
+
end
|
data/testrocket.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "testrocket/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "testrocket"
|
7
|
+
s.version = Testrocket::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Peter Cooper"]
|
10
|
+
s.email = ["git@peterc.org"]
|
11
|
+
s.homepage = "http://github.com/peterc/testrocket"
|
12
|
+
s.summary = %q{A super lightweight testing library for Ruby}
|
13
|
+
s.description = %q{A super lightweight testing library for Ruby}
|
14
|
+
|
15
|
+
s.rubyforge_project = "testrocket"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: testrocket
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Peter Cooper
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-08-10 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: A super lightweight testing library for Ruby
|
18
|
+
email:
|
19
|
+
- git@peterc.org
|
20
|
+
executables: []
|
21
|
+
|
22
|
+
extensions: []
|
23
|
+
|
24
|
+
extra_rdoc_files: []
|
25
|
+
|
26
|
+
files:
|
27
|
+
- .gitignore
|
28
|
+
- Gemfile
|
29
|
+
- HISTORY
|
30
|
+
- LICENSE
|
31
|
+
- README.md
|
32
|
+
- Rakefile
|
33
|
+
- lib/testrocket.rb
|
34
|
+
- lib/testrocket/version.rb
|
35
|
+
- test/helper.rb
|
36
|
+
- test/test_testrocket.rb
|
37
|
+
- testrocket.gemspec
|
38
|
+
has_rdoc: true
|
39
|
+
homepage: http://github.com/peterc/testrocket
|
40
|
+
licenses: []
|
41
|
+
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
requirements: []
|
60
|
+
|
61
|
+
rubyforge_project: testrocket
|
62
|
+
rubygems_version: 1.6.2
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: A super lightweight testing library for Ruby
|
66
|
+
test_files:
|
67
|
+
- test/helper.rb
|
68
|
+
- test/test_testrocket.rb
|