updater 0.2.2 → 0.3.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.
data/spec/update_spec.rb CHANGED
@@ -3,183 +3,21 @@ require File.join( File.dirname(__FILE__), "spec_helper" )
3
3
  include Updater
4
4
 
5
5
  describe Update do
6
-
7
- class Foo
8
- include DataMapper::Resource
9
-
10
- property :id, Serial
11
- property :name, String
12
-
13
- def bar(*args)
14
- Foo.bar(:instance,*args)
15
- end
16
-
17
- end
18
-
19
- Foo.auto_migrate!
20
-
21
- before(:each) do
22
- Foo.all.destroy!
23
- end
24
-
25
- it "should include DataMapper::Resource" do
26
- DataMapper::Model.descendants.to_a.should include(Update)
27
- end
28
-
29
6
  it "should have a version matching the VERSION file" do
30
7
  Updater::VERSION.should == File.read(File.join(ROOT,'VERSION')).strip
31
- end
8
+ end
32
9
 
33
- describe "adding an immidiate update request" do
34
-
35
- it "with a class target" do
36
- u = Update.immidiate(Foo,:bar,[])
37
- u.target.should == Foo
38
- Update.current.should include(u)
39
- Update.delayed.should_not include(u)
40
- end
41
-
42
- it "with an conforming instance target" do
43
- f = Foo.create
44
- u = Update.immidiate(f,:bar,[])
45
- u.target.should == f
46
- Update.current.should include(u)
47
- Update.delayed.should_not include(u)
48
- end
49
-
50
- it "with an custome finder" do
51
- f = Foo.create(:name=>'baz')
52
- u = Update.immidiate(Foo,:bar,[],:finder=>:first, :finder_args=>{:name=>'baz'})
53
- u.target.should == f
54
- Update.current.should include(u)
55
- Update.delayed.should_not include(u)
56
- end
57
-
10
+ it "shuold have its own inspect method" do
11
+ Update.new(Update.orm.new).inspect.should =~ /Updater::Update/
58
12
  end
59
-
60
- describe "chained request" do
61
-
62
- it "should not be in current or delayed queue" do
63
- u = Update.chain(Foo,:bar,[:error])
64
- u.time.should be_nil
65
- Update.current.should_not include(u)
66
- Update.delayed.should_not include(u)
67
- end
68
-
69
- end
70
-
71
- describe "named request" do
72
-
73
- it "should be found by name when target is an instance" do
74
- f = Foo.create(:name=>'Honey')
75
- u = Update.immidiate(f,:bar,[:named],:name=>'Now')
76
- u.name.should ==("Now")
77
- Update.for(f, "Now").should ==(u)
78
- end
79
-
80
- it "should be found by name when target is a class" do
81
- u = Update.immidiate(Foo,:bar,[:named],:name=>'Now')
82
- u.name.should ==("Now")
83
- Update.for(Foo, "Now").should ==(u)
84
- end
85
-
86
- it "should return all updates for a given target" do
87
- u1 = Update.immidiate(Foo,:bar,[:arg1,:arg2])
88
- u2 = Update.immidiate(Foo,:bar,[:arg3,:arg4])
89
- Update.for(Foo).should include(u1,u2)
90
- end
91
13
 
92
-
93
- end
94
-
95
- describe "adding an delayed update request" do
96
-
97
- it "with a class target" do
98
- u = Update.at(Chronic.parse('tomorrow'),Foo,:bar,[])
99
- u.target.should == Foo
100
- Update.current.should_not include(u)
101
- Update.delayed.should include(u)
102
- end
103
-
104
- it "with an conforming instance target" do
105
- f = Foo.create
106
- u = Update.at(Chronic.parse('tomorrow'),f,:bar,[])
107
- u.target.should == f
108
- Update.current.should_not include(u)
109
- Update.delayed.should include(u)
110
- end
111
-
112
- it "with an custome finder" do
113
- f = Foo.create(:name=>'baz')
114
- u = Update.at(Chronic.parse('tomorrow'),Foo,:bar,[],:finder=>:first, :finder_args=>{:name=>'baz'})
115
- u.target.should == f
116
- Update.current.should_not include(u)
117
- Update.delayed.should include(u)
118
- end
119
-
120
- end
121
-
122
- describe "running an update" do
123
-
124
- before :each do
125
- Update.all.destroy!
126
- end
127
-
128
- it "should call the named method with a class target" do
129
- u = Update.immidiate(Foo,:bar,[:arg1,:arg2])
130
- Foo.should_receive(:bar).with(:arg1,:arg2)
131
- u.run
132
- end
133
-
134
- it "should call the named method with an conforming instance target" do
135
- f = Foo.create
136
- u = Update.immidiate(f,:bar,[:arg1,:arg2])
137
- Foo.should_receive(:bar).with(:instance,:arg1,:arg2)
138
- u.run
139
- end
140
-
141
- it "should delete the record once it is run" do
142
- u = Update.immidiate(Foo,:bar,[:arg1,:arg2])
143
- Foo.should_receive(:bar).with(:arg1,:arg2)
144
- u.run
145
- u.should_not be_saved #NOTE: not a theological statment
146
- end
147
-
148
- it "should delete the record if there is a failure" do
149
- u = Update.immidiate(Foo,:bar,[:arg1,:arg2])
150
- Foo.should_receive(:bar).with(:arg1,:arg2).and_raise(RuntimeError)
151
- u.run
152
- u.should_not be_saved #NOTE: not a theological statment
153
- end
154
-
155
- it "should not delete the record if it is a chain record" do
156
- u = Update.chain(Foo,:bar,[:arg1,:arg2])
157
- Foo.should_receive(:bar).with(:arg1,:arg2).and_raise(RuntimeError)
158
- u.run
159
- u.should be_saved
160
- end
161
-
162
- describe "Error Handeling" do
163
- it "should return false when run" do
164
- u = Update.immidiate(Foo,:bar,[:arg1,:arg2])
165
- Foo.should_receive(:bar).with(:arg1,:arg2).and_raise(RuntimeError)
166
- u.run.should be_false
167
- end
168
-
169
- it "should trap errors" do
170
- u = Update.immidiate(Foo,:bar,[:arg1,:arg2])
171
- Foo.should_receive(:bar).with(:arg1,:arg2).and_raise(RuntimeError)
172
- lambda {u.run}.should_not raise_error
173
- end
174
-
175
- it "should run the failure task" do
176
- err = Update.chain(Foo,:bar,[:error])
177
- u = Update.immidiate(Foo,:bar,[:arg1,:arg2],:failure=>err)
178
- Foo.should_receive(:bar).with(:arg1,:arg2).and_raise(RuntimeError)
179
- Foo.should_receive(:bar).with(:error)
180
- u.run
181
- end
14
+ end
15
+
16
+ context "Gemspec: " do
17
+ it"should match version" do
18
+ gs = File.open(File.join(ROOT,'updater.gemspec')) do |f|
19
+ eval f.read
182
20
  end
21
+ gs.version.to_s.should == File.read(File.join(ROOT,'VERSION')).strip
183
22
  end
184
-
185
- end
23
+ end
data/spec/util_spec.rb ADDED
@@ -0,0 +1,11 @@
1
+ require File.join( File.dirname(__FILE__), "spec_helper" )
2
+
3
+ include Updater
4
+
5
+ describe "Util.tempio" do
6
+
7
+ it "should return an unlinked file" do
8
+ Updater::Util.tempio.stat.nlink.should == 0
9
+ end
10
+
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: updater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John F. Miller
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-24 00:00:00 -07:00
12
+ date: 2010-02-09 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -68,13 +68,27 @@ files:
68
68
  - Rakefile
69
69
  - VERSION
70
70
  - lib/updater.rb
71
+ - lib/updater/util.rb
71
72
  - lib/updater/update.rb
73
+ - lib/updater/fork_worker.rb
74
+ - lib/updater/update_dm.rb
72
75
  - lib/updater/tasks.rb
73
- - lib/updater/worker.rb
74
- - spec/worker_spec.rb
76
+ - lib/updater/thread_worker.rb
77
+ - lib/updater/orm/datamapper.rb
78
+ - spec/fork_worker_instance_spec.rb
79
+ - spec/thread_worker_spec.rb
80
+ - spec/schedule_spec.rb
75
81
  - spec/lock_spec.rb
82
+ - spec/params_sub_spec.rb
83
+ - spec/chained_spec.rb
84
+ - spec/fooclass.rb
76
85
  - spec/update_spec.rb
77
86
  - spec/spec_helper.rb
87
+ - spec/named_request_spec.rb
88
+ - spec/update_runner_spec.rb
89
+ - spec/util_spec.rb
90
+ - spec/fork_worker_spec.rb
91
+ - spec/errors_spec.rb
78
92
  - bin/updater
79
93
  has_rdoc: true
80
94
  homepage: http://blog.antarestrader.com