shindo 0.0.14 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.14
1
+ 0.0.16
data/bin/shindo CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.join(File.dirname(__FILE__), '..', 'lib', 'shindo')
3
3
 
4
- helpers = Dir.glob(File.join(Dir.pwd, '**', '*helper.rb'))
4
+ helpers = Dir.glob(File.join(Dir.pwd, 'tests', '**', '*helper.rb'))
5
5
  tests = []
6
6
  tags = []
7
7
  for argument in ARGV
@@ -161,14 +161,18 @@ module Shindo
161
161
  if (@if_tagged.empty? || !(@if_tagged & @tag_stack.flatten).empty?) &&
162
162
  (@unless_tagged.empty? || (@unless_tagged & @tag_stack.flatten).empty?)
163
163
  if block_given?
164
- for before in @befores.flatten.compact
165
- before.call
166
- end
167
-
168
- @annals.start
169
164
  begin
165
+ for before in @befores.flatten.compact
166
+ before.call
167
+ end
168
+
169
+ @annals.start
170
170
  success = instance_eval(&block)
171
171
  @annals.stop
172
+
173
+ for after in @afters.flatten.compact
174
+ after.call
175
+ end
172
176
  rescue => error
173
177
  @annals.stop
174
178
  success = false
@@ -190,10 +194,6 @@ module Shindo
190
194
  prompt(description, &block)
191
195
  end
192
196
  end
193
-
194
- for after in @afters.flatten.compact
195
- after.call
196
- end
197
197
  else
198
198
  @formatador.display_line("[yellow]* #{description}#{taggings}[/]")
199
199
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{shindo}
8
- s.version = "0.0.14"
8
+ s.version = "0.0.16"
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)"]
@@ -1,38 +1,50 @@
1
- success = Tempfile.new('success')
2
- success << <<-TESTS
3
- Shindo.tests do
4
- test('success') { true }
5
- end
6
- TESTS
7
- success.close
8
-
9
- failure = Tempfile.new('failure')
10
- failure << <<-TESTS
11
- Shindo.tests do
12
- test('failure') { false }
13
- end
14
- TESTS
15
- failure.close
16
-
17
- pending = Tempfile.new('pending')
18
- pending << <<-TESTS
19
- Shindo.tests do
20
- test('pending')
21
- end
22
- TESTS
23
- pending.close
24
-
25
1
  Shindo.tests('basics') do
2
+ tests('exception') do
3
+ before do
4
+ @tempfile = tempfile('exception', <<-TESTS)
5
+ Shindo.tests do
6
+ test('exception') { raise StandardError.new('exception') }
7
+ end
8
+ TESTS
9
+ @output = bin(@tempfile.path)
10
+ end
11
+ test('output') { @output.include?('- exception') }
12
+ test('status') { $?.exitstatus == 1 }
13
+ end
26
14
  tests('failure') do
27
- test('output') { `#{BIN} #{failure.path}`.include?('- failure') }
15
+ before do
16
+ @tempfile = tempfile('failure', <<-TESTS)
17
+ Shindo.tests do
18
+ test('failure') { false }
19
+ end
20
+ TESTS
21
+ @output = bin(@tempfile.path)
22
+ end
23
+ test('output') { @output.include?('- failure') }
28
24
  test('status') { $?.exitstatus == 1 }
29
25
  end
30
26
  tests('pending') do
31
- test('output') { `#{BIN} #{pending.path}`.include?('* pending') }
27
+ before do
28
+ @tempfile = tempfile('pending', <<-TESTS)
29
+ Shindo.tests do
30
+ test('pending')
31
+ end
32
+ TESTS
33
+ @output = bin(@tempfile.path)
34
+ end
35
+ test('output') { @output.include?('* pending') }
32
36
  test('status') { $?.exitstatus == 0 }
33
37
  end
34
38
  tests('success') do
35
- test('output') { `#{BIN} #{success.path}`.include?('+ success') }
39
+ before do
40
+ @tempfile = tempfile('success', <<-TESTS)
41
+ Shindo.tests do
42
+ test('success') { true }
43
+ end
44
+ TESTS
45
+ @output = bin(@tempfile.path)
46
+ end
47
+ test('output') { @output.include?('+ success') }
36
48
  test('status') { $?.exitstatus == 0 }
37
49
  end
38
50
  end
@@ -1,32 +1,30 @@
1
- negative = Tempfile.new('negative')
2
- negative << <<-TESTS
3
- Shindo.tests do
4
- test('is tested') { true }
5
- test('is skipped', 'negative') { false }
6
- end
7
- TESTS
8
- negative.close
9
-
10
- positive = Tempfile.new('positive')
11
- positive << <<-TESTS
12
- Shindo.tests do
13
- test('is tested', 'positive') { true }
14
- test('is skipped') { false }
15
- end
16
- TESTS
17
- positive.close
18
-
19
1
  Shindo.tests('tags') do
20
2
 
21
3
  tests('negative') do
22
- before { @output = `#{BIN} #{negative.path} -negative` }
4
+ before do
5
+ @tempfile = tempfile('negative', <<-TESTS)
6
+ Shindo.tests do
7
+ test('is tested') { true }
8
+ test('is skipped', 'negative') { false }
9
+ end
10
+ TESTS
11
+ @output = bin("#{@tempfile.path} -negative")
12
+ end
23
13
  test('is tested') { @output.include?('+ is tested') }
24
14
  test('is skipped') { @output.include?('_ is skipped (negative)') }
25
15
  test('status') { $?.exitstatus == 0 }
26
16
  end
27
17
 
28
18
  tests('positive') do
29
- before { @output = `#{BIN} #{positive.path} +positive` }
19
+ before do
20
+ @tempfile = tempfile('positive', <<-TESTS)
21
+ Shindo.tests do
22
+ test('is tested', 'positive') { true }
23
+ test('is skipped') { false }
24
+ end
25
+ TESTS
26
+ @output = bin("#{@tempfile.path} +positive")
27
+ end
30
28
  test('is tested') { @output.include?('+ is tested (positive)') }
31
29
  test('is skipped') { @output.include?('_ is skipped') }
32
30
  test('status') { $?.exitstatus == 0 }
@@ -1,16 +1,16 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'shindo'
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'shindo'))
2
+
4
3
  require 'tempfile'
5
4
 
6
- unless Object.const_defined?(:BIN)
7
- BIN = File.join(File.dirname(__FILE__), '..', 'bin', 'shindo')
5
+ BIN = File.join(File.dirname(__FILE__), '..', 'bin', 'shindo')
6
+
7
+ def bin(arguments)
8
+ `#{BIN} #{arguments}`
8
9
  end
9
- tags = Thread.current[:tags] || []
10
- ARGV.each do |arg|
11
- if arg.match(/^[\+\-]/)
12
- tags << arg
13
- ARGV.delete(arg)
14
- end
10
+
11
+ def tempfile(name, data)
12
+ tempfile = Tempfile.new(name)
13
+ tempfile << data
14
+ tempfile.close
15
+ tempfile
15
16
  end
16
- Thread.current[:tags] = tags
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 14
9
- version: 0.0.14
8
+ - 16
9
+ version: 0.0.16
10
10
  platform: ruby
11
11
  authors:
12
12
  - geemus (Wesley Beary)