running_man 0.3.12 → 0.4.0

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.
@@ -1,7 +1,7 @@
1
1
  $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
2
2
 
3
3
  module RunningMan
4
- VERSION = '0.3.12'
4
+ VERSION = '0.4.0'
5
5
 
6
6
  # Public: Sets up any helper class methods in TestClassMethods on the
7
7
  # specified test case class.
@@ -5,6 +5,33 @@ module RunningMan
5
5
  #
6
6
  # See README for instructions on use.
7
7
  class ActiveRecordBlock < Block
8
+ module TestHelper
9
+ # Open a new transaction before running any test.
10
+ def setup_transaction
11
+ ActiveRecord::Base.connection.increment_open_transactions
12
+ if ActiveRecord::Base.connection.respond_to?(:transaction_joinable=)
13
+ ActiveRecord::Base.connection.transaction_joinable = false
14
+ end
15
+ ActiveRecord::Base.connection.begin_db_transaction
16
+ end
17
+
18
+ # Rollback our transaction, returning our fixtures to a pristine state.
19
+ def teardown_transaction
20
+ if ActiveRecord::Base.connection.open_transactions != 0
21
+ ActiveRecord::Base.connection.rollback_db_transaction
22
+ ActiveRecord::Base.connection.decrement_open_transactions
23
+ end
24
+ ActiveRecord::Base.clear_active_connections!
25
+ end
26
+
27
+ def clear_database
28
+ conn = ActiveRecord::Base.connection
29
+ conn.tables.each do |table|
30
+ conn.delete "DELETE FROM #{table}"
31
+ end
32
+ end
33
+ end
34
+
8
35
  module TestClassMethods
9
36
  # Runs this block once, which should insert records through ActiveRecord.
10
37
  # Test Cases should only have one #fixtures call, and it should be at the
@@ -14,6 +41,8 @@ module RunningMan
14
41
  end
15
42
  end
16
43
 
44
+ include TestHelper
45
+
17
46
  # Ensure the block is setup to run first, and that the test run is wrapped
18
47
  # in a database transaction.
19
48
  def setup(test_class)
@@ -34,24 +63,6 @@ module RunningMan
34
63
  setup_transaction
35
64
  end
36
65
 
37
- # Open a new transaction before running any test.
38
- def setup_transaction
39
- ActiveRecord::Base.connection.increment_open_transactions
40
- if ActiveRecord::Base.connection.respond_to?(:transaction_joinable=)
41
- ActiveRecord::Base.connection.transaction_joinable = false
42
- end
43
- ActiveRecord::Base.connection.begin_db_transaction
44
- end
45
-
46
- # Rollback our transaction, returning our fixtures to a pristine state.
47
- def teardown_transaction
48
- if ActiveRecord::Base.connection.open_transactions != 0
49
- ActiveRecord::Base.connection.rollback_db_transaction
50
- ActiveRecord::Base.connection.decrement_open_transactions
51
- end
52
- ActiveRecord::Base.clear_active_connections!
53
- end
54
-
55
66
  # reload any AR instances
56
67
  def set_ivar(binding, ivar, value)
57
68
  if value.class.respond_to?(:find)
@@ -59,12 +70,5 @@ module RunningMan
59
70
  end
60
71
  super(binding, ivar, value)
61
72
  end
62
-
63
- def clear_database
64
- conn = ActiveRecord::Base.connection
65
- conn.tables.each do |table|
66
- conn.delete "DELETE FROM #{table}"
67
- end
68
- end
69
73
  end
70
74
  end
@@ -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.3.12'
17
- s.date = '2012-08-14'
16
+ s.version = '0.4.0'
17
+ s.date = '2013-03-06'
18
18
  s.rubyforge_project = 'running_man'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
metadata CHANGED
@@ -1,32 +1,22 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: running_man
3
- version: !ruby/object:Gem::Version
4
- hash: 11
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 12
10
- version: 0.3.12
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - rick
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-08-14 00:00:00 Z
12
+ date: 2013-03-06 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description: Simple class for test/unit setup blocks that run just once.
22
15
  email: technoweenie@gmail.com
23
16
  executables: []
24
-
25
17
  extensions: []
26
-
27
18
  extra_rdoc_files: []
28
-
29
- files:
19
+ files:
30
20
  - LICENSE
31
21
  - README.md
32
22
  - Rakefile
@@ -40,38 +30,29 @@ files:
40
30
  - test/test_helper.rb
41
31
  homepage: http://github.com/technoweenie/running_man
42
32
  licenses: []
43
-
44
33
  post_install_message:
45
34
  rdoc_options: []
46
-
47
- require_paths:
35
+ require_paths:
48
36
  - lib
49
- required_ruby_version: !ruby/object:Gem::Requirement
37
+ required_ruby_version: !ruby/object:Gem::Requirement
50
38
  none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- hash: 3
55
- segments:
56
- - 0
57
- version: "0"
58
- required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
44
  none: false
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- hash: 3
64
- segments:
65
- - 0
66
- version: "0"
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
67
49
  requirements: []
68
-
69
50
  rubyforge_project: running_man
70
- rubygems_version: 1.8.24
51
+ rubygems_version: 1.8.23
71
52
  signing_key:
72
53
  specification_version: 2
73
54
  summary: Simple class for test/unit setup blocks that run just once.
74
- test_files:
55
+ test_files:
75
56
  - test/running_man/active_record_block_test.rb
76
57
  - test/running_man/block_helper_test.rb
77
58
  - test/running_man/block_test.rb