resque-status 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,107 @@
1
+ require 'test_helper'
2
+
3
+ class TestResqueStatus < Test::Unit::TestCase
4
+
5
+ context "Resque::Status" do
6
+ setup do
7
+ Resque.redis.flush_all
8
+ Resque::Status.expire_in = nil
9
+ @uuid = Resque::Status.create
10
+ Resque::Status.set(@uuid, "my status")
11
+ @uuid_with_json = Resque::Status.create({"im" => "json"})
12
+ end
13
+
14
+ context ".get" do
15
+ should "return the status as a Resque::Status for the uuid" do
16
+ status = Resque::Status.get(@uuid)
17
+ assert status.is_a?(Resque::Status)
18
+ assert_equal 'my status', status.message
19
+ end
20
+
21
+ should "return false if the status is not set" do
22
+ assert !Resque::Status.get('whu')
23
+ end
24
+
25
+ should "decode encoded json" do
26
+ assert_equal("json", Resque::Status.get(@uuid_with_json)['im'])
27
+ end
28
+ end
29
+
30
+ context ".set" do
31
+
32
+ should "set the status for the uuid" do
33
+ assert Resque::Status.set(@uuid, "updated")
34
+ assert_equal "updated", Resque::Status.get(@uuid).message
35
+ end
36
+
37
+ should "return the status" do
38
+ assert Resque::Status.set(@uuid, "updated").is_a?(Resque::Status)
39
+ end
40
+
41
+ end
42
+
43
+ context ".create" do
44
+ should "add an item to a key set" do
45
+ before = Resque::Status.status_ids.length
46
+ Resque::Status.create
47
+ after = Resque::Status.status_ids.length
48
+ assert_equal 1, after - before
49
+ end
50
+
51
+ should "return a uuid" do
52
+ assert_match(/^\w{32}$/, Resque::Status.create)
53
+ end
54
+
55
+ should "store any status passed" do
56
+ uuid = Resque::Status.create("initial status")
57
+ status = Resque::Status.get(uuid)
58
+ assert status.is_a?(Resque::Status)
59
+ assert_equal "initial status", status.message
60
+ end
61
+
62
+ should "expire keys if expire_in is set" do
63
+ Resque::Status.expire_in = 1
64
+ uuid = Resque::Status.create("new status")
65
+ assert_contains Resque::Status.status_ids, uuid
66
+ assert_equal "new status", Resque::Status.get(uuid).message
67
+ sleep 2
68
+ Resque::Status.create
69
+ assert_does_not_contain Resque::Status.status_ids, uuid
70
+ assert_nil Resque::Status.get(uuid)
71
+ end
72
+ end
73
+
74
+ context ".status_ids" do
75
+ should "return an array of job ids" do
76
+ assert Resque::Status.status_ids.is_a?(Array)
77
+ end
78
+ end
79
+
80
+ context ".statuses" do
81
+
82
+ should "return an array status objects" do
83
+ statuses = Resque::Status.statuses
84
+ assert statuses.is_a?(Array)
85
+ assert_same_elements [@uuid_with_json, @uuid], statuses.collect {|s| s.uuid }
86
+ end
87
+
88
+ end
89
+
90
+ context ".logger" do
91
+ setup do
92
+ @logger = Resque::Status.logger(@uuid)
93
+ end
94
+
95
+ should "return a redisk logger" do
96
+ assert @logger.is_a?(Redisk::Logger)
97
+ end
98
+
99
+ should "scope the logger to a key" do
100
+ assert_match(/#{@uuid}/, @logger.name)
101
+ end
102
+
103
+ end
104
+
105
+ end
106
+
107
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resque-status
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Aaron Quint
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-19 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: uuid
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.0.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: resque
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.1
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: redisk
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.2.0
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: shoulda
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.10.2
54
+ version:
55
+ description: resque-status is an extension to the resque queue system that provides simple trackable jobs. It provides a Resque::Status class which can set/get the statuses of jobs and a Resque::JobWithStatus class that when subclassed provides easily trackable/killable jobs.
56
+ email: aaron@quirkey.com
57
+ executables: []
58
+
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - LICENSE
63
+ - README.rdoc
64
+ files:
65
+ - .document
66
+ - .gitignore
67
+ - LICENSE
68
+ - README.rdoc
69
+ - Rakefile
70
+ - examples/sleep_job.rb
71
+ - init.rb
72
+ - lib/resque/job_with_status.rb
73
+ - lib/resque/server/views/status.erb
74
+ - lib/resque/server/views/status_styles.erb
75
+ - lib/resque/server/views/statuses.erb
76
+ - lib/resque/status.rb
77
+ - lib/resque/status_server.rb
78
+ - resque-status.gemspec
79
+ - test/redis-test.conf
80
+ - test/test_helper.rb
81
+ - test/test_resque-job_with_status.rb
82
+ - test/test_resque-status.rb
83
+ has_rdoc: true
84
+ homepage: http://github.com/quirkey/resque-status
85
+ licenses: []
86
+
87
+ post_install_message:
88
+ rdoc_options:
89
+ - --charset=UTF-8
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: "0"
97
+ version:
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: "0"
103
+ version:
104
+ requirements: []
105
+
106
+ rubyforge_project: quirkey
107
+ rubygems_version: 1.3.5
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: resque-status is an extension to the resque queue system that provides simple trackable jobs.
111
+ test_files:
112
+ - test/test_helper.rb
113
+ - test/test_resque-job_with_status.rb
114
+ - test/test_resque-status.rb
115
+ - examples/sleep_job.rb