shindo 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -8,65 +8,65 @@ There are two commands you should know, 'tests' and 'test'. Tests help you group
8
8
 
9
9
  A successful test should return true. (yay)
10
10
 
11
- Shindo.tests {
11
+ Shindo.tests do
12
12
  test('something really important') { true }
13
- }
13
+ end
14
14
 
15
15
  A failing test should return false or nil. (boo)
16
16
 
17
- Shindo.tests {
17
+ Shindo.tests do
18
18
  test('something (hopefully) less important') { false }
19
- }
19
+ end
20
20
 
21
21
  A pending test shouldn't even have a block (meh)
22
22
 
23
- Shindo.tests {
23
+ Shindo.tests do
24
24
  test('something that hasn't been gotten around to yet')
25
- }
25
+ end
26
26
 
27
27
  Grouping tests
28
28
 
29
- Shindo.tests {
30
- tests('foo/bar') {
29
+ Shindo.tests do
30
+ tests('foo/bar') do
31
31
  test('foo') { true }
32
32
  test('bar') { true }
33
- }
34
- }
33
+ end
34
+ end
35
35
 
36
36
  You can also have descriptions for Shindo.tests, and write that last one like this
37
37
 
38
- Shindo.tests('foo/bar') {
38
+ Shindo.tests('foo/bar') do
39
39
  test('foo') { true }
40
40
  test('bar') { false }
41
- }
41
+ end
42
42
 
43
43
  Nest tests as deeply as you would like.
44
44
 
45
45
  Then, if you want to get real fancy you can also tag your tests, to help narrow down which ones to run
46
46
 
47
- Shindo.tests {
48
- tests('foo/bar', ['foo', 'bar']) {
47
+ Shindo.tests do
48
+ tests('foo/bar', ['foo', 'bar']) do
49
49
  test('foo') { true }
50
50
  test('bar') { true }
51
- }
52
- }
51
+ end
52
+ end
53
53
 
54
54
  Or if you can narrow down even more tightly
55
55
 
56
- Shindo.tests {
57
- tests('foo/bar') {
56
+ Shindo.tests do
57
+ tests('foo/bar') do
58
58
  test('foo', ['foo']) { true }
59
59
  test('bar', ['bar']) { true }
60
- }
61
- }
60
+ end
61
+ end
62
62
 
63
63
  == Running tests
64
64
 
65
65
  Run tests with the shindo command, the easiest is to specify a file name:
66
66
 
67
- shindo some_test_file.rb
67
+ shindo something_tests.rb
68
68
 
69
- You can also give directories and it will run all .rb files inside (recurses through subdirectories)
69
+ You can also give directories and it will run all files ending in _tests.rb (recurses through subdirectories)
70
70
 
71
71
  shindo some_test_directory
72
72
 
data/Rakefile CHANGED
@@ -20,16 +20,16 @@ end
20
20
 
21
21
  require 'rake/testtask'
22
22
  Rake::TestTask.new(:test) do |test|
23
- test.libs << 'lib' << 'test'
24
- test.pattern = 'test/**/*_test.rb'
23
+ test.libs << 'lib' << 'tests'
24
+ test.pattern = 'tests/**/*_tests.rb'
25
25
  test.verbose = true
26
26
  end
27
27
 
28
28
  begin
29
29
  require 'rcov/rcovtask'
30
30
  Rcov::RcovTask.new do |test|
31
- test.libs << 'test'
32
- test.pattern = 'test/**/*_test.rb'
31
+ test.libs << 'tests'
32
+ test.pattern = 'tests/**/*_tests.rb'
33
33
  test.verbose = true
34
34
  end
35
35
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/bin/shindo CHANGED
@@ -9,14 +9,14 @@ for argument in ARGV
9
9
  else
10
10
  path = File.expand_path(argument)
11
11
  if File.directory?(path)
12
- files |= Dir.glob(File.join(path, '**', '*.rb'))
12
+ files |= Dir.glob(File.join(path, '**', '*_tests.rb'))
13
13
  else
14
14
  files << path
15
15
  end
16
16
  end
17
17
  end
18
18
 
19
- success = true
19
+ @success = true
20
20
  def run_in_thread(files, tags)
21
21
  tests = Thread.new {
22
22
  Thread.current[:tags] = tags
@@ -26,17 +26,16 @@ def run_in_thread(files, tags)
26
26
  }
27
27
  tests.join
28
28
  if tests[:reload]
29
+ @success = true
29
30
  run_in_thread(files, tags)
30
31
  else
31
- success = success && tests[:success]
32
+ @success = @success && tests[:success]
32
33
  end
33
34
  end
34
35
  run_in_thread(files, tags)
35
36
 
36
- at_exit {
37
- if success
38
- Kernel.exit(0)
39
- else
40
- Kernel.exit(1)
41
- end
42
- }
37
+ if @success
38
+ Kernel.exit(0)
39
+ else
40
+ Kernel.exit(1)
41
+ end
data/lib/shindo.rb CHANGED
@@ -17,8 +17,12 @@ module Shindo
17
17
  @annals = Annals.new
18
18
  @befores = []
19
19
  @description_stack = []
20
- @if_tagged = Thread.current[:tags].select {|tag| tag.match(/^\+/)}
21
- @unless_tagged = Thread.current[:tags].select {|tag| tag.match(/^\-/)}.map {|tag| tag[1..-1]}
20
+ self.if_tagged = Thread.current[:tags].
21
+ select {|tag| tag.match(/^\+/)}.
22
+ map {|tag| tag[1..-1]}
23
+ self.unless_tagged = Thread.current[:tags].
24
+ select {|tag| tag.match(/^\-/)}.
25
+ map {|tag| tag[1..-1]}
22
26
  @indent = 1
23
27
  @success = true
24
28
  @tag_stack = []
@@ -27,7 +31,7 @@ module Shindo
27
31
  tests(header, &block)
28
32
  print("\n")
29
33
  if @success
30
- Thread.current[:success] = false
34
+ Thread.current[:success] = true
31
35
  else
32
36
  Thread.current[:success] = false
33
37
  end
data/shindo.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{shindo}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["geemus (Wesley Beary)"]
12
- s.date = %q{2009-10-07}
12
+ s.date = %q{2009-11-02}
13
13
  s.default_executable = %q{shindo}
14
14
  s.description = %q{Simple depth first ruby testing}
15
15
  s.email = %q{me@geemus.com}
@@ -25,7 +25,10 @@ Gem::Specification.new do |s|
25
25
  "VERSION",
26
26
  "bin/shindo",
27
27
  "lib/shindo.rb",
28
- "shindo.gemspec"
28
+ "shindo.gemspec",
29
+ "tests/basic_tests.rb",
30
+ "tests/tag_tests.rb",
31
+ "tests/tests_helper.rb"
29
32
  ]
30
33
  s.homepage = %q{http://github.com/geemus/shindo}
31
34
  s.rdoc_options = ["--charset=UTF-8"]
@@ -0,0 +1,40 @@
1
+ require File.join(File.dirname(__FILE__), 'tests_helper')
2
+
3
+ success = Tempfile.new('success')
4
+ success << <<-TESTS
5
+ Shindo.tests do
6
+ test('success') { true }
7
+ end
8
+ TESTS
9
+ success.close
10
+
11
+ failure = Tempfile.new('failure')
12
+ failure << <<-TESTS
13
+ Shindo.tests do
14
+ test('failure') { false }
15
+ end
16
+ TESTS
17
+ failure.close
18
+
19
+ pending = Tempfile.new('pending')
20
+ pending << <<-TESTS
21
+ Shindo.tests do
22
+ test('pending')
23
+ end
24
+ TESTS
25
+ pending.close
26
+
27
+ Shindo.tests('basics') do
28
+ tests('failure') do
29
+ test('output') { `#{BIN} #{failure.path}`.include?('- failure') }
30
+ test('status') { $?.exitstatus == 1 }
31
+ end
32
+ tests('pending') do
33
+ test('output') { `#{BIN} #{pending.path}`.include?('* pending') }
34
+ test('status') { $?.exitstatus == 0 }
35
+ end
36
+ tests('success') do
37
+ test('output') { `#{BIN} #{success.path}`.include?('+ success') }
38
+ test('status') { $?.exitstatus == 0 }
39
+ end
40
+ end
@@ -0,0 +1,37 @@
1
+ require File.join(File.dirname(__FILE__), 'tests_helper')
2
+
3
+ negative = Tempfile.new('negative')
4
+ negative << <<-TESTS
5
+ Shindo.tests do
6
+ test('is tested') { true }
7
+ test('is skipped', 'negative') { false }
8
+ end
9
+ TESTS
10
+ negative.close
11
+
12
+ positive = Tempfile.new('positive')
13
+ positive << <<-TESTS
14
+ Shindo.tests do
15
+ test('is tested', 'positive') { true }
16
+ test('is skipped') { false }
17
+ end
18
+ TESTS
19
+ positive.close
20
+
21
+ Shindo.tests('tags') do
22
+
23
+ tests('negative') do
24
+ before { @output = `#{BIN} #{negative.path} -negative` }
25
+ test('is tested') { @output.include?('+ is tested') }
26
+ test('is skipped') { @output.include?('_ is skipped [negative]') }
27
+ test('status') { $?.exitstatus == 0 }
28
+ end
29
+
30
+ tests('positive') do
31
+ before { @output = `#{BIN} #{positive.path} +positive` }
32
+ test('is tested') { @output.include?('+ is tested [positive]') }
33
+ test('is skipped') { @output.include?('_ is skipped') }
34
+ test('status') { $?.exitstatus == 0 }
35
+ end
36
+
37
+ end
@@ -0,0 +1,16 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'shindo'
4
+ require 'tempfile'
5
+
6
+ unless Object.const_defined?(:BIN)
7
+ BIN = File.join(File.dirname(__FILE__), '..', 'bin', 'shindo')
8
+ end
9
+ tags = Thread.current[:tags] || []
10
+ ARGV.each do |arg|
11
+ if arg.match(/^[\+\-]/)
12
+ tags << arg
13
+ ARGV.delete(arg)
14
+ end
15
+ end
16
+ Thread.current[:tags] = tags
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shindo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - geemus (Wesley Beary)
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-07 00:00:00 -07:00
12
+ date: 2009-11-02 00:00:00 -08:00
13
13
  default_executable: shindo
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -39,6 +39,9 @@ files:
39
39
  - bin/shindo
40
40
  - lib/shindo.rb
41
41
  - shindo.gemspec
42
+ - tests/basic_tests.rb
43
+ - tests/tag_tests.rb
44
+ - tests/tests_helper.rb
42
45
  has_rdoc: true
43
46
  homepage: http://github.com/geemus/shindo
44
47
  licenses: []