Dear All:
I have done my test for 2 actions do simultaneously for the same
command. Here is my approvement.
Window DOS 1
F:\ruby\tiesto> ruby test/unit/item_test.rb
Loaded suite test/unit/item_test
Started
.
Finished in 42.078 seconds.
1 tests, 0 assertions, 0 failures, 0 errors
Windows DOS 2
F:\ruby\tiesto>ruby test/unit/item_test.rb
Loaded suite test/unit/item_test
Started
.
Finished in 42.125 seconds.
1 tests, 0 assertions, 0 failures, 0 errors
SCRIPT item_test.rb
require File.dirname( FILE) + ‘/…/test_helper’
class ItemTest < Test::Unit:: TestCase
def test_what
CD = item.find(:first)
Item.transaction do
CD.modification
end
end
end
SCRIPT in Item.rb (Active Record)
class Item < ActiveRecord: :Base
def modification
#delaying process
for z in 1…100000000
end
update_attributes( :stock => stock-1)
end
TABLE BEFORE TESTS RUN
ID | ITEM | QTY |
1 | HEAVEN | 10 |
After 2 Windows Run TEST TOGETHER.
TABLE AFTER EXECUTIONS
ID | ITEM | QTY |
1 | HEAVEN | 9 |
It is not what i expected, it should be 10 - 1 -1 = 8, NOT 9. In other
case i did put Item.transaction do there.
What is your suggestion about it ???
Thank you,
Reinhart
http://teapoci.blogspot.com