dtest 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -10,12 +10,6 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
10
10
  spec.ruby_opts = ['-rubygems'] if defined? Gem
11
11
  end
12
12
 
13
- RSpec::Core::RakeTask.new(:rcov) do |spec|
14
- spec.pattern = 'spec/**/*_spec.rb'
15
- spec.ruby_opts = ['-rubygems'] if defined? Gem
16
- spec.rcov = true
17
- end
18
-
19
13
  task :default => :spec
20
14
 
21
15
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/bin/dtest CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
+ $LOAD_PATH << File.expand_path(File.join('..', 'lib'), File.dirname(__FILE__))
4
5
  require 'dtest/command'
@@ -0,0 +1,11 @@
1
+ # Example for dtest description
2
+ # ruby sample2.rb --color
3
+ require 'rubygems'
4
+ require 'dtest'
5
+
6
+ TestCase "hello" do
7
+ test "hello world" do
8
+ expect_equal(0,1)
9
+ end
10
+ end
11
+
@@ -0,0 +1,14 @@
1
+ require 'dtest/runner'
2
+ require 'dtest/dsl'
3
+
4
+ at_exit do
5
+ # parse and run
6
+ option = DTest::Runner.parse!(ARGV)
7
+ res = DTest::Runner.run
8
+ DTest::Runner.report(res)
9
+ # output xml
10
+ if option[:xml_path]
11
+ res.outputxml(option[:xml_path])
12
+ end
13
+ end
14
+
@@ -11,23 +11,15 @@ if ARGV.empty?
11
11
  usage
12
12
  else
13
13
  # Command line parser
14
- xml_path = nil
15
- opt = OptionParser.new
16
- opt.on('--color') do |b|
17
- DTest::Report.color_enabled = b
18
- end
19
- opt.on('--xml PATH') do |path|
20
- xml_path = path
21
- end
22
- opt.parse!(ARGV)
14
+ option = DTest::Runner.parse!(ARGV)
23
15
 
24
16
  # execute test
25
17
  res = DTest::Runner.run(ARGV)
26
18
  DTest::Runner.report(res)
27
19
 
28
20
  # output xml
29
- if xml_path
30
- res.outputxml(xml_path)
21
+ if option[:xml_path]
22
+ res.outputxml(option[:xml_path])
31
23
  end
32
24
  end
33
25
 
@@ -156,24 +156,30 @@ module DTest
156
156
 
157
157
  # abort
158
158
  def abort_if(condition, message = nil)
159
- str = "Abort"
160
- str += ": #{message}\n" if message
161
- failed(str)
162
- raise AbortTest.new(str) if condition
159
+ if condition
160
+ str = "Abort"
161
+ str += ": #{message}\n" if message
162
+ failed(str)
163
+ raise AbortTest.new(str)
164
+ end
163
165
  end
164
166
 
165
167
  def abort_case_if(condition, message = nil)
166
- str = "Abort TestCase"
167
- str += ": #{message}\n" if message
168
- failed(str)
169
- raise AbortTestCase.new(str) if condition
168
+ if condition
169
+ str = "Abort TestCase"
170
+ str += ": #{message}\n" if message
171
+ failed(str)
172
+ raise AbortTestCase.new(str)
173
+ end
170
174
  end
171
175
 
172
176
  def abort_global_if(condition, message = nil)
173
- str = "Abort global"
174
- str += ": #{message}\n" if message
175
- failed(str)
176
- raise AbortGlobal.new(str) if condition
177
+ if condition
178
+ str = "Abort global"
179
+ str += ": #{message}\n" if message
180
+ failed(str)
181
+ raise AbortGlobal.new(str)
182
+ end
177
183
  end
178
184
 
179
185
  private #internal methods
@@ -20,8 +20,5 @@ module DTest
20
20
  end
21
21
  end
22
22
 
23
- def self.failure_caller(level)
24
- failure_line(caller(level).first)
25
- end
26
23
  end # DTest
27
24
 
@@ -31,11 +31,8 @@ module DTest
31
31
 
32
32
  # symbol to string
33
33
  def self.tag_s(tag)
34
- if TAG_MAP.include?(tag)
35
- text = TAG_MAP[tag]
36
- else
37
- text = tag.to_s
38
- end
34
+ # must be in TAG_MAP.include?(tag)
35
+ TAG_MAP[tag]
39
36
  end
40
37
 
41
38
  def self.colored_tag(tag)
@@ -1,11 +1,28 @@
1
1
 
2
2
 
3
+ require 'optparse'
3
4
  require 'dtest/core'
4
5
  require 'dtest/progress'
5
6
 
6
7
  module DTest
7
8
  class Runner
8
- def self.run(files)
9
+ def self.parse!(argv)
10
+ # Command line parser
11
+ res = {}
12
+ xml_path = nil
13
+ opt = OptionParser.new
14
+ opt.on('--color') do |b|
15
+ DTest::Report.color_enabled = b
16
+ end
17
+ opt.on('--xml PATH') do |path|
18
+ res[:xml_path] = path
19
+ end
20
+ opt.parse!(ARGV)
21
+
22
+ res
23
+ end
24
+
25
+ def self.run(files = [])
9
26
  files.each do |file|
10
27
  load file
11
28
  end
@@ -1,5 +1,5 @@
1
1
  module DTest
2
2
 
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
 
5
5
  end
@@ -0,0 +1,7 @@
1
+ if ENV['COVERAGE']
2
+ require 'simplecov'
3
+ SimpleCov.start
4
+ end
5
+ $LOAD_PATH << File.expand_path(File.join('..', 'lib'), File.dirname(__FILE__))
6
+ require 'dtest/dsl'
7
+ require 'dtest/runner'
@@ -1,9 +1,5 @@
1
-
2
- require 'dtest/dsl'
3
- require 'dtest/runner'
1
+ require File.expand_path(File.join('.', 'spec_helper'), File.dirname(__FILE__))
4
2
  include DTest
5
-
6
-
7
3
  #
8
4
  # グローバル、テストケース、テスト before/after
9
5
  # abortは3種類ある
@@ -1,6 +1,4 @@
1
-
2
- require 'dtest/dsl'
3
- require 'dtest/runner'
1
+ require File.expand_path(File.join('.', 'spec_helper'), File.dirname(__FILE__))
4
2
  include DTest
5
3
 
6
4
  describe Global::Manager, 'test assert' do
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.join('.', 'spec_helper'), File.dirname(__FILE__))
2
+
3
+ ARGV = []
4
+
5
+ Dir::glob(File.dirname(__FILE__) + "/dtest/*.rb").each {|f|
6
+ ARGV << f
7
+ }
8
+
9
+ def exec_cmd
10
+ begin
11
+ load 'dtest/command.rb'
12
+ ensure
13
+ DTest::Global::Manager.instance.clear
14
+ DTest::Test::Manager.instance.clear
15
+ end
16
+ end
17
+
18
+ # execute dtest 1(without color, no output xml)
19
+ exec_cmd
20
+
21
+ # execute dtest 2(with color, output xml)
22
+ require 'tempfile'
23
+ temp = Tempfile.new('foo')
24
+ begin
25
+ temp.close
26
+ ARGV.insert(0, '--xml')
27
+ ARGV.insert(1, temp.path)
28
+ ARGV << '--color'
29
+ exec_cmd
30
+ ensure
31
+ temp.unlink
32
+ end
33
+
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.join('.', 'spec_helper'), File.dirname(__FILE__))
2
+
3
+ ARGV = []
4
+ begin
5
+ load 'dtest/command.rb'
6
+ ensure
7
+ DTest::Global::Manager.instance.clear
8
+ DTest::Test::Manager.instance.clear
9
+ end
10
+
11
+
@@ -1,7 +1,6 @@
1
- require 'dtest/dsl'
2
- require 'dtest/runner'
3
1
  include DTest
4
2
 
3
+
5
4
  describe Global::Manager, 'global before/after exception' do
6
5
  before do
7
6
  $call = []
@@ -1,5 +1,4 @@
1
- require 'dtest/dsl'
2
- require 'dtest/runner'
1
+ require File.expand_path(File.join('.', 'spec_helper'), File.dirname(__FILE__))
3
2
  include DTest
4
3
 
5
4
 
@@ -1,5 +1,4 @@
1
- require 'dtest/dsl'
2
- require 'dtest/runner'
1
+ require File.expand_path(File.join('.', 'spec_helper'), File.dirname(__FILE__))
3
2
  include DTest
4
3
 
5
4
  describe Global::Manager, 'dtest instance' do
@@ -1,5 +1,4 @@
1
- require 'dtest/dsl'
2
- require 'dtest/runner'
1
+ require File.expand_path(File.join('.', 'spec_helper'), File.dirname(__FILE__))
3
2
  include DTest
4
3
 
5
4
  describe Global::Manager, 'value_parameterized' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-01 00:00:00.000000000Z
12
+ date: 2011-11-09 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70264612395960 !ruby/object:Gem::Requirement
16
+ requirement: &70104550738940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.9.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70264612395960
24
+ version_requirements: *70104550738940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70264612395400 !ruby/object:Gem::Requirement
27
+ requirement: &70104550738480 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 1.2.3
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70264612395400
35
+ version_requirements: *70104550738480
36
36
  description: DTest is a testing tool to describe integrating test for distributed
37
37
  systems.
38
38
  email: suma@sourceforge.jp
@@ -49,6 +49,7 @@ files:
49
49
  - bin/dtest
50
50
  - dtest.gemspec
51
51
  - examples/sample.rb
52
+ - examples/sample2.rb
52
53
  - lib/dtest.rb
53
54
  - lib/dtest/command.rb
54
55
  - lib/dtest/core.rb
@@ -62,8 +63,11 @@ files:
62
63
  - lib/dtest/test.rb
63
64
  - lib/dtest/util.rb
64
65
  - lib/dtest/version.rb
66
+ - spec/spec_helper.rb
65
67
  - spec/test_abort_spec.rb
66
68
  - spec/test_assert_spec.rb
69
+ - spec/test_command1_spec.rb
70
+ - spec/test_command2_spec.rb
67
71
  - spec/test_exception_spec.rb
68
72
  - spec/test_expect_spec.rb
69
73
  - spec/test_spec.rb
@@ -88,13 +92,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
92
  version: '0'
89
93
  requirements: []
90
94
  rubyforge_project:
91
- rubygems_version: 1.8.11
95
+ rubygems_version: 1.8.10
92
96
  signing_key:
93
97
  specification_version: 3
94
98
  summary: DTest is a testing tool to describe integrating test for distributed systems.
95
99
  test_files:
100
+ - spec/spec_helper.rb
96
101
  - spec/test_abort_spec.rb
97
102
  - spec/test_assert_spec.rb
103
+ - spec/test_command1_spec.rb
104
+ - spec/test_command2_spec.rb
98
105
  - spec/test_exception_spec.rb
99
106
  - spec/test_expect_spec.rb
100
107
  - spec/test_spec.rb