running_man 0.1 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/lib/running_man.rb +1 -1
- data/lib/running_man/active_record_block.rb +7 -1
- data/lib/running_man/block.rb +39 -4
- data/running_man.gemspec +3 -3
- data/test/running_man/block_helper_test.rb +15 -6
- metadata +12 -6
data/Rakefile
CHANGED
@@ -95,7 +95,7 @@ task :release => :build do
|
|
95
95
|
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
96
96
|
sh "git tag v#{version}"
|
97
97
|
sh "git push origin master"
|
98
|
-
sh "git push v#{version}"
|
98
|
+
sh "git push origin v#{version}"
|
99
99
|
sh "gem push pkg/#{name}-#{version}.gem"
|
100
100
|
end
|
101
101
|
|
data/lib/running_man.rb
CHANGED
@@ -8,14 +8,20 @@ module RunningMan
|
|
8
8
|
module TestClassMethods
|
9
9
|
def fixtures(&block)
|
10
10
|
test_block = RunningMan::ActiveRecordBlock.new(block)
|
11
|
+
active_record_fixtures_setup(test_block)
|
12
|
+
active_record_fixtures_teardown
|
13
|
+
end
|
14
|
+
|
15
|
+
def active_record_fixtures_setup(test_block)
|
11
16
|
setup do
|
12
17
|
test_block.run(self)
|
13
|
-
|
14
18
|
# Open a new transaction before running any test.
|
15
19
|
ActiveRecord::Base.connection.increment_open_transactions
|
16
20
|
ActiveRecord::Base.connection.begin_db_transaction
|
17
21
|
end
|
22
|
+
end
|
18
23
|
|
24
|
+
def active_record_fixtures_teardown
|
19
25
|
teardown do
|
20
26
|
# Rollback our transaction, returning our fixtures to a pristine
|
21
27
|
# state.
|
data/lib/running_man/block.rb
CHANGED
@@ -6,6 +6,10 @@ module RunningMan
|
|
6
6
|
test_block = RunningMan::Block.new(block)
|
7
7
|
setup { test_block.run(self) }
|
8
8
|
end
|
9
|
+
|
10
|
+
def teardown_once(&block)
|
11
|
+
final_teardowns << RunningMan::Block.new(block)
|
12
|
+
end
|
9
13
|
end
|
10
14
|
|
11
15
|
# block_arg - Optional Proc of code that runs only once for the test case.
|
@@ -43,10 +47,10 @@ module RunningMan
|
|
43
47
|
# Returns nothing.
|
44
48
|
def run_once(binding)
|
45
49
|
@ivars.clear
|
46
|
-
before = instance_variables
|
47
|
-
instance_eval(&@block)
|
48
|
-
(instance_variables - before).each do |ivar|
|
49
|
-
@ivars[ivar] = instance_variable_get(ivar)
|
50
|
+
before = binding.instance_variables
|
51
|
+
binding.instance_eval(&@block)
|
52
|
+
(binding.instance_variables - before).each do |ivar|
|
53
|
+
@ivars[ivar] = binding.instance_variable_get(ivar)
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
@@ -77,4 +81,35 @@ module RunningMan
|
|
77
81
|
!!@run
|
78
82
|
end
|
79
83
|
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# TODO: Add MiniTest support for ruby 1.9
|
87
|
+
if defined?(Test::Unit::TestSuite) && defined?(Test::Unit::TestCase)
|
88
|
+
module Test
|
89
|
+
module Unit
|
90
|
+
class TestCase
|
91
|
+
def self.final_teardowns
|
92
|
+
@final_teardowns ||= []
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
class Suite
|
97
|
+
def run(result, &progress_block) # :nodoc:
|
98
|
+
yield(STARTED, name)
|
99
|
+
klass_to_teardown = if @tests.first.is_a?(Test::Unit::TestCase)
|
100
|
+
@tests.first.class
|
101
|
+
end
|
102
|
+
@tests.each do |test|
|
103
|
+
test.run(result, &progress_block)
|
104
|
+
end
|
105
|
+
if klass_to_teardown
|
106
|
+
klass_to_teardown.final_teardowns.each do |teardown|
|
107
|
+
teardown.run(@tests.last)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
yield(FINISHED, name)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
80
115
|
end
|
data/running_man.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 = 'running_man'
|
16
|
-
s.version = '0.
|
17
|
-
s.date = '2010-05-
|
16
|
+
s.version = '0.2'
|
17
|
+
s.date = '2010-05-03'
|
18
18
|
s.rubyforge_project = 'running_man'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
## a custom homepage, consider using your GitHub URL or the like.
|
28
28
|
s.authors = ["rick"]
|
29
29
|
s.email = 'technoweenie@gmail.com'
|
30
|
-
s.homepage = 'http://
|
30
|
+
s.homepage = 'http://github.com/technoweenie/running_man'
|
31
31
|
|
32
32
|
## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
|
33
33
|
## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
|
@@ -2,24 +2,33 @@ require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
|
2
2
|
|
3
3
|
class BlockHelperTest < Test::Unit::TestCase
|
4
4
|
class << self
|
5
|
-
attr_accessor :block_calls
|
5
|
+
attr_accessor :block_calls, :test_calls
|
6
6
|
end
|
7
|
-
self.block_calls = 0
|
7
|
+
self.block_calls = self.test_calls = 0
|
8
|
+
|
9
|
+
original_string = 'abc'.freeze
|
8
10
|
|
9
11
|
setup_once do
|
10
|
-
|
11
|
-
|
12
|
+
assert_equal 'BlockHelperTest', self.class.name
|
13
|
+
@a = original_string
|
14
|
+
self.class.block_calls += 1
|
12
15
|
end
|
13
16
|
|
14
|
-
|
17
|
+
teardown_once do
|
18
|
+
assert_equal 'BlockHelperTest', self.class.name
|
19
|
+
assert_equal original_string, @a
|
20
|
+
assert_equal original_string.object_id, @a.object_id
|
15
21
|
assert_equal 1, self.class.block_calls
|
22
|
+
assert_equal 2, self.class.test_calls
|
16
23
|
end
|
17
24
|
|
18
25
|
def test_sets_ivar_from_block
|
19
|
-
|
26
|
+
self.class.test_calls += 1
|
27
|
+
assert_equal 'abc', @a
|
20
28
|
end
|
21
29
|
|
22
30
|
# checks that block_calls is not incremented again
|
23
31
|
def test_again
|
32
|
+
self.class.test_calls += 1
|
24
33
|
end
|
25
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: running_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
version: "0.2"
|
5
9
|
platform: ruby
|
6
10
|
authors:
|
7
11
|
- rick
|
@@ -9,7 +13,7 @@ autorequire:
|
|
9
13
|
bindir: bin
|
10
14
|
cert_chain: []
|
11
15
|
|
12
|
-
date: 2010-05-
|
16
|
+
date: 2010-05-03 00:00:00 -07:00
|
13
17
|
default_executable:
|
14
18
|
dependencies: []
|
15
19
|
|
@@ -34,7 +38,7 @@ files:
|
|
34
38
|
- test/running_man/block_test.rb
|
35
39
|
- test/test_helper.rb
|
36
40
|
has_rdoc: true
|
37
|
-
homepage: http://
|
41
|
+
homepage: http://github.com/technoweenie/running_man
|
38
42
|
licenses: []
|
39
43
|
|
40
44
|
post_install_message:
|
@@ -46,18 +50,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
50
|
requirements:
|
47
51
|
- - ">="
|
48
52
|
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
49
55
|
version: "0"
|
50
|
-
version:
|
51
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
57
|
requirements:
|
53
58
|
- - ">="
|
54
59
|
- !ruby/object:Gem::Version
|
60
|
+
segments:
|
61
|
+
- 0
|
55
62
|
version: "0"
|
56
|
-
version:
|
57
63
|
requirements: []
|
58
64
|
|
59
65
|
rubyforge_project: running_man
|
60
|
-
rubygems_version: 1.3.
|
66
|
+
rubygems_version: 1.3.6
|
61
67
|
signing_key:
|
62
68
|
specification_version: 2
|
63
69
|
summary: Simple class for test/unit setup blocks that run just once.
|