rabbit_jobs 0.11.5 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'spec_helper'
3
2
 
4
3
  describe RabbitJobs::Consumer::JobConsumer do
@@ -11,11 +10,13 @@ describe RabbitJobs::Consumer::JobConsumer do
11
10
  mock(RJ::Job).parse(payload) { job }
12
11
  consumer.process_message(:delivery_info, :properties, payload)
13
12
  end
13
+
14
14
  it 'reports parsing errors' do
15
- payload = "some bad json data"
15
+ payload = 'some bad json data'
16
16
  mock(consumer).report_error(:parsing_error, payload)
17
17
  consumer.process_message(:delivery_info, :properties, payload).should == true
18
18
  end
19
+
19
20
  it 'skips expired jobs' do
20
21
  payload = RJ::Job.serialize(TestJob)
21
22
  job
@@ -35,22 +36,22 @@ describe RabbitJobs::Consumer::JobConsumer do
35
36
  end
36
37
 
37
38
  describe '#report_error' do
38
- it "accepts error type :not_found" do
39
- lambda { consumer.report_error(:not_found, 'klass_name') }.should_not raise_error
39
+ it 'accepts error type :not_found' do
40
+ -> { consumer.report_error(:not_found, 'klass_name') }.should_not raise_error
40
41
  end
41
42
 
42
- it "accepts error type :parsing_error" do
43
- lambda { consumer.report_error(:parsing_error, 'payload data') }.should_not raise_error
43
+ it 'accepts error type :parsing_error' do
44
+ -> { consumer.report_error(:parsing_error, 'payload data') }.should_not raise_error
44
45
  end
45
46
 
46
- it "accepts error type :error" do
47
+ it 'accepts error type :error' do
47
48
  exception = nil
48
49
  begin
49
- raise 'testing'
50
- rescue Exception => e
50
+ fail 'testing'
51
+ rescue RuntimeError => e
51
52
  exception = e
52
53
  end
53
- lambda { consumer.report_error(:error, exception, 'payload data') }.should_not raise_error
54
+ -> { consumer.report_error(:error, exception, 'payload data') }.should_not raise_error
54
55
  end
55
56
  end
56
57
  end
@@ -1,35 +1,33 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'spec_helper'
3
2
 
4
3
  describe RabbitJobs::Job do
5
4
  it 'should parse class and params' do
6
- job = RabbitJobs::Job.parse({class: 'TestJob', params: [1,2,3]}.to_json)
7
- job.params.should == [1, 2, 3]
5
+ job, params = RabbitJobs::Job.parse({ class: 'TestJob', params: [1, 2, 3] }.to_json)
6
+ job.should be_is_a(TestJob)
7
+ params.should == [1, 2, 3]
8
8
  end
9
9
 
10
- it 'should understand expires_in' do
11
- job = JobWithExpire.new(1, 2, 3)
12
- job.expires_in.should == 60*60
13
- job.expires?.should == true
10
+ it 'understands expires_in option' do
11
+ JobWithExpire.expires_in.should eq 1.hour
14
12
  end
15
13
 
16
14
  context 'job expiration' do
17
15
  it 'should expire job by expires_in option' do
18
- job = TestJob.new
19
- job.opts['expires_at'] = (Time.now - 10).to_i
16
+ job = JobWithExpire.new
17
+ job.created_at = 2.hours.ago.to_i
20
18
  job.expired?.should == true
21
19
  end
22
20
 
23
21
  it 'should expire job by expires_in option in job class and current_time' do
24
- job = JobWithExpire.new(1, 2, 3)
25
- job.opts['created_at'] = (Time.now - job.expires_in - 10).to_i
22
+ job = JobWithExpire.new
23
+ job.created_at = (Time.now - JobWithExpire.expires_in - 10).to_i
26
24
  job.expired?.should == true
27
25
  end
28
26
 
29
27
  it 'should not be expired with default params' do
30
- job = TestJob.new(1, 2, 3)
31
- job.opts['created_at'] = (Time.now).to_i
28
+ job = TestJob.new
29
+ job.created_at = (Time.now).to_i
32
30
  job.expired?.should == false
33
31
  end
34
32
  end
35
- end
33
+ end
@@ -1,12 +1,11 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'spec_helper'
3
2
 
4
3
  describe RabbitJobs do
5
4
  it 'should pass publish methods to publisher' do
6
- mock(RJ::Publisher).publish_to('default_queue', TestJob, nil, 1, 2, "string")
7
- RJ.publish_to('default_queue', TestJob, nil, 1, 2, "string")
5
+ mock(RJ::Publisher).publish_to('default_queue', TestJob, nil, 1, 2, 'string')
6
+ RJ.publish_to('default_queue', TestJob, nil, 1, 2, 'string')
8
7
 
9
- mock(RJ::Publisher).direct_publish_to('default_queue', 'hello', {name: "my_exchange"})
10
- RJ.direct_publish_to('default_queue', 'hello', {name: "my_exchange"})
8
+ mock(RJ::Publisher).direct_publish_to('default_queue', 'hello', name: 'my_exchange')
9
+ RJ.direct_publish_to('default_queue', 'hello', name: 'my_exchange')
11
10
  end
12
- end
11
+ end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'spec_helper'
3
2
 
4
3
  describe RabbitJobs::Worker do
@@ -6,7 +5,7 @@ describe RabbitJobs::Worker do
6
5
  before(:each) do
7
6
  RJ.configure do |c|
8
7
  c.server 'amqp://localhost'
9
- c.queue "default"
8
+ c.queue 'default'
10
9
  end
11
10
  end
12
11
 
@@ -15,12 +14,12 @@ describe RabbitJobs::Worker do
15
14
  describe '#consumer' do
16
15
  it 'validates consumer type' do
17
16
  old_consumer = worker.consumer
18
- lambda { worker.consumer = 123 }.should raise_error
19
- worker.consumer.should == old_consumer
17
+ -> { worker.consumer = 123 }.should raise_error
18
+ worker.consumer.should eq old_consumer
20
19
 
21
20
  new_consumer = TestConsumer.new
22
- lambda { worker.consumer = new_consumer }.should_not raise_error
23
- worker.consumer.should == new_consumer
21
+ -> { worker.consumer = new_consumer }.should_not raise_error
22
+ worker.consumer.should eq new_consumer
24
23
  end
25
24
  end
26
- end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbit_jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.5
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Lazureykis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-16 00:00:00.000000000 Z
11
+ date: 2014-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: 1.6.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: 1.6.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: codeclimate-test-reporter
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  description: Background jobs on RabbitMQ
140
154
  email:
141
155
  - lazureykis@gmail.com
@@ -157,6 +171,7 @@ files:
157
171
  - examples/configuration.rb
158
172
  - examples/worker
159
173
  - lib/rabbit_jobs.rb
174
+ - lib/rabbit_jobs/amqp_transport.rb
160
175
  - lib/rabbit_jobs/configuration.rb
161
176
  - lib/rabbit_jobs/consumer/job_consumer.rb
162
177
  - lib/rabbit_jobs/job.rb
@@ -204,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
219
  version: '0'
205
220
  requirements: []
206
221
  rubyforge_project:
207
- rubygems_version: 2.0.0
222
+ rubygems_version: 2.0.14
208
223
  signing_key:
209
224
  specification_version: 4
210
225
  summary: Background jobs on RabbitMQ