shindo 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shindo (0.1.12)
4
+ shindo (0.2.0)
5
5
  formatador (>= 0.0.16)
6
6
 
7
7
  GEM
data/README.rdoc CHANGED
@@ -18,29 +18,72 @@ Returns takes what you expect and checks a block to see if the return value matc
18
18
  Raises takes what error you expect and checks to see if the block will raise it:
19
19
 
20
20
  Shindo.tests do
21
- raises(StandardError) { StandardError.new }
21
+ raises(StandardError) { raise StandardError.new }
22
22
  end
23
23
 
24
+ For one off simple tests like this you can also chain the calls like this:
25
+
26
+ Shindo.tests('raises').raises(StandardError) { raise StandardError.new }
27
+
24
28
  You can also override the default descriptions:
25
29
 
26
30
  Shindo.tests('foo/bar') do
27
31
  returns('foo', 'returns foo when bar') { 'foo' }
28
- returns('bar', 'returns bar when qux') { 'bar' }
32
+ raises(StandardError, 'raises StandardError when baz') { raise StandardError }
33
+ end
34
+
35
+ Or nest things inside tests blocks:
36
+ Shindo.tests do
37
+ tests('returns') do
38
+ returns('foo', 'returns foo when bar') { 'foo' }
39
+ returns('bar', 'returns bar when baz') { 'bar' }
40
+ end
41
+ tests('raises') do
42
+ raises(StandardError, 'raises StandardError when baz') { raise StandardError }
43
+ raises(StandardError, 'raises StandardError when qux') { raise StandardError }
44
+ end
29
45
  end
30
46
 
31
47
  Then, if you want to get real fancy you can also tag your tests, to help narrow down which ones to run
32
48
 
33
49
  Shindo.tests('tests for foo', 'foo') do
34
- test('foo') { true }
50
+ test('foo') { true }
35
51
  end
36
52
 
37
53
  Shindo.tests('tests for bar', 'bar') do
38
- test('bar') { true }
39
- end
54
+ test('bar') { true }
40
55
  end
41
56
 
42
57
  Note: you'll have to supply a non-default description first, and then follow up with tags.
43
58
 
59
+ == Setup and Teardown
60
+
61
+ Tests get evaluated in the file just like you see it so you can add setup and teardown easily:
62
+
63
+ Shindo.tests do
64
+ foo = 'bar' # setup
65
+ tests('foo').returns('bar') { foo }
66
+
67
+ foo = 'baz' # cleanup after last
68
+ tests('foo').returns('baz') { foo }
69
+
70
+ foo = nil # teardown
71
+ end
72
+
73
+ That can get pretty tedious if it needs to happen before or after every single test though, so there are helpers:
74
+
75
+ Shindo.tests do
76
+ before do
77
+ @object = Object.new
78
+ end
79
+
80
+ after do
81
+ @object = nil
82
+ end
83
+
84
+ tests('@object.class').returns(Object) { @object.class }
85
+ end
86
+
44
87
  == Running tests
45
88
 
46
89
  Run tests with the shindo command, the easiest is to specify a file name:
data/lib/shindo.rb CHANGED
@@ -4,7 +4,7 @@ require 'formatador'
4
4
  module Shindo
5
5
 
6
6
  unless const_defined?(:VERSION)
7
- VERSION = '0.2.0'
7
+ VERSION = '0.2.1'
8
8
  end
9
9
 
10
10
  def self.tests(description = nil, tags = [], &block)
@@ -93,12 +93,12 @@ module Shindo
93
93
  self
94
94
  end
95
95
 
96
- def raises(error, &block)
97
- assert(:raises, error, "raises #{error.inspect}", &block)
96
+ def raises(error, description = "raises #{error.inspect}", &block)
97
+ assert(:raises, error, description, &block)
98
98
  end
99
99
 
100
- def returns(expectation, &block)
101
- assert(:returns, expectation, "returns #{expectation.inspect}", &block)
100
+ def returns(expectation, description = "returns #{expectation.inspect}", &block)
101
+ assert(:returns, expectation, description, &block)
102
102
  end
103
103
 
104
104
  def test(description = 'returns true', &block)
data/shindo.gemspec CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'shindo'
16
- s.version = '0.2.0'
17
- s.date = '2011-01-24'
16
+ s.version = '0.2.1'
17
+ s.date = '2011-01-25'
18
18
  s.rubyforge_project = 'shindo'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shindo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - geemus (Wesley Beary)
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-24 00:00:00 -08:00
18
+ date: 2011-01-25 00:00:00 -08:00
19
19
  default_executable: shindo
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency