aki-testrocket 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ rvm:
2
+ - 1.9.2
3
+ gemfile: gemfiles/Gemfile.travis
4
+ notifications:
5
+ recipients:
6
+ - chris@dinarrr.com
7
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in testrocket.gemspec
4
+ gemspec
data/Gemfile.travis ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rake" # added for travis-ci.org
4
+
5
+ # Specify your gem's dependencies in testrocket.gemspec
6
+ gemspec
data/HISTORY ADDED
@@ -0,0 +1,3 @@
1
+ 0.0.1 - August 10, 2011
2
+
3
+ - Initial release
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,64 @@
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
+ # A 'pending' test
45
+ ~-> { "this is a pending test" }
46
+
47
+ # A description
48
+ !-> { "use this for descriptive output and to separate your test parts" }
49
+
50
+ Other Features
51
+ --------------
52
+
53
+ 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:
54
+
55
+ TestRocket.out = File.new('/dev/null', 'w')
56
+
57
+ TestRocket.out also supports Logger instances.
58
+
59
+ Authors
60
+ -------
61
+
62
+ Initial concept and maintenance by Peter Cooper
63
+
64
+ Extra concepts and code by Christoph Grabo
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rake/testtask'
5
+ Rake::TestTask.new(:test) do |test|
6
+ test.libs << 'lib' << 'test'
7
+ test.pattern = 'test/**/test_*.rb'
8
+ test.verbose = true
9
+ end
10
+
11
+ task :default => :test
data/lib/testrocket.rb ADDED
@@ -0,0 +1,19 @@
1
+ module TestRocket
2
+ extend Module.new { attr_accessor :out }
3
+
4
+ def _test(a, b)
5
+ send((call rescue()) ? a : b)
6
+ end
7
+
8
+ def +@; r = _test :_pass, :_fail; (TestRocket.out || $>) << r; r end
9
+ def -@; r = _test :_fail, :_pass; (TestRocket.out || $>) << r; r end
10
+ def ~@; r = _pend; (TestRocket.out || $>) << r; r end
11
+ def !@; r = _desc; (TestRocket.out || $>) << r; r end
12
+
13
+ def _pass; " OK\n"; end
14
+ def _fail; " FAIL @ #{source_location.join(':')}\n"; end
15
+ def _pend; "PENDING '#{call.to_s}' @ #{source_location.join(':')}\n"; end
16
+ def _desc; " FIRE '#{call.to_s}'!\n"; end
17
+ end
18
+
19
+ Proc.send :include, TestRocket
@@ -0,0 +1,3 @@
1
+ module Testrocket
2
+ VERSION = "0.0.2"
3
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'minitest/autorun'
2
+ require 'testrocket'
3
+
4
+ TestRocket.out = File.new('/dev/null', 'w')
@@ -0,0 +1,33 @@
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
+
24
+ it "should give a pending notice" do
25
+ (~->{ "a pending test" }).must_match(/PENDING/)
26
+ (~->{ "a pending test" }).must_match(/a pending test/)
27
+ end
28
+
29
+ it "should fire a description rocket" do
30
+ (!->{ "a description" }).must_match(/FIRE/)
31
+ (!->{ "a description" }).must_match(/a description/)
32
+ end
33
+ end
@@ -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 = "aki-testrocket"
7
+ s.version = Testrocket::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Peter Cooper","Christoph Grabo"]
10
+ s.email = ["git@peterc.org","chris@dinarrr.com"]
11
+ s.homepage = "http://github.com/asaaki/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 = "aki-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,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aki-testrocket
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Peter Cooper
9
+ - Christoph Grabo
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2011-08-14 00:00:00.000000000Z
14
+ dependencies: []
15
+ description: A super lightweight testing library for Ruby
16
+ email:
17
+ - git@peterc.org
18
+ - chris@dinarrr.com
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - .gitignore
24
+ - .travis.yml
25
+ - Gemfile
26
+ - Gemfile.travis
27
+ - HISTORY
28
+ - LICENSE
29
+ - README.md
30
+ - Rakefile
31
+ - lib/testrocket.rb
32
+ - lib/testrocket/version.rb
33
+ - test/helper.rb
34
+ - test/test_testrocket.rb
35
+ - testrocket.gemspec
36
+ homepage: http://github.com/asaaki/testrocket
37
+ licenses: []
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project: aki-testrocket
56
+ rubygems_version: 1.8.6
57
+ signing_key:
58
+ specification_version: 3
59
+ summary: A super lightweight testing library for Ruby
60
+ test_files: []