Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first commit

  • Loading branch information...
commit 0d425683bdd728cfeab518a475b10c25cc98b695 0 parents
@txus authored
6 .gitignore
@@ -0,0 +1,6 @@
+*.gem
+.bundle
+pkg/*
+graph.png
+.yardoc/*
+doc/*
1  .rvmrc
@@ -0,0 +1 @@
+rvm --create use ruby-1.9.2@a
81 Readme.md
@@ -0,0 +1,81 @@
+#a
+
+**a** is a testing framework written in 6 lines of code (or 473 characters)
+which tries to be performant, with eye-catchy reports and easy to use.
+
+Heavily inspired by Konstantin Haase's [almost-sinatra](
+http://github.com/rkh/almost-sinatra), its long-term purpose is to become the
+fastest testing framework available.
+
+In order to contribute to **a**, you have to bear in mind that the code
+**must** stay under 7 lines and with **less than 80 chars** per line. There is
+room for optimization.
+
+##Features
+
+ * Setup / Teardown
+ * Assertions (using the `a` method)
+ * Report tests/assertions/failures
+ * Keep track of lines where failures happened
+
+##Install
+
+ $ gem install a-gem
+
+Or in your Gemfile:
+
+ gem 'a-gem'
+
+##Usage
+
+````ruby
+require 'a'
+
+class MyTestCase < A
+ def setup
+ @user = { :some => :object }
+ end
+
+ def test_user_has_property
+ a @user[:some] == :object
+ a !@user[:other]
+ end
+
+ def teardown
+ @user = nil
+ end
+end
+
+class MyOtherTestCase < A
+ def setup
+ @foo = [1,2,3]
+ end
+
+ def test_user_has_property
+ a @foo.length == 3
+ a @foo[2] > 934 # Should fail at line 27
+
+ @foo[1] = 99
+
+ a @foo[1] != 2
+ end
+
+ def teardown
+ @bar = :something
+ end
+end
+````
+
+And voilà:
+
+![a](http://dl.dropbox.com/u/2571594/a.png)
+
+##Disclaimer
+
+**a** has no automated tests nor documentation, and I will have to turn down
+any pull request that contains those, unless the tests are written in **a**
+itself.
+
+## Copyright
+
+Copyright (c) 2011 Josep M. Bach. Released under the MIT license.
16 a.gemspec
@@ -0,0 +1,16 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |gem|
+ gem.authors = ["Josep M. Bach"]
+ gem.email = ["josep.m.bach@gmail.com"]
+ gem.description = %q{th fstst tstng frmwrk.}
+ gem.summary = %q{th fstst tstng frmwrk.}
+ gem.homepage = 'http://github.com/txus/a'
+
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ gem.files = `git ls-files`.split("\n")
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ gem.name = "a-gem"
+ gem.require_paths = ['lib']
+ gem.version = '0.0.1'
+end
37 examples/my_test.rb
@@ -0,0 +1,37 @@
+$: << 'lib'
+
+require 'a'
+
+class MyTestCase < A
+ def setup
+ @user = { :some => :object }
+ end
+
+ def test_user_has_property
+ a @user[:some] == :object
+ a !@user[:other]
+ end
+
+ def teardown
+ @user = nil
+ end
+end
+
+class MyOtherTestCase < A
+ def setup
+ @foo = [1,2,3]
+ end
+
+ def test_user_has_property
+ a @foo.length == 3
+ a @foo[2] > 934 # Should fail at line 27
+
+ @foo[1] = 99
+
+ a @foo[1] != 2
+ end
+
+ def teardown
+ @bar = :something
+ end
+end
6 lib/a.rb
@@ -0,0 +1,6 @@
+$n=Time.now;$f=[];$t=[];$a=0;class A;def a c;$a+=1;print c ?"\e[32m.\e[0m":($f\
+<<caller[0];"\e[31mF\e[0m");end;def self.inherited(b);$t<<b;end;end;at_exit{$t\
+.map{|t|i=t.new;i.setup rescue nil;t.instance_methods(false).map{|m|i.send m \
+if !%w(setup teardown).include? m};i.teardown rescue nil};print "\n#{Time.now-
+$n} s.\n#{$t.size} tests, #{$a} assertions, #{$f.size} failures\n\n"+$f.map{|f|
+"\e[31mFailure\e[0m \e[97m@\e[33m #{f}"}.join("\n")+"\n";exit -1 if $f[0]}
Please sign in to comment.
Something went wrong with that request. Please try again.