transaction-simple 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # Transaction::Simple
4
+ # Simple object transaction support for Ruby
5
+ # http://rubyforge.org/projects/trans-simple/
6
+ # Version 1.4.0
7
+ #
8
+ # Licensed under a MIT-style licence. See Licence.txt in the main
9
+ # distribution for full licensing information.
10
+ #
11
+ # Copyright (c) 2003 - 2007 Austin Ziegler
12
+ #
13
+ # $Id: test_transaction_simple_threadsafe.rb 48 2007-02-03 16:00:11Z austin $
14
+ #++
15
+ $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
16
+
17
+ require 'transaction/simple/threadsafe'
18
+ require 'test/unit'
19
+
20
+ module Transaction::Simple::Test
21
+ class ThreadSafe < Test::Unit::TestCase #:nodoc:
22
+ VALUE = "Now is the time for all good men to come to the aid of their country."
23
+
24
+ def setup
25
+ @value = VALUE.dup
26
+ @value.extend(Transaction::Simple::ThreadSafe)
27
+ end
28
+
29
+ def test_extended
30
+ assert_respond_to(@value, :start_transaction)
31
+ end
32
+
33
+ def test_started
34
+ assert_equal(false, @value.transaction_open?)
35
+ assert_nothing_raised { @value.start_transaction }
36
+ assert_equal(true, @value.transaction_open?)
37
+ end
38
+
39
+ def test_rewind
40
+ assert_equal(false, @value.transaction_open?)
41
+ assert_raises(Transaction::TransactionError) { @value.rewind_transaction }
42
+ assert_nothing_raised { @value.start_transaction }
43
+ assert_equal(true, @value.transaction_open?)
44
+ assert_nothing_raised { @value.gsub!(/men/, 'women') }
45
+ assert_not_equal(VALUE, @value)
46
+ assert_nothing_raised { @value.rewind_transaction }
47
+ assert_equal(true, @value.transaction_open?)
48
+ assert_equal(VALUE, @value)
49
+ end
50
+
51
+ def test_abort
52
+ assert_equal(false, @value.transaction_open?)
53
+ assert_raises(Transaction::TransactionError) { @value.abort_transaction }
54
+ assert_nothing_raised { @value.start_transaction }
55
+ assert_equal(true, @value.transaction_open?)
56
+ assert_nothing_raised { @value.gsub!(/men/, 'women') }
57
+ assert_not_equal(VALUE, @value)
58
+ assert_nothing_raised { @value.abort_transaction }
59
+ assert_equal(false, @value.transaction_open?)
60
+ assert_equal(VALUE, @value)
61
+ end
62
+
63
+ def test_commit
64
+ assert_equal(false, @value.transaction_open?)
65
+ assert_raises(Transaction::TransactionError) { @value.commit_transaction }
66
+ assert_nothing_raised { @value.start_transaction }
67
+ assert_equal(true, @value.transaction_open?)
68
+ assert_nothing_raised { @value.gsub!(/men/, 'women') }
69
+ assert_not_equal(VALUE, @value)
70
+ assert_equal(true, @value.transaction_open?)
71
+ assert_nothing_raised { @value.commit_transaction }
72
+ assert_equal(false, @value.transaction_open?)
73
+ assert_not_equal(VALUE, @value)
74
+ end
75
+
76
+ def test_multilevel
77
+ assert_equal(false, @value.transaction_open?)
78
+ assert_nothing_raised { @value.start_transaction }
79
+ assert_equal(true, @value.transaction_open?)
80
+ assert_nothing_raised { @value.gsub!(/men/, 'women') }
81
+ assert_equal(VALUE.gsub(/men/, 'women'), @value)
82
+ assert_equal(true, @value.transaction_open?)
83
+ assert_nothing_raised { @value.start_transaction }
84
+ assert_nothing_raised { @value.gsub!(/country/, 'nation-state') }
85
+ assert_nothing_raised { @value.commit_transaction }
86
+ assert_equal(VALUE.gsub(/men/, 'women').gsub(/country/, 'nation-state'), @value)
87
+ assert_equal(true, @value.transaction_open?)
88
+ assert_nothing_raised { @value.abort_transaction }
89
+ assert_equal(VALUE, @value)
90
+ end
91
+
92
+ def test_multilevel_named
93
+ assert_equal(false, @value.transaction_open?)
94
+ assert_raises(Transaction::TransactionError) { @value.transaction_name }
95
+ assert_nothing_raised { @value.start_transaction(:first) } # 1
96
+ assert_raises(Transaction::TransactionError) { @value.start_transaction(:first) }
97
+ assert_equal(true, @value.transaction_open?)
98
+ assert_equal(true, @value.transaction_open?(:first))
99
+ assert_equal(:first, @value.transaction_name)
100
+ assert_nothing_raised { @value.start_transaction } # 2
101
+ assert_not_equal(:first, @value.transaction_name)
102
+ assert_equal(nil, @value.transaction_name)
103
+ assert_raises(Transaction::TransactionError) { @value.abort_transaction(:second) }
104
+ assert_nothing_raised { @value.abort_transaction(:first) }
105
+ assert_equal(false, @value.transaction_open?)
106
+ assert_nothing_raised do
107
+ @value.start_transaction(:first)
108
+ @value.gsub!(/men/, 'women')
109
+ @value.start_transaction(:second)
110
+ @value.gsub!(/women/, 'people')
111
+ @value.start_transaction
112
+ @value.gsub!(/people/, 'sentients')
113
+ end
114
+ assert_nothing_raised { @value.abort_transaction(:second) }
115
+ assert_equal(true, @value.transaction_open?(:first))
116
+ assert_equal(VALUE.gsub(/men/, 'women'), @value)
117
+ assert_nothing_raised do
118
+ @value.start_transaction(:second)
119
+ @value.gsub!(/women/, 'people')
120
+ @value.start_transaction
121
+ @value.gsub!(/people/, 'sentients')
122
+ end
123
+ assert_raises(Transaction::TransactionError) { @value.rewind_transaction(:foo) }
124
+ assert_nothing_raised { @value.rewind_transaction(:second) }
125
+ assert_equal(VALUE.gsub(/men/, 'women'), @value)
126
+ assert_nothing_raised do
127
+ @value.gsub!(/women/, 'people')
128
+ @value.start_transaction
129
+ @value.gsub!(/people/, 'sentients')
130
+ end
131
+ assert_raises(Transaction::TransactionError) { @value.commit_transaction(:foo) }
132
+ assert_nothing_raised { @value.commit_transaction(:first) }
133
+ assert_equal(VALUE.gsub(/men/, 'sentients'), @value)
134
+ assert_equal(false, @value.transaction_open?)
135
+ end
136
+
137
+ def test_array
138
+ assert_nothing_raised do
139
+ @orig = ["first", "second", "third"]
140
+ @value = ["first", "second", "third"]
141
+ @value.extend(Transaction::Simple::ThreadSafe)
142
+ end
143
+ assert_equal(@orig, @value)
144
+ assert_nothing_raised { @value.start_transaction }
145
+ assert_equal(true, @value.transaction_open?)
146
+ assert_nothing_raised { @value[1].gsub!(/second/, "fourth") }
147
+ assert_not_equal(@orig, @value)
148
+ assert_nothing_raised { @value.abort_transaction }
149
+ assert_equal(@orig, @value)
150
+ end
151
+ end
152
+ end
metadata CHANGED
@@ -1,66 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.10
2
+ rubygems_version: 0.9.1
3
3
  specification_version: 1
4
4
  name: transaction-simple
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.3.0
7
- date: 2005-05-05
6
+ version: 1.4.0
7
+ date: 2007-02-03 00:00:00 -05:00
8
8
  summary: Simple object transaction support for Ruby.
9
9
  require_paths:
10
- - lib
11
- email: transaction-simple@halostatue.ca
10
+ - lib
11
+ email: austin@rubyforge.org
12
12
  homepage: http://rubyforge.org/projects/trans-simple
13
13
  rubyforge_project: trans-simple
14
- description: "Transaction::Simple provides a generic way to add active transaction support to
15
- objects. The transaction methods added by this module will work with most
16
- objects, excluding those that cannot be Marshal-ed (bindings, procedure objects,
17
- IO instances, or singleton objects)."
18
- autorequire: transaction/simple
14
+ description: Transaction::Simple provides a generic way to add active transaction support to objects. The transaction methods added by this module will work with most objects, excluding those that cannot be Marshal-ed (bindings, procedure objects, IO instances, or singleton objects).
15
+ autorequire:
19
16
  default_executable:
20
17
  bindir: bin
21
18
  has_rdoc: true
22
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
23
20
  requirements:
24
- -
25
- - ">="
26
- - !ruby/object:Gem::Version
27
- version: 1.8.1
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.8.2
28
24
  version:
29
25
  platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
30
29
  authors:
31
- - Austin Ziegler
30
+ - Austin Ziegler
32
31
  files:
33
- - Changelog
34
- - Install
35
- - lib
36
- - Rakefile
37
- - Readme
38
- - tests
39
- - lib/transaction
40
- - lib/transaction/simple
41
- - lib/transaction/simple.rb
42
- - lib/transaction/simple/group.rb
43
- - lib/transaction/simple/threadsafe
44
- - lib/transaction/simple/threadsafe.rb
45
- - lib/transaction/simple/threadsafe/group.rb
46
- - tests/tc_transaction_simple.rb
47
- - tests/tc_transaction_simple_group.rb
48
- - tests/tc_transaction_simple_threadsafe.rb
49
- - tests/testall.rb
32
+ - History.txt
33
+ - Install.txt
34
+ - Licence.txt
35
+ - Manifest.txt
36
+ - Rakefile
37
+ - Readme.txt
38
+ - lib/transaction/simple.rb
39
+ - lib/transaction/simple/group.rb
40
+ - lib/transaction/simple/threadsafe.rb
41
+ - lib/transaction/simple/threadsafe/group.rb
42
+ - setup.rb
43
+ - test/test_all.rb
44
+ - test/test_broken_graph.rb
45
+ - test/test_transaction_simple.rb
46
+ - test/test_transaction_simple_group.rb
47
+ - test/test_transaction_simple_threadsafe.rb
50
48
  test_files:
51
- - tests/tc_transaction_simple.rb
52
- - tests/tc_transaction_simple_group.rb
53
- - tests/tc_transaction_simple_threadsafe.rb
54
- rdoc_options:
55
- - "--title"
56
- - "Transaction::Simple -- Active Object Transaction Support for Ruby"
57
- - "--main"
58
- - Transaction::Simple
59
- - "--line-numbers"
49
+ - test/test_all.rb
50
+ rdoc_options: []
51
+
60
52
  extra_rdoc_files:
61
- - Readme
62
- - Changelog
53
+ - History.txt
54
+ - Install.txt
55
+ - Licence.txt
56
+ - Readme.txt
63
57
  executables: []
58
+
64
59
  extensions: []
60
+
65
61
  requirements: []
66
- dependencies: []
62
+
63
+ dependencies:
64
+ - !ruby/object:Gem::Dependency
65
+ name: hoe
66
+ version_requirement:
67
+ version_requirements: !ruby/object:Gem::Version::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 1.1.7
72
+ version:
data/Changelog DELETED
@@ -1,31 +0,0 @@
1
- $Id: Changelog,v 1.5 2005/05/05 16:16:49 austin Exp $
2
-
3
- == Transaction::simple 1.3.0
4
- * Updated to fix a lot of warnings.
5
- * Added a per-transaction-object list of excluded instance variables.
6
- * Moved Transaction::simple::ThreadSafe to transaction/simple/threadsafe.
7
- * Added transaction groups. Transaction groups are wrapper objects to allow
8
- the coordination of transactions with a group of objects. There are both
9
- normal and threadsafe versions of transaction groups.
10
- * Fixed a long-standing problem where instance variables that were added to an
11
- object after a transaction was started would remain.
12
- * Reorganised unit tests.
13
-
14
- == Transaction::Simple 1.2.0
15
- * Added a RubyGem.
16
- * Added a block form of Transaction::Simple.
17
-
18
- == Transaction::Simple 1.1.1
19
- * Cleaned up some documentation.
20
-
21
- == Transaction::Simple 1.1
22
- * Added Transaction::Simple::ThreadSafe for truly atomic and thread-safe
23
- transactions.
24
- * Fixed the description of Transaction::Simple to note that it is *not* atomic
25
- because it is not implicitly thread-safe.
26
- * Added support for named transactions. Named transactions can be used to make
27
- checkpoints that can be committed, aborted, or rewound without explicitly
28
- committing, aborting, or rewinding the intervening transactions.
29
-
30
- == Transaction::Simple 1.0
31
- * Created. Initial release.
data/Install DELETED
@@ -1,6 +0,0 @@
1
- Installing this package is as simple as:
2
-
3
- % ruby install.rb
4
-
5
- Alternatively, you can juse the RubyGem version of Transaction::Simple
6
- available as transaction-simple-1.3.0.gem from the usual sources.
@@ -1,277 +0,0 @@
1
- $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
2
-
3
- require 'transaction/simple'
4
- require 'test/unit'
5
-
6
- class Test__Transaction_Simple < Test::Unit::TestCase #:nodoc:
7
- VALUE = "Now is the time for all good men to come to the aid of their country."
8
-
9
- def setup
10
- @value = VALUE.dup
11
- @value.extend(Transaction::Simple)
12
- end
13
-
14
- def test_extended
15
- assert_respond_to(@value, :start_transaction)
16
- end
17
-
18
- def test_started
19
- assert_equal(false, @value.transaction_open?)
20
- assert_nothing_raised { @value.start_transaction }
21
- assert_equal(true, @value.transaction_open?)
22
- end
23
-
24
- def test_rewind
25
- assert_equal(false, @value.transaction_open?)
26
- assert_raises(Transaction::TransactionError) { @value.rewind_transaction }
27
- assert_nothing_raised { @value.start_transaction }
28
- assert_equal(true, @value.transaction_open?)
29
- assert_nothing_raised { @value.gsub!(/men/, 'women') }
30
- assert_not_equal(VALUE, @value)
31
- assert_nothing_raised { @value.rewind_transaction }
32
- assert_equal(true, @value.transaction_open?)
33
- assert_equal(VALUE, @value)
34
- end
35
-
36
- def test_abort
37
- assert_equal(false, @value.transaction_open?)
38
- assert_raises(Transaction::TransactionError) { @value.abort_transaction }
39
- assert_nothing_raised { @value.start_transaction }
40
- assert_equal(true, @value.transaction_open?)
41
- assert_nothing_raised { @value.gsub!(/men/, 'women') }
42
- assert_not_equal(VALUE, @value)
43
- assert_nothing_raised { @value.abort_transaction }
44
- assert_equal(false, @value.transaction_open?)
45
- assert_equal(VALUE, @value)
46
- end
47
-
48
- def test_commit
49
- assert_equal(false, @value.transaction_open?)
50
- assert_raises(Transaction::TransactionError) { @value.commit_transaction }
51
- assert_nothing_raised { @value.start_transaction }
52
- assert_equal(true, @value.transaction_open?)
53
- assert_nothing_raised { @value.gsub!(/men/, 'women') }
54
- assert_not_equal(VALUE, @value)
55
- assert_equal(true, @value.transaction_open?)
56
- assert_nothing_raised { @value.commit_transaction }
57
- assert_equal(false, @value.transaction_open?)
58
- assert_not_equal(VALUE, @value)
59
- end
60
-
61
- def test_multilevel
62
- assert_equal(false, @value.transaction_open?)
63
- assert_nothing_raised { @value.start_transaction }
64
- assert_equal(true, @value.transaction_open?)
65
- assert_nothing_raised { @value.gsub!(/men/, 'women') }
66
- assert_equal(VALUE.gsub(/men/, 'women'), @value)
67
- assert_equal(true, @value.transaction_open?)
68
- assert_nothing_raised { @value.start_transaction }
69
- assert_nothing_raised { @value.gsub!(/country/, 'nation-state') }
70
- assert_nothing_raised { @value.commit_transaction }
71
- assert_equal(VALUE.gsub(/men/, 'women').gsub(/country/, 'nation-state'), @value)
72
- assert_equal(true, @value.transaction_open?)
73
- assert_nothing_raised { @value.abort_transaction }
74
- assert_equal(VALUE, @value)
75
- end
76
-
77
- def test_multilevel_named
78
- assert_equal(false, @value.transaction_open?)
79
- assert_raises(Transaction::TransactionError) { @value.transaction_name }
80
- assert_nothing_raised { @value.start_transaction(:first) } # 1
81
- assert_raises(Transaction::TransactionError) { @value.start_transaction(:first) }
82
- assert_equal(true, @value.transaction_open?)
83
- assert_equal(true, @value.transaction_open?(:first))
84
- assert_equal(:first, @value.transaction_name)
85
- assert_nothing_raised { @value.start_transaction } # 2
86
- assert_not_equal(:first, @value.transaction_name)
87
- assert_equal(nil, @value.transaction_name)
88
- assert_raises(Transaction::TransactionError) { @value.abort_transaction(:second) }
89
- assert_nothing_raised { @value.abort_transaction(:first) }
90
- assert_equal(false, @value.transaction_open?)
91
- assert_nothing_raised do
92
- @value.start_transaction(:first)
93
- @value.gsub!(/men/, 'women')
94
- @value.start_transaction(:second)
95
- @value.gsub!(/women/, 'people')
96
- @value.start_transaction
97
- @value.gsub!(/people/, 'sentients')
98
- end
99
- assert_nothing_raised { @value.abort_transaction(:second) }
100
- assert_equal(true, @value.transaction_open?(:first))
101
- assert_equal(VALUE.gsub(/men/, 'women'), @value)
102
- assert_nothing_raised do
103
- @value.start_transaction(:second)
104
- @value.gsub!(/women/, 'people')
105
- @value.start_transaction
106
- @value.gsub!(/people/, 'sentients')
107
- end
108
- assert_raises(Transaction::TransactionError) { @value.rewind_transaction(:foo) }
109
- assert_nothing_raised { @value.rewind_transaction(:second) }
110
- assert_equal(VALUE.gsub(/men/, 'women'), @value)
111
- assert_nothing_raised do
112
- @value.gsub!(/women/, 'people')
113
- @value.start_transaction
114
- @value.gsub!(/people/, 'sentients')
115
- end
116
- assert_raises(Transaction::TransactionError) { @value.commit_transaction(:foo) }
117
- assert_nothing_raised { @value.commit_transaction(:first) }
118
- assert_equal(VALUE.gsub(/men/, 'sentients'), @value)
119
- assert_equal(false, @value.transaction_open?)
120
- end
121
-
122
- def test_block
123
- Transaction::Simple.start(@value) do |tv|
124
- assert_equal(true, tv.transaction_open?)
125
- assert_nothing_raised { tv.gsub!(/men/, 'women') }
126
- assert_equal(VALUE.gsub(/men/, 'women'), tv)
127
- tv.abort_transaction
128
- flunk("Failed to abort the transaction.")
129
- end
130
- assert_equal(false, @value.transaction_open?)
131
- assert_equal(VALUE, @value)
132
-
133
- @value = VALUE.dup
134
- Transaction::Simple.start(@value) do |tv|
135
- assert_equal(true, tv.transaction_open?)
136
- assert_nothing_raised { tv.gsub!(/men/, 'women') }
137
- assert_equal(VALUE.gsub(/men/, 'women'), tv)
138
- tv.commit_transaction
139
- flunk("Failed to commit the transaction.")
140
- end
141
- assert_equal(false, @value.transaction_open?)
142
- assert_equal(VALUE.gsub(/men/, 'women'), @value)
143
- end
144
-
145
- def test_named_block
146
- Transaction::Simple.start_named(:first, @value) do |tv|
147
- assert_equal(true, tv.transaction_open?)
148
- assert_equal(true, tv.transaction_open?(:first))
149
- assert_nothing_raised { tv.gsub!(/men/, 'women') }
150
- assert_equal(VALUE.gsub(/men/, 'women'), tv)
151
- tv.abort_transaction
152
- flunk("Failed to abort the transaction.")
153
- end
154
- assert_equal(false, @value.transaction_open?)
155
- assert_equal(false, @value.transaction_open?(:first))
156
- assert_equal(VALUE, @value)
157
-
158
- @value = VALUE.dup
159
- Transaction::Simple.start_named(:first, @value) do |tv|
160
- assert_equal(true, tv.transaction_open?)
161
- assert_equal(true, tv.transaction_open?(:first))
162
- assert_nothing_raised { tv.gsub!(/men/, 'women') }
163
- assert_equal(VALUE.gsub(/men/, 'women'), tv)
164
- tv.commit_transaction
165
- flunk("Failed to commit the transaction.")
166
- end
167
- assert_equal(false, @value.transaction_open?)
168
- assert_equal(false, @value.transaction_open?(:first))
169
- assert_equal(VALUE.gsub(/men/, 'women'), @value)
170
- end
171
-
172
- def test_named_block_error
173
- @value.start_transaction(:first)
174
- Transaction::Simple.start_named(:second, @value) do |tv|
175
- assert_equal(true, tv.transaction_open?)
176
- assert_equal(true, tv.transaction_open?(:first))
177
- assert_equal(true, tv.transaction_open?(:second))
178
- assert_nothing_raised { tv.gsub!(/men/, 'women') }
179
- assert_equal(VALUE.gsub(/men/, 'women'), tv)
180
- assert_raises(Transaction::TransactionError) do
181
- tv.abort_transaction(:first)
182
- end
183
- end
184
- assert_equal(true, @value.transaction_open?)
185
- assert_equal(true, @value.transaction_open?(:first))
186
- assert_equal(false, @value.transaction_open?(:second))
187
- assert_equal(VALUE.gsub(/men/, 'women'), @value)
188
- assert_nothing_raised { @value.abort_transaction(:first) }
189
- assert_equal(VALUE, @value)
190
-
191
- @value.start_transaction(:first)
192
- Transaction::Simple.start_named(:second, @value) do |tv|
193
- assert_equal(true, tv.transaction_open?)
194
- assert_equal(true, tv.transaction_open?(:first))
195
- assert_equal(true, tv.transaction_open?(:second))
196
- assert_nothing_raised { tv.gsub!(/men/, 'women') }
197
- assert_equal(VALUE.gsub(/men/, 'women'), tv)
198
- assert_raises(Transaction::TransactionError) do
199
- tv.commit_transaction(:first)
200
- end
201
- end
202
- assert_equal(true, @value.transaction_open?)
203
- assert_equal(true, @value.transaction_open?(:first))
204
- assert_equal(false, @value.transaction_open?(:second))
205
- assert_equal(VALUE.gsub(/men/, 'women'), @value)
206
- assert_nothing_raised { @value.abort_transaction(:first) }
207
- assert_equal(VALUE, @value)
208
- end
209
-
210
- def test_multivar_block
211
- a = VALUE.dup
212
- b = a.dup
213
-
214
- Transaction::Simple.start(a, b) do |ta, tb|
215
- assert_equal(true, ta.transaction_open?)
216
- assert_equal(true, tb.transaction_open?)
217
- ta.abort_transaction
218
- flunk("Failed to abort the transaction.")
219
- end
220
- assert_equal(false, a.transaction_open?)
221
- assert_equal(false, b.transaction_open?)
222
-
223
- Transaction::Simple.start(a, b) do |ta, tb|
224
- assert_equal(true, ta.transaction_open?)
225
- assert_equal(true, tb.transaction_open?)
226
- ta.commit_transaction
227
- flunk("Failed to commit the transaction.")
228
- end
229
- assert_equal(false, a.transaction_open?)
230
- assert_equal(false, b.transaction_open?)
231
- end
232
-
233
- def test_multilevel_block
234
- Transaction::Simple.start_named(:outer, @value) do |tv0|
235
- assert_equal(1, tv0.instance_variable_get(:@__transaction_level__))
236
- assert_equal(true, tv0.transaction_open?(:outer))
237
- Transaction::Simple.start_named(:inner, tv0) do |tv1|
238
- assert_equal(2, tv0.instance_variable_get(:@__transaction_level__))
239
- assert_equal(true, tv1.transaction_open?(:inner))
240
- tv1.abort_transaction
241
- flunk("Failed to abort the transaction.")
242
- end
243
- assert_equal(false, tv0.transaction_open?(:inner))
244
- assert_equal(true, tv0.transaction_open?(:outer))
245
-
246
- tv0.commit_transaction
247
- flunk("Failed to commit the transaction.")
248
- end
249
- assert_equal(false, @value.transaction_open?(:inner))
250
- assert_equal(false, @value.transaction_open?(:outer))
251
- end
252
-
253
- def test_array
254
- assert_nothing_raised do
255
- @orig = ["first", "second", "third"]
256
- @value = ["first", "second", "third"]
257
- @value.extend(Transaction::Simple)
258
- end
259
- assert_equal(@orig, @value)
260
- assert_nothing_raised { @value.start_transaction }
261
- assert_equal(true, @value.transaction_open?)
262
- assert_nothing_raised { @value[1].gsub!(/second/, "fourth") }
263
- assert_not_equal(@orig, @value)
264
- assert_nothing_raised { @value.abort_transaction }
265
- assert_equal(@orig, @value)
266
- end
267
-
268
- def test_instance_var
269
- @value = VALUE.dup
270
- @value.extend(Transaction::Simple)
271
- @value.start_transaction
272
- assert_equal(true, @value.transaction_open?)
273
- @value.instance_variable_set("@foo", "bar")
274
- @value.rewind_transaction
275
- assert_nil(@value.instance_variable_get("@foo"))
276
- end
277
- end