a-gem 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/.gitignore +6 -0
  2. data/.rvmrc +1 -0
  3. data/Readme.md +83 -0
  4. data/a.gemspec +16 -0
  5. data/examples/my_test.rb +37 -0
  6. data/lib/a.rb +6 -0
  7. metadata +60 -0
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ pkg/*
4
+ graph.png
5
+ .yardoc/*
6
+ doc/*
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create use ruby-1.9.2@a
@@ -0,0 +1,83 @@
1
+ #a
2
+
3
+ **a** is a testing framework written in [6 lines of code](
4
+ https://github.com/txus/a/blob/master/lib/a.rb) (or 473 characters) which
5
+ tries to be performant, with eye-catchy reports and easy to use.
6
+
7
+ Heavily inspired by Konstantin Haase's [almost-sinatra](
8
+ http://github.com/rkh/almost-sinatra), its long-term purpose is to become the
9
+ fastest testing framework available.
10
+
11
+ In order to contribute to **a**, you have to bear in mind that the code
12
+ **must** stay under 7 lines and with **less than 80 chars** per line. There is
13
+ room for optimization.
14
+
15
+ ##Features
16
+
17
+ * Setup / Teardown
18
+ * Assertions (using the `a` method)
19
+ * Report tests/assertions/failures
20
+ * Keep track of lines where failures happened
21
+
22
+ ##Install
23
+
24
+ $ gem install a-gem
25
+
26
+ Or in your Gemfile:
27
+
28
+ gem 'a-gem'
29
+
30
+ ##Usage
31
+
32
+ ````ruby
33
+ require 'a'
34
+
35
+ class MyTestCase < A
36
+ def setup
37
+ @user = { :some => :object }
38
+ end
39
+
40
+ def test_user_has_property
41
+ a @user[:some] == :object
42
+ a !@user[:other]
43
+ end
44
+
45
+ def teardown
46
+ @user = nil
47
+ end
48
+ end
49
+
50
+ class MyOtherTestCase < A
51
+ def setup
52
+ @foo = [1,2,3]
53
+ end
54
+
55
+ def test_user_has_property
56
+ a @foo.length == 3
57
+ a @foo[2] > 934 # Should fail at line 27
58
+
59
+ @foo[1] = 99
60
+
61
+ a @foo[1] != 2
62
+ end
63
+
64
+ def teardown
65
+ @bar = :something
66
+ end
67
+ end
68
+ ````
69
+
70
+ And voilà:
71
+
72
+ ![a](http://dl.dropbox.com/u/2571594/a.png)
73
+
74
+ ##Disclaimer
75
+
76
+ **a** has no automated tests nor documentation, and I will have to turn down
77
+ any pull request that contains those, unless the tests are written in **a**
78
+ itself.
79
+
80
+ ## Copyright
81
+
82
+ Copyright (c) 2011 Josep M. Bach. Released under the MIT license.
83
+
@@ -0,0 +1,16 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["Josep M. Bach"]
5
+ gem.email = ["josep.m.bach@gmail.com"]
6
+ gem.description = %q{th fstst tstng frmwrk.}
7
+ gem.summary = %q{th fstst tstng frmwrk.}
8
+ gem.homepage = 'http://github.com/txus/a'
9
+
10
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ gem.name = "a-gem"
14
+ gem.require_paths = ['lib']
15
+ gem.version = '0.0.1'
16
+ end
@@ -0,0 +1,37 @@
1
+ $: << 'lib'
2
+
3
+ require 'a'
4
+
5
+ class MyTestCase < A
6
+ def setup
7
+ @user = { :some => :object }
8
+ end
9
+
10
+ def test_user_has_property
11
+ a @user[:some] == :object
12
+ a !@user[:other]
13
+ end
14
+
15
+ def teardown
16
+ @user = nil
17
+ end
18
+ end
19
+
20
+ class MyOtherTestCase < A
21
+ def setup
22
+ @foo = [1,2,3]
23
+ end
24
+
25
+ def test_user_has_property
26
+ a @foo.length == 3
27
+ a @foo[2] > 934 # Should fail at line 27
28
+
29
+ @foo[1] = 99
30
+
31
+ a @foo[1] != 2
32
+ end
33
+
34
+ def teardown
35
+ @bar = :something
36
+ end
37
+ end
@@ -0,0 +1,6 @@
1
+ $n=Time.now;$f=[];$t=[];$a=0;class A;def a c;$a+=1;print c ?"\e[32m.\e[0m":($f\
2
+ <<caller[0];"\e[31mF\e[0m");end;def self.inherited(b);$t<<b;end;end;at_exit{$t\
3
+ .map{|t|i=t.new;i.setup rescue nil;t.instance_methods(false).map{|m|i.send m \
4
+ if !%w(setup teardown).include? m};i.teardown rescue nil};print "\n#{Time.now-
5
+ $n} s.\n#{$t.size} tests, #{$a} assertions, #{$f.size} failures\n\n"+$f.map{|f|
6
+ "\e[31mFailure\e[0m \e[97m@\e[33m #{f}"}.join("\n")+"\n";exit -1 if $f[0]}
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: a-gem
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Josep M. Bach
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-07-06 00:00:00 Z
14
+ dependencies: []
15
+
16
+ description: th fstst tstng frmwrk.
17
+ email:
18
+ - josep.m.bach@gmail.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - .gitignore
27
+ - .rvmrc
28
+ - Readme.md
29
+ - a.gemspec
30
+ - examples/my_test.rb
31
+ - lib/a.rb
32
+ homepage: http://github.com/txus/a
33
+ licenses: []
34
+
35
+ post_install_message:
36
+ rdoc_options: []
37
+
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ requirements: []
53
+
54
+ rubyforge_project:
55
+ rubygems_version: 1.8.4
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: th fstst tstng frmwrk.
59
+ test_files: []
60
+