sequel 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,63 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+
3
+ context "A worker" do
4
+ setup do
5
+ @w = Sequel::Worker.new
6
+ end
7
+
8
+ teardown do
9
+ sleep 0.1
10
+ @w.join if @w
11
+ end
12
+
13
+ specify "should be a thread" do
14
+ @w.should be_a_kind_of(Thread)
15
+ end
16
+
17
+ specify "should be alive until it is joined" do
18
+ @w.should be_alive
19
+ end
20
+
21
+ specify "should be busy if any jobs are pending" do
22
+ @w.should_not be_busy
23
+ @w.add {sleep 0.5}
24
+ @w.should be_busy
25
+ end
26
+
27
+ specify "should accept jobs and perform them in the correct order" do
28
+ values = []
29
+ @w.add {values << 1}
30
+ @w.async {values << 2}
31
+ @w << proc {values << 3}
32
+
33
+ @w.join
34
+ values.should == [1, 2, 3]
35
+ @w = nil
36
+ end
37
+ end
38
+
39
+ context "A worker with a given db" do
40
+ setup do
41
+ @db = MockDatabase.new
42
+ @m = Module.new do
43
+ def transaction; execute('BEGIN'); yield; execute('COMMIT'); end
44
+ end
45
+ @db.extend(@m)
46
+ @w = Sequel::Worker.new(@db)
47
+ end
48
+
49
+ teardown do
50
+ @w.join if @w
51
+ end
52
+
53
+ specify "should wrap everything in a transaction" do
54
+ @w.async {@db[:items] << {:x => 1}}
55
+ @w.join
56
+ @w = nil
57
+ @db.sqls.should == [
58
+ 'BEGIN',
59
+ 'INSERT INTO items (x) VALUES (1)',
60
+ 'COMMIT'
61
+ ]
62
+ end
63
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: sequel
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.2
7
- date: 2007-11-01 00:00:00 +02:00
6
+ version: 0.3.3
7
+ date: 2007-11-04 00:00:00 +02:00
8
8
  summary: Lightweight ORM library for Ruby
9
9
  require_paths:
10
10
  - lib
@@ -36,6 +36,7 @@ files:
36
36
  - doc/rdoc
37
37
  - spec/adapters
38
38
  - spec/adapters/mysql_spec.rb
39
+ - spec/adapters/oracle_spec.rb
39
40
  - spec/adapters/postgres_spec.rb
40
41
  - spec/adapters/sqlite_spec.rb
41
42
  - spec/array_keys_spec.rb
@@ -50,6 +51,7 @@ files:
50
51
  - spec/schema_spec.rb
51
52
  - spec/sequelizer_spec.rb
52
53
  - spec/spec_helper.rb
54
+ - spec/worker_spec.rb
53
55
  - lib/sequel
54
56
  - lib/sequel/ado.rb
55
57
  - lib/sequel/array_keys.rb
@@ -83,6 +85,7 @@ files:
83
85
  - lib/sequel/schema/schema_sql.rb
84
86
  - lib/sequel/schema.rb
85
87
  - lib/sequel/sqlite.rb
88
+ - lib/sequel/worker.rb
86
89
  - lib/sequel.rb
87
90
  - CHANGELOG
88
91
  test_files: []