ayl 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b3b09c825346a151c1ee66241ddb9f8f803fb663
4
+ data.tar.gz: a18dc857d326a0b310cfc2c6fc8b1b4aa1a5afec
5
+ SHA512:
6
+ metadata.gz: 4733517f005acbae5f5c668810bd33fb1fcfe3076892abd4540438a3f1721fb5be3a900f23cd8620169d705806d2c51264d2679d48a302317b23ae39715c15a6
7
+ data.tar.gz: 94529875c0b7971d76a6503b85f5befab221cb775826588717b2f59566b6cd27c35f87ffdc628e512c2e12f59f84db11867330abb691afb1727b4b5cd6483e31
data/Gemfile CHANGED
@@ -6,13 +6,11 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
- gem "rspec", ">= 2.3.0"
10
- gem "bundler", ">= 1.0.0"
11
- gem "jeweler", ">= 1.6.4"
12
- gem "rcov", ">= 0"
13
- gem 'pry'
9
+ gem "rspec", "~> 2.14"
10
+ gem "bundler", "~> 1.10"
11
+ gem "jeweler", "~> 2.0"
14
12
  end
15
13
 
16
- group :test do
17
- gem 'pry'
14
+ group :test, :development do
15
+ gem 'pry', "~> 0.9"
18
16
  end
@@ -1,41 +1,79 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ addressable (2.3.8)
5
+ builder (3.2.2)
4
6
  coderay (0.9.8)
5
- diff-lcs (1.1.3)
6
- git (1.2.5)
7
- jeweler (1.6.4)
8
- bundler (~> 1.0)
7
+ descendants_tracker (0.0.4)
8
+ thread_safe (~> 0.3, >= 0.3.1)
9
+ diff-lcs (1.2.5)
10
+ faraday (0.9.1)
11
+ multipart-post (>= 1.2, < 3)
12
+ git (1.2.9.1)
13
+ github_api (0.12.3)
14
+ addressable (~> 2.3)
15
+ descendants_tracker (~> 0.0.4)
16
+ faraday (~> 0.8, < 0.10)
17
+ hashie (>= 3.3)
18
+ multi_json (>= 1.7.5, < 2.0)
19
+ nokogiri (~> 1.6.3)
20
+ oauth2
21
+ hashie (3.4.2)
22
+ highline (1.7.2)
23
+ jeweler (2.0.1)
24
+ builder
25
+ bundler (>= 1.0)
9
26
  git (>= 1.2.5)
27
+ github_api
28
+ highline (>= 1.6.15)
29
+ nokogiri (>= 1.5.10)
10
30
  rake
31
+ rdoc
32
+ jwt (1.5.0)
11
33
  method_source (0.6.7)
12
34
  ruby_parser (>= 2.3.1)
35
+ mini_portile (0.6.2)
36
+ multi_json (1.11.0)
37
+ multi_xml (0.5.5)
38
+ multipart-post (2.0.0)
39
+ nokogiri (1.6.6.2)
40
+ mini_portile (~> 0.6.0)
41
+ oauth2 (1.0.0)
42
+ faraday (>= 0.8, < 0.10)
43
+ jwt (~> 1.0)
44
+ multi_json (~> 1.3)
45
+ multi_xml (~> 0.5)
46
+ rack (~> 1.2)
13
47
  pry (0.9.7.4)
14
48
  coderay (~> 0.9.8)
15
49
  method_source (~> 0.6.7)
16
50
  ruby_parser (>= 2.3.1)
17
51
  slop (~> 2.1.0)
18
- rake (0.9.2.2)
19
- rcov (0.9.11)
20
- rspec (2.7.0)
21
- rspec-core (~> 2.7.0)
22
- rspec-expectations (~> 2.7.0)
23
- rspec-mocks (~> 2.7.0)
24
- rspec-core (2.7.1)
25
- rspec-expectations (2.7.0)
26
- diff-lcs (~> 1.1.2)
27
- rspec-mocks (2.7.0)
52
+ rack (1.6.1)
53
+ rake (10.4.2)
54
+ rdoc (4.2.0)
55
+ rspec (2.99.0)
56
+ rspec-core (~> 2.99.0)
57
+ rspec-expectations (~> 2.99.0)
58
+ rspec-mocks (~> 2.99.0)
59
+ rspec-core (2.99.2)
60
+ rspec-expectations (2.99.2)
61
+ diff-lcs (>= 1.1.3, < 2.0)
62
+ rspec-mocks (2.99.3)
28
63
  ruby_parser (2.3.1)
29
64
  sexp_processor (~> 3.0)
30
65
  sexp_processor (3.0.8)
31
66
  slop (2.1.0)
67
+ thread_safe (0.3.5)
32
68
 
33
69
  PLATFORMS
34
70
  ruby
35
71
 
36
72
  DEPENDENCIES
37
- bundler (>= 1.0.0)
38
- jeweler (>= 1.6.4)
39
- pry
40
- rcov
41
- rspec (>= 2.3.0)
73
+ bundler (~> 1.10)
74
+ jeweler (~> 2.0)
75
+ pry (~> 0.9)
76
+ rspec (~> 2.14)
77
+
78
+ BUNDLED WITH
79
+ 1.10.3
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 j0hnds@gmail.com
1
+ Copyright (c) 2011-2015 j0hnds@gmail.com
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -13,7 +13,7 @@ been abstracted away from the general framework. You can implement any
13
13
  "Engine" you like to provide the asynchronous functionality. A
14
14
  reference implementation of an engine using beanstalk
15
15
  ({beanstalkd}[http://kr.github.com/beanstalkd/],
16
- {beanstalk-client}[http://beanstalk.rubyforge.org/]) as a queuing
16
+ {beaneater}[https://github.com/beanstalkd/beaneater]) as a queuing
17
17
  mechanism is provided to give you a leg up:
18
18
  {ayl-beanstalk}[https://github.com/j0hnds/ayl-beanstalk]. If you
19
19
  decide to use a different mechanism, you can simply provide an
@@ -39,6 +39,6 @@ See the {wiki}[https://github.com/j0hnds/ayl/wiki/ayl-Home] for more detailed do
39
39
 
40
40
  == Copyright
41
41
 
42
- Copyright (c) 2011 j0hnds@gmail.com. See LICENSE.txt for
42
+ Copyright (c) 2011-2015 j0hnds@gmail.com. See LICENSE.txt for
43
43
  further details.
44
44
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -2,14 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: ayl 0.4.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "ayl"
8
- s.version = "0.3.0"
9
+ s.version = "0.4.0"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Dave Sieh"]
12
- s.date = "2013-08-07"
14
+ s.date = "2015-06-15"
13
15
  s.description = "Invoke code At Your Leisure. ayl is a small framework that simplifies the process of implementing asynchronous method calls in Ruby."
14
16
  s.email = "j0hnds@gmail.com"
15
17
  s.extra_rdoc_files = [
@@ -47,32 +49,28 @@ Gem::Specification.new do |s|
47
49
  ]
48
50
  s.homepage = "http://github.com/j0hnds/ayl"
49
51
  s.licenses = ["MIT"]
50
- s.require_paths = ["lib"]
51
- s.rubygems_version = "1.8.23"
52
+ s.rubygems_version = "2.4.6"
52
53
  s.summary = "Invoke code At Your Leisure"
53
54
 
54
55
  if s.respond_to? :specification_version then
55
- s.specification_version = 3
56
+ s.specification_version = 4
56
57
 
57
58
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
58
- s.add_development_dependency(%q<rspec>, [">= 2.3.0"])
59
- s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
60
- s.add_development_dependency(%q<jeweler>, [">= 1.6.4"])
61
- s.add_development_dependency(%q<rcov>, [">= 0"])
62
- s.add_development_dependency(%q<pry>, [">= 0"])
59
+ s.add_development_dependency(%q<rspec>, ["~> 2.14"])
60
+ s.add_development_dependency(%q<bundler>, ["~> 1.10"])
61
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
62
+ s.add_development_dependency(%q<pry>, ["~> 0.9"])
63
63
  else
64
- s.add_dependency(%q<rspec>, [">= 2.3.0"])
65
- s.add_dependency(%q<bundler>, [">= 1.0.0"])
66
- s.add_dependency(%q<jeweler>, [">= 1.6.4"])
67
- s.add_dependency(%q<rcov>, [">= 0"])
68
- s.add_dependency(%q<pry>, [">= 0"])
64
+ s.add_dependency(%q<rspec>, ["~> 2.14"])
65
+ s.add_dependency(%q<bundler>, ["~> 1.10"])
66
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
67
+ s.add_dependency(%q<pry>, ["~> 0.9"])
69
68
  end
70
69
  else
71
- s.add_dependency(%q<rspec>, [">= 2.3.0"])
72
- s.add_dependency(%q<bundler>, [">= 1.0.0"])
73
- s.add_dependency(%q<jeweler>, [">= 1.6.4"])
74
- s.add_dependency(%q<rcov>, [">= 0"])
75
- s.add_dependency(%q<pry>, [">= 0"])
70
+ s.add_dependency(%q<rspec>, ["~> 2.14"])
71
+ s.add_dependency(%q<bundler>, ["~> 1.10"])
72
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
73
+ s.add_dependency(%q<pry>, ["~> 0.9"])
76
74
  end
77
75
  end
78
76
 
@@ -6,7 +6,8 @@ module Ayl
6
6
  attr_reader :mailer
7
7
 
8
8
  def mailer=(mailer)
9
- raise "Mailer implement the 'ayl_message(message, exception)' method" if mailer && !mailer.respond_to?(:ayl_message)
9
+ raise "Mailer must implement the 'ayl_message(message, exception)' method" if mailer && !mailer.respond_to?(:ayl_message)
10
+ raise "Mailer must implement the 'burying_job(code)' method" if mailer && !mailer.respond_to?(:burying_job)
10
11
  @mailer = mailer
11
12
  end
12
13
 
@@ -16,6 +17,12 @@ module Ayl
16
17
  Ayl::Logger.instance.error("Error sending ayl email message: #{ex.backtrace.join("\n")}")
17
18
  end
18
19
 
20
+ def burying_job(code)
21
+ mailer.burying_job(code).deliver if mailer && mailer.respond_to?(:burying_job)
22
+ rescue Exception => ex
23
+ Ayl::Logger.instance.error("Error sending burying_job email message: #{ex.backtrace.join("\n")}")
24
+ end
25
+
19
26
  end
20
27
 
21
28
  end
@@ -3,6 +3,7 @@ module Ayl
3
3
  class Message
4
4
 
5
5
  attr_accessor :object, :selector, :options, :arguments
6
+ attr_reader :code
6
7
 
7
8
  def initialize(object, selector, opts, *args)
8
9
  @object = object
@@ -13,15 +14,20 @@ module Ayl
13
14
 
14
15
  def self.from_hash(message_hash)
15
16
  raise Ayl::UnrecoverableMessageException, "parameter must be a hash" unless message_hash.is_a?(Hash)
16
- raise Ayl::UnrecoverableMessageException, "not a valid message hash" if message_hash[:type] != :ayl || message_hash[:code].nil?
17
- raise Ayl::UnrecoverableMessageException, "No code provided in job: #{job.body}" if message_hash[:code].nil?
17
+ raise Ayl::UnrecoverableMessageException, "not a valid message hash" if message_hash['type'] != 'ayl' || message_hash['code'].nil?
18
+ raise Ayl::UnrecoverableMessageException, "No code provided in job: #{job.body}" if message_hash['code'].nil?
18
19
 
19
- code = message_hash[:code]
20
+ code = message_hash['code']
20
21
 
21
22
  Message.new(nil, nil, MessageOptions.new).tap do | m |
22
23
  m.send(:message_hash=, message_hash)
23
24
  m.send(:code=, code)
24
- m.options.failed_job_handler = message_hash[:failed_job_handler] if message_hash[:failed_job_handler]
25
+ m.options.failed_job_handler =
26
+ message_hash['failed_job_handler'] if message_hash['failed_job_handler']
27
+ m.options.failed_job_count =
28
+ message_hash['failed_job_count'] if message_hash['failed_job_handler'] == 'decay' && message_hash['failed_job_count']
29
+ m.options.failed_job_delay =
30
+ message_hash['failed_job_delay'] if message_hash['failed_job_handler'] == 'decay' && message_hash['failed_job_delay']
25
31
  end
26
32
 
27
33
  end
@@ -31,11 +37,20 @@ module Ayl
31
37
  end
32
38
 
33
39
  def to_hash
34
- @message_hash ||= {
40
+ @message_hash ||= new_message_hash
41
+ end
42
+
43
+ def new_message_hash
44
+ {
35
45
  :type => :ayl,
36
46
  :failed_job_handler => options.failed_job_handler,
37
47
  :code => to_rrepr
38
- }
48
+ }.tap do | h |
49
+ if options.failed_job_handler == 'decay'
50
+ h[:failed_job_count] = options.failed_job_count
51
+ h[:failed_job_delay] = options.failed_job_delay
52
+ end
53
+ end
39
54
  end
40
55
 
41
56
  def evaluate(top_binding)
@@ -2,14 +2,23 @@ module Ayl
2
2
 
3
3
  class MessageOptions
4
4
 
5
- OPTIONS = [ :priority, :fuzz, :delay, :time_to_run, :queue_name, :failed_job_handler ]
5
+ OPTIONS = [
6
+ :priority,
7
+ :fuzz,
8
+ :delay,
9
+ :time_to_run,
10
+ :queue_name,
11
+ :failed_job_handler,
12
+ :failed_job_delay,
13
+ :failed_job_count ]
6
14
 
7
15
  VALID_FAILED_JOB_HANDLERS = %W{ bury decay delete }
8
16
 
9
17
  attr_accessor *OPTIONS
10
18
 
11
19
  class << self
12
- attr_accessor :default_priority, :default_fuzz, :default_delay, :default_time_to_run, :default_queue_name, :default_failed_job_handler
20
+ attr_accessor :default_priority, :default_fuzz, :default_delay, :default_time_to_run, :default_queue_name
21
+ attr_accessor :default_failed_job_handler, :default_failed_job_delay, :default_failed_job_count
13
22
  end
14
23
 
15
24
  # Set the default options
@@ -19,6 +28,8 @@ module Ayl
19
28
  self.default_time_to_run = 120
20
29
  self.default_queue_name = 'default'
21
30
  self.default_failed_job_handler = 'delete'
31
+ self.default_failed_job_delay = 60
32
+ self.default_failed_job_count = 3
22
33
 
23
34
  def initialize(opts=nil)
24
35
  opts ||= {}
@@ -7,47 +7,47 @@ describe Ayl::Engine do
7
7
  it "should return the default (synchronous) engine if no other engines are configured" do
8
8
  engine = Ayl::Engine.get_active_engine
9
9
 
10
- engine.should_not be_nil
11
- engine.should be_an_instance_of(Ayl::Engine)
10
+ expect(engine).not_to be_nil
11
+ expect(engine).to be_an_instance_of(Ayl::Engine)
12
12
  end
13
13
 
14
14
  it "should allow a different engine to be configured and selected if active" do
15
- mock_engine = mock("FakeEngine")
16
- mock_engine.should_receive(:respond_to?).with(:asynchronous?).and_return(true)
17
- mock_engine.should_receive(:respond_to?).with(:is_connected?).and_return(true)
18
- mock_engine.should_receive(:is_connected?).and_return(true)
15
+ mock_engine = double("FakeEngine")
16
+ expect(mock_engine).to receive(:respond_to?).with(:asynchronous?).and_return(true)
17
+ expect(mock_engine).to receive(:respond_to?).with(:is_connected?).and_return(true)
18
+ expect(mock_engine).to receive(:is_connected?).and_return(true)
19
19
 
20
20
  Ayl::Engine.clear_engines
21
21
  Ayl::Engine.add_engine(mock_engine)
22
22
 
23
- Ayl::Engine.get_active_engine.should == mock_engine
23
+ expect(Ayl::Engine.get_active_engine).to eq(mock_engine)
24
24
  end
25
25
 
26
26
  it "should allow a different engine to be configured but select the default if the new one is not active" do
27
- mock_engine = mock("FakeEngine")
28
- mock_engine.should_receive(:respond_to?).with(:asynchronous?).and_return(true)
29
- mock_engine.should_receive(:respond_to?).with(:is_connected?).and_return(true)
30
- mock_engine.should_receive(:is_connected?).and_return(false)
27
+ mock_engine = double("FakeEngine")
28
+ expect(mock_engine).to receive(:respond_to?).with(:asynchronous?).and_return(true)
29
+ expect(mock_engine).to receive(:respond_to?).with(:is_connected?).and_return(true)
30
+ expect(mock_engine).to receive(:is_connected?).and_return(false)
31
31
 
32
32
  Ayl::Engine.clear_engines
33
33
  Ayl::Engine.add_engine(mock_engine)
34
34
 
35
- Ayl::Engine.get_active_engine.should == Ayl::Engine.instance
35
+ expect(Ayl::Engine.get_active_engine).to eq(Ayl::Engine.instance)
36
36
  end
37
37
 
38
38
  it "should raise an exception if a new engine is added that doesn't respond to :asynchronous" do
39
- mock_engine = mock("FakeEngine")
40
- mock_engine.should_receive(:respond_to?).with(:asynchronous?).and_return(false)
39
+ mock_engine = double("FakeEngine")
40
+ expect(mock_engine).to receive(:respond_to?).with(:asynchronous?).and_return(false)
41
41
 
42
- lambda { Ayl::Engine.add_engine(mock_engine) }.should raise_error
42
+ expect { Ayl::Engine.add_engine(mock_engine) }.to raise_error
43
43
  end
44
44
 
45
45
  it "should raise an exception if a new engine is added that doesn't respond to :is_connected" do
46
- mock_engine = mock("FakeEngine")
47
- mock_engine.should_receive(:respond_to?).with(:asynchronous?).and_return(true)
48
- mock_engine.should_receive(:respond_to?).with(:is_connected?).and_return(false)
46
+ mock_engine = double("FakeEngine")
47
+ expect(mock_engine).to receive(:respond_to?).with(:asynchronous?).and_return(true)
48
+ expect(mock_engine).to receive(:respond_to?).with(:is_connected?).and_return(false)
49
49
 
50
- lambda { Ayl::Engine.add_engine(mock_engine) }.should raise_error
50
+ expect { Ayl::Engine.add_engine(mock_engine) }.to raise_error
51
51
  end
52
52
 
53
53
  end
@@ -59,26 +59,26 @@ describe Ayl::Engine do
59
59
  end
60
60
 
61
61
  it "should identify itself as synchronous" do
62
- @default_engine.asynchronous?.should be_false
62
+ expect(@default_engine.asynchronous?).to be false
63
63
  end
64
64
 
65
65
  it "should respond that it is connected" do
66
- @default_engine.is_connected?.should be_true
66
+ expect(@default_engine.is_connected?).to be true
67
67
  end
68
68
 
69
69
  it "should simply execute the code provided in the message submission" do
70
- mock_logger = mock("Ayl::Logger")
70
+ mock_logger = double("Ayl::Logger")
71
71
  mock_logger.stub(:debug)
72
72
 
73
73
  Ayl::Logger.instance.logger = mock_logger
74
74
 
75
- mock_message = mock("Ayl::Message")
75
+ mock_message = double("Ayl::Message")
76
76
 
77
- mock_worker = mock("Ayl::Worker")
78
- mock_worker.should_receive(:process_message).with(mock_message).and_return(8)
79
- Ayl::Worker.should_receive(:new).and_return(mock_worker)
77
+ mock_worker = double("Ayl::Worker")
78
+ expect(mock_worker).to receive(:process_message).with(mock_message).and_return(8)
79
+ expect(Ayl::Worker).to receive(:new).and_return(mock_worker)
80
80
 
81
- @default_engine.submit(mock_message).should == 8
81
+ expect(@default_engine.submit(mock_message)).to eq(8)
82
82
  end
83
83
 
84
84
  end
@@ -13,30 +13,32 @@ describe Ayl::Extensions do
13
13
  end
14
14
 
15
15
  it "should delegate the call to ayl_send to ayl_send_opts" do
16
- @cut.should_receive(:ayl_send_opts).with(:something, {}, "arg1", "arg2")
16
+ expect(@cut).to receive(:ayl_send_opts).with(:something, {}, "arg1", "arg2")
17
17
  @cut.ayl_send(:something, "arg1", "arg2")
18
18
  end
19
19
 
20
20
  it "should have the message submit the call from ayl_send_opts" do
21
- mock_engine = mock("Ayl::Engine")
21
+ mock_engine = double("Ayl::Engine")
22
22
 
23
- Ayl::Engine.should_receive(:get_active_engine).and_return(mock_engine)
23
+ expect(Ayl::Engine).to receive(:get_active_engine).and_return(mock_engine)
24
24
 
25
- mock_message_opts = mock("Ayl::MessageOptions")
26
- Ayl::MessageOptions.should_receive(:new).with({}).and_return(mock_message_opts)
25
+ mock_message_opts = double("Ayl::MessageOptions")
26
+ expect(Ayl::MessageOptions).to receive(:new).with({}).and_return(mock_message_opts)
27
27
 
28
- mock_message = mock("Ayl::Message")
28
+ mock_message = double("Ayl::Message")
29
29
 
30
- Ayl::Message.should_receive(:new).with(@cut, :something, mock_message_opts, "arg1", "arg2").and_return(mock_message)
31
- mock_engine.should_receive(:submit).with(mock_message)
30
+ expect(Ayl::Message).to receive(:new).
31
+ with(@cut, :something, mock_message_opts, "arg1", "arg2").
32
+ and_return(mock_message)
33
+ expect(mock_engine).to receive(:submit).with(mock_message)
32
34
 
33
35
  @cut.ayl_send_opts(:something, {}, "arg1", "arg2")
34
36
  end
35
37
 
36
38
  it "should extend a common set up classes" do
37
39
  [ Array, Hash, Module, Numeric, Range, String, Symbol ].each do |c|
38
- c.should respond_to :ayl_send
39
- c.should respond_to :ayl_send_opts
40
+ expect(c).to respond_to :ayl_send
41
+ expect(c).to respond_to :ayl_send_opts
40
42
  end
41
43
  end
42
44
 
@@ -9,14 +9,14 @@ describe Ayl::Logger do
9
9
  context "Logger Configuration" do
10
10
 
11
11
  it "should respond with nil if a logger isn't configured" do
12
- Ayl::Logger.instance.logger.should be_nil
12
+ expect(Ayl::Logger.instance.logger).to be_nil
13
13
  end
14
14
 
15
15
  it "should respond with the logger set if the logger is configured" do
16
- mock_logger = mock("Logger")
16
+ mock_logger = double("Logger")
17
17
 
18
18
  Ayl::Logger.instance.logger = mock_logger
19
- Ayl::Logger.instance.logger.should == mock_logger
19
+ expect(Ayl::Logger.instance.logger).to be mock_logger
20
20
  end
21
21
 
22
22
  end
@@ -24,11 +24,11 @@ describe Ayl::Logger do
24
24
  context "Logging" do
25
25
 
26
26
  it "should log calls to the logger through std out when no logger is configured" do
27
- Kernel.should_receive(:puts).with("DEBUG: Debug message")
28
- Kernel.should_receive(:puts).with("ERROR: Error message")
29
- Kernel.should_receive(:puts).with("FATAL: Fatal message")
30
- Kernel.should_receive(:puts).with("INFO: Info message")
31
- Kernel.should_receive(:puts).with("WARN: Warn message")
27
+ expect(Kernel).to receive(:puts).with("DEBUG: Debug message")
28
+ expect(Kernel).to receive(:puts).with("ERROR: Error message")
29
+ expect(Kernel).to receive(:puts).with("FATAL: Fatal message")
30
+ expect(Kernel).to receive(:puts).with("INFO: Info message")
31
+ expect(Kernel).to receive(:puts).with("WARN: Warn message")
32
32
 
33
33
  Ayl::Logger.instance.logger = nil
34
34
 
@@ -38,12 +38,12 @@ describe Ayl::Logger do
38
38
  end
39
39
 
40
40
  it "should log calls to the configured logger" do
41
- mock_logger = mock("Logger")
42
- mock_logger.should_receive(:debug).with("Debug message")
43
- mock_logger.should_receive(:error).with("Error message")
44
- mock_logger.should_receive(:fatal).with("Fatal message")
45
- mock_logger.should_receive(:info).with("Info message")
46
- mock_logger.should_receive(:warn).with("Warn message")
41
+ mock_logger = double("Logger")
42
+ expect(mock_logger).to receive(:debug).with("Debug message")
43
+ expect(mock_logger).to receive(:error).with("Error message")
44
+ expect(mock_logger).to receive(:fatal).with("Fatal message")
45
+ expect(mock_logger).to receive(:info).with("Info message")
46
+ expect(mock_logger).to receive(:warn).with("Warn message")
47
47
 
48
48
  Ayl::Logger.instance.logger = mock_logger
49
49
 
@@ -8,22 +8,23 @@ describe Ayl::Mailer do
8
8
 
9
9
  context 'Mailer configuration' do
10
10
 
11
- context "#logger" do
11
+ context "#deliver_message" do
12
12
 
13
13
  it "should respond with nil if a mailer isn't configured" do
14
- Ayl::Mailer.instance.mailer.should be_nil
14
+ expect(Ayl::Mailer.instance.mailer).to be_nil
15
15
  end
16
16
 
17
17
  it "should raise an error if an attempt is made to configure the mailer with an invalid object" do
18
- lambda { Ayl::Mailer.instance.mailer = Object.new }.should raise_error
18
+ expect { Ayl::Mailer.instance.mailer = Object.new }.to raise_error
19
19
  end
20
20
 
21
21
  it "should allow a valid mailer to be configured" do
22
- mock_mailer = mock("MyMailer")
22
+ mock_mailer = double("MyMailer")
23
23
  mock_mailer.stub(:ayl_message)
24
+ mock_mailer.stub(:burying_job)
24
25
 
25
- lambda { Ayl::Mailer.instance.mailer = mock_mailer }.should_not raise_error
26
- Ayl::Mailer.instance.mailer.should == mock_mailer
26
+ expect { Ayl::Mailer.instance.mailer = mock_mailer }.not_to raise_error
27
+ expect(Ayl::Mailer.instance.mailer).to be mock_mailer
27
28
  end
28
29
 
29
30
  end
@@ -39,12 +40,13 @@ describe Ayl::Mailer do
39
40
  end
40
41
 
41
42
  it "should deliver a message and no stack trace if a valid mailer is configured" do
42
- mock_mailer = mock("MyMailer")
43
- mock_mailer.should_receive(:ayl_message).with('The Message', nil).and_return do
44
- mock("MailMessage").tap do | mail_message |
45
- mail_message.should_receive(:deliver)
46
- end
47
- end
43
+ mock_mailer = double("MyMailer")
44
+ mock_message = double("MailMessage")
45
+ expect(mock_message).to receive(:deliver)
46
+ expect(mock_mailer).to receive(:ayl_message).
47
+ with('The Message', nil).
48
+ and_return(mock_message)
49
+ mock_mailer.stub(:burying_job)
48
50
 
49
51
  Ayl::Mailer.instance.mailer = mock_mailer
50
52
 
@@ -52,12 +54,13 @@ describe Ayl::Mailer do
52
54
  end
53
55
 
54
56
  it "should deliver a message and a stack trace if a valid mailer is configured" do
55
- mock_mailer = mock("MyMailer")
56
- mock_mailer.should_receive(:ayl_message).with('The Message', 'StackTrace').and_return do
57
- mock("MailMessage").tap do | mail_message |
58
- mail_message.should_receive(:deliver)
59
- end
60
- end
57
+ mock_mailer = double("MyMailer")
58
+ mock_message = double("MailMessage")
59
+ expect(mock_message).to receive(:deliver)
60
+ expect(mock_mailer).to receive(:ayl_message).
61
+ with('The Message', 'StackTrace').
62
+ and_return(mock_message)
63
+ mock_mailer.stub(:burying_job)
61
64
 
62
65
  Ayl::Mailer.instance.mailer = mock_mailer
63
66
 
@@ -66,6 +69,23 @@ describe Ayl::Mailer do
66
69
 
67
70
  end
68
71
 
72
+ context '#burying_job' do
73
+
74
+ it "should deliver a message if a valid mailer is configured" do
75
+ mock_mailer = double("MyMailer")
76
+ mock_message = double("MailMessage")
77
+ expect(mock_message).to receive(:deliver)
78
+ expect(mock_mailer).to receive(:burying_job).
79
+ with('1 + 2').
80
+ and_return(mock_message)
81
+ mock_mailer.stub(:ayl_message)
82
+
83
+ Ayl::Mailer.instance.mailer = mock_mailer
84
+
85
+ Ayl::Mailer.instance.burying_job('1 + 2')
86
+ end
87
+ end
88
+
69
89
  end
70
90
 
71
91
  end
@@ -5,12 +5,14 @@ describe Ayl::MessageOptions do
5
5
  context "Option Default Accessors" do
6
6
 
7
7
  it "should have the correct defaults" do
8
- Ayl::MessageOptions.default_priority.should == 512
9
- Ayl::MessageOptions.default_fuzz.should == 0
10
- Ayl::MessageOptions.default_delay.should == 0
11
- Ayl::MessageOptions.default_time_to_run.should == 120
12
- Ayl::MessageOptions.default_queue_name.should == 'default'
13
- Ayl::MessageOptions.default_failed_job_handler.should == 'delete'
8
+ expect(Ayl::MessageOptions.default_priority).to eq(512)
9
+ expect(Ayl::MessageOptions.default_fuzz).to eq(0)
10
+ expect(Ayl::MessageOptions.default_delay).to eq(0)
11
+ expect(Ayl::MessageOptions.default_time_to_run).to eq(120)
12
+ expect(Ayl::MessageOptions.default_queue_name).to eq('default')
13
+ expect(Ayl::MessageOptions.default_failed_job_handler).to eq('delete')
14
+ expect(Ayl::MessageOptions.default_failed_job_count).to eq(3)
15
+ expect(Ayl::MessageOptions.default_failed_job_delay).to eq(60)
14
16
  end
15
17
 
16
18
  it "should reflect the changes if changes have been made" do
@@ -20,13 +22,17 @@ describe Ayl::MessageOptions do
20
22
  Ayl::MessageOptions.default_time_to_run = 1
21
23
  Ayl::MessageOptions.default_queue_name = 'different'
22
24
  Ayl::MessageOptions.default_failed_job_handler = 'bury'
23
-
24
- Ayl::MessageOptions.default_priority.should == 256
25
- Ayl::MessageOptions.default_fuzz.should == 18
26
- Ayl::MessageOptions.default_delay.should == 2300
27
- Ayl::MessageOptions.default_time_to_run.should == 1
28
- Ayl::MessageOptions.default_queue_name.should == 'different'
29
- Ayl::MessageOptions.default_failed_job_handler.should == 'bury'
25
+ Ayl::MessageOptions.default_failed_job_count = 8
26
+ Ayl::MessageOptions.default_failed_job_delay = 3600
27
+
28
+ expect(Ayl::MessageOptions.default_priority).to eq(256)
29
+ expect(Ayl::MessageOptions.default_fuzz).to eq(18)
30
+ expect(Ayl::MessageOptions.default_delay).to eq(2300)
31
+ expect(Ayl::MessageOptions.default_time_to_run).to eq(1)
32
+ expect(Ayl::MessageOptions.default_queue_name).to eq('different')
33
+ expect(Ayl::MessageOptions.default_failed_job_handler).to eq('bury')
34
+ expect(Ayl::MessageOptions.default_failed_job_count).to eq(8)
35
+ expect(Ayl::MessageOptions.default_failed_job_delay).to eq(3600)
30
36
  end
31
37
 
32
38
  end
@@ -36,66 +42,77 @@ describe Ayl::MessageOptions do
36
42
  it "should respond with the correct defaults when initialized with an empty hash" do
37
43
  mo = Ayl::MessageOptions.new({})
38
44
 
39
- mo.priority.should == Ayl::MessageOptions.default_priority
40
- mo.fuzz.should == Ayl::MessageOptions.default_fuzz
41
- mo.delay.should == Ayl::MessageOptions.default_delay
42
- mo.time_to_run.should == Ayl::MessageOptions.default_time_to_run
43
- mo.queue_name.should == Ayl::MessageOptions.default_queue_name
44
- mo.failed_job_handler.should == Ayl::MessageOptions.default_failed_job_handler
45
+ expect(mo.priority).to eq(Ayl::MessageOptions.default_priority)
46
+ expect(mo.fuzz).to eq(Ayl::MessageOptions.default_fuzz)
47
+ expect(mo.delay).to eq(Ayl::MessageOptions.default_delay)
48
+ expect(mo.time_to_run).to eq(Ayl::MessageOptions.default_time_to_run)
49
+ expect(mo.queue_name).to eq(Ayl::MessageOptions.default_queue_name)
50
+ expect(mo.failed_job_handler).to eq(Ayl::MessageOptions.default_failed_job_handler)
51
+ expect(mo.failed_job_count).to eq(Ayl::MessageOptions.default_failed_job_count)
52
+ expect(mo.failed_job_delay).to eq(Ayl::MessageOptions.default_failed_job_delay)
45
53
  end
46
54
 
47
55
  it "should respond with the correct defaults when initialized with nil" do
48
56
  mo = Ayl::MessageOptions.new(nil)
49
57
 
50
- mo.priority.should == Ayl::MessageOptions.default_priority
51
- mo.fuzz.should == Ayl::MessageOptions.default_fuzz
52
- mo.delay.should == Ayl::MessageOptions.default_delay
53
- mo.time_to_run.should == Ayl::MessageOptions.default_time_to_run
54
- mo.queue_name.should == Ayl::MessageOptions.default_queue_name
55
- mo.failed_job_handler.should == Ayl::MessageOptions.default_failed_job_handler
58
+ expect(mo.priority).to eq(Ayl::MessageOptions.default_priority)
59
+ expect(mo.fuzz).to eq(Ayl::MessageOptions.default_fuzz)
60
+ expect(mo.delay).to eq(Ayl::MessageOptions.default_delay)
61
+ expect(mo.time_to_run).to eq(Ayl::MessageOptions.default_time_to_run)
62
+ expect(mo.queue_name).to eq(Ayl::MessageOptions.default_queue_name)
63
+ expect(mo.failed_job_handler).to eq(Ayl::MessageOptions.default_failed_job_handler)
64
+ expect(mo.failed_job_count).to eq(Ayl::MessageOptions.default_failed_job_count)
65
+ expect(mo.failed_job_delay).to eq(Ayl::MessageOptions.default_failed_job_delay)
56
66
  end
57
67
 
58
68
  it "should respond with the correct defaults when initialized with no parameter" do
59
69
  mo = Ayl::MessageOptions.new()
60
70
 
61
- mo.priority.should == Ayl::MessageOptions.default_priority
62
- mo.fuzz.should == Ayl::MessageOptions.default_fuzz
63
- mo.delay.should == Ayl::MessageOptions.default_delay
64
- mo.time_to_run.should == Ayl::MessageOptions.default_time_to_run
65
- mo.queue_name.should == Ayl::MessageOptions.default_queue_name
66
- mo.failed_job_handler.should == Ayl::MessageOptions.default_failed_job_handler
71
+ expect(mo.priority).to eq(Ayl::MessageOptions.default_priority)
72
+ expect(mo.fuzz).to eq(Ayl::MessageOptions.default_fuzz)
73
+ expect(mo.delay).to eq(Ayl::MessageOptions.default_delay)
74
+ expect(mo.time_to_run).to eq(Ayl::MessageOptions.default_time_to_run)
75
+ expect(mo.queue_name).to eq(Ayl::MessageOptions.default_queue_name)
76
+ expect(mo.failed_job_handler).to eq(Ayl::MessageOptions.default_failed_job_handler)
77
+ expect(mo.failed_job_count).to eq(Ayl::MessageOptions.default_failed_job_count)
78
+ expect(mo.failed_job_delay).to eq(Ayl::MessageOptions.default_failed_job_delay)
67
79
  end
68
80
 
69
81
  it "should respond with the correct values when all are specified in the options" do
70
- opts = { :priority => 22, :fuzz => 88, :delay => 99, :time_to_run => 11, :queue_name => 'stub', :failed_job_handler => 'decay' }
82
+ opts = { priority: 22, fuzz: 88, delay: 99, time_to_run: 11, queue_name: 'stub',
83
+ failed_job_handler: 'decay', failed_job_count: 12, failed_job_delay: 14 }
71
84
  mo = Ayl::MessageOptions.new(opts)
72
85
 
73
- mo.priority.should == opts[:priority]
74
- mo.fuzz.should == opts[:fuzz]
75
- mo.delay.should == opts[:delay]
76
- mo.time_to_run.should == opts[:time_to_run]
77
- mo.queue_name.should == opts[:queue_name]
78
- mo.failed_job_handler.should == opts[:failed_job_handler]
86
+ expect(mo.priority).to eq(opts[:priority])
87
+ expect(mo.fuzz).to eq(opts[:fuzz])
88
+ expect(mo.delay).to eq(opts[:delay])
89
+ expect(mo.time_to_run).to eq(opts[:time_to_run])
90
+ expect(mo.queue_name).to eq(opts[:queue_name])
91
+ expect(mo.failed_job_handler).to eq(opts[:failed_job_handler])
92
+ expect(mo.failed_job_count).to eq(opts[:failed_job_count])
93
+ expect(mo.failed_job_delay).to eq(opts[:failed_job_delay])
79
94
  end
80
95
 
81
96
  it "should respond with the correct values when some values are specified in the options" do
82
97
  opts = { :priority => 22, :fuzz => 88, :delay => 99 }
83
98
  mo = Ayl::MessageOptions.new(opts)
84
99
 
85
- mo.priority.should == opts[:priority]
86
- mo.fuzz.should == opts[:fuzz]
87
- mo.delay.should == opts[:delay]
88
- mo.time_to_run.should == Ayl::MessageOptions.default_time_to_run
89
- mo.queue_name.should == Ayl::MessageOptions.default_queue_name
90
- mo.failed_job_handler.should == Ayl::MessageOptions.default_failed_job_handler
100
+ expect(mo.priority).to eq(opts[:priority])
101
+ expect(mo.fuzz).to eq(opts[:fuzz])
102
+ expect(mo.delay).to eq(opts[:delay])
103
+ expect(mo.time_to_run).to eq(Ayl::MessageOptions.default_time_to_run)
104
+ expect(mo.queue_name).to eq(Ayl::MessageOptions.default_queue_name)
105
+ expect(mo.failed_job_handler).to eq(Ayl::MessageOptions.default_failed_job_handler)
106
+ expect(mo.failed_job_count).to eq(Ayl::MessageOptions.default_failed_job_count)
107
+ expect(mo.failed_job_delay).to eq(Ayl::MessageOptions.default_failed_job_delay)
91
108
  end
92
109
 
93
110
  it "should raise an exception when an invalid option is provided in the hash" do
94
- lambda { Ayl::MessageOptions.new({:bob => 'something' }) }.should raise_error
111
+ expect { Ayl::MessageOptions.new({:bob => 'something' }) }.to raise_error
95
112
  end
96
113
 
97
114
  it "should raise an exception when a non-hash is provided as a parameter" do
98
- lambda { Ayl::MessageOptions.new(14) }.should raise_error
115
+ expect { Ayl::MessageOptions.new(14) }.to raise_error
99
116
  end
100
117
 
101
118
  end
@@ -10,6 +10,8 @@ describe Ayl::Message do
10
10
  Ayl::MessageOptions.default_time_to_run = 120
11
11
  Ayl::MessageOptions.default_queue_name = 'default'
12
12
  Ayl::MessageOptions.default_failed_job_handler = 'decay'
13
+ Ayl::MessageOptions.default_failed_job_count = 3
14
+ Ayl::MessageOptions.default_failed_job_delay = 60
13
15
  end
14
16
 
15
17
  context "Initialization" do
@@ -18,20 +20,20 @@ describe Ayl::Message do
18
20
  options = Ayl::MessageOptions.new
19
21
  m = Ayl::Message.new("object", :method_name, options, "arg1", "arg2")
20
22
 
21
- m.object.should == "object"
22
- m.selector.should == :method_name
23
- m.options.should == options
24
- m.arguments.should == [ "arg1", "arg2" ]
23
+ expect(m.object).to eq "object"
24
+ expect(m.selector).to eq :method_name
25
+ expect(m.options).to eq options
26
+ expect(m.arguments).to eq [ "arg1", "arg2" ]
25
27
  end
26
28
 
27
29
  it "should accept an object, selector options and no arguments" do
28
30
  options = Ayl::MessageOptions.new
29
31
  m = Ayl::Message.new("object", :method_name, options)
30
32
 
31
- m.object.should == "object"
32
- m.selector.should == :method_name
33
- m.options.should == options
34
- m.arguments.should == [ ]
33
+ expect(m.object).to eq "object"
34
+ expect(m.selector).to eq :method_name
35
+ expect(m.options).to eq options
36
+ expect(m.arguments).to eq [ ]
35
37
  end
36
38
 
37
39
  end
@@ -41,13 +43,13 @@ describe Ayl::Message do
41
43
  it "should generate code when arguments are present" do
42
44
  options = Ayl::MessageOptions.new
43
45
  m = Ayl::Message.new("object", :method_name, options, "arg1", "arg2")
44
- m.to_rrepr.should == "\"object\".method_name(\"arg1\", \"arg2\")"
46
+ expect(m.to_rrepr).to eq "\"object\".method_name(\"arg1\", \"arg2\")"
45
47
  end
46
48
 
47
49
  it "should generate code when no arguments are present" do
48
50
  options = Ayl::MessageOptions.new
49
51
  m = Ayl::Message.new("object", :method_name, options)
50
- m.to_rrepr.should == "\"object\".method_name()"
52
+ expect(m.to_rrepr).to eq "\"object\".method_name()"
51
53
  end
52
54
 
53
55
  end
@@ -57,75 +59,81 @@ describe Ayl::Message do
57
59
  it "should package up the message into a hash" do
58
60
  options = Ayl::MessageOptions.new
59
61
  m = Ayl::Message.new("object", :method_name, options, "arg1", "arg2")
60
- m.to_hash.should == { :type => :ayl, :failed_job_handler => 'decay', :code => "\"object\".method_name(\"arg1\", \"arg2\")" }
62
+ expect(m.to_hash).to eq({ :type => :ayl, :failed_job_handler => 'decay', :failed_job_count => 3, :failed_job_delay => 60, :code => "\"object\".method_name(\"arg1\", \"arg2\")" })
63
+ end
64
+
65
+ it "should package up the message into a hash but not with decay" do
66
+ options = Ayl::MessageOptions.new({failed_job_handler: 'delete'})
67
+ m = Ayl::Message.new("object", :method_name, options, "arg1", "arg2")
68
+ expect(m.to_hash).to eq({ :type => :ayl, :failed_job_handler => 'delete', :code => "\"object\".method_name(\"arg1\", \"arg2\")" })
61
69
  end
62
70
 
63
71
  it "should package up the message into a hash when the decay failed job has been set" do
64
72
  options = Ayl::MessageOptions.new
65
73
  options.failed_job_handler = 'decay'
66
74
  m = Ayl::Message.new("object", :method_name, options, "arg1", "arg2")
67
- m.to_hash.should == { :type => :ayl, :failed_job_handler => 'decay', :code => "\"object\".method_name(\"arg1\", \"arg2\")" }
75
+ expect(m.to_hash).to eq({ :type => :ayl, :failed_job_handler => 'decay', :failed_job_count => 3, :failed_job_delay => 60, :code => "\"object\".method_name(\"arg1\", \"arg2\")" })
68
76
  end
69
77
 
70
78
  it "should be able to create a message from a hash with code that has arguments" do
71
- m_hash = { :type => :ayl, :code => "\"object\".method_name(\"arg1\", \"arg2\")" }
79
+ m_hash = { 'type' => 'ayl', 'code' => "\"object\".method_name(\"arg1\", \"arg2\")" }
72
80
  m = Ayl::Message.from_hash(m_hash)
73
- m.options.is_a?(Ayl::MessageOptions).should be_true
74
- m.to_hash.should === m_hash
81
+ expect(m.options.is_a?(Ayl::MessageOptions)).to be true
82
+ expect(m.to_hash).to eq m_hash
75
83
  end
76
84
 
77
85
  it "should be able to create a message from a hash with code that has no arguments" do
78
- m_hash = { :type => :ayl, :code => "\"object\".method_name()" }
86
+ m_hash = { 'type' => 'ayl', 'code' => "\"object\".method_name()" }
79
87
  m = Ayl::Message.from_hash(m_hash)
80
- m.options.is_a?(Ayl::MessageOptions).should be_true
81
- m.to_hash.should === m_hash
88
+ expect(m.options.is_a?(Ayl::MessageOptions)).to be true
89
+ expect(m.to_hash).to eq m_hash
82
90
  end
83
91
 
84
92
  it "should be able to create a message from a hash with code that has no arguments and no parens" do
85
- m_hash = { :type => :ayl, :code => "\"object\".method_name" }
93
+ m_hash = { 'type' => 'ayl', 'code' => "\"object\".method_name" }
86
94
  m = Ayl::Message.from_hash(m_hash)
87
- m.options.is_a?(Ayl::MessageOptions).should be_true
88
- m.to_hash.should === m_hash
95
+ expect(m.options.is_a?(Ayl::MessageOptions)).to be true
96
+ expect(m.to_hash).to eq m_hash
89
97
  end
90
98
 
91
99
  it "should be able to create a message from a hash with code that has one arguments with multiple parens" do
92
- m_hash = { :type => :ayl, :code => "\"object\".method_name('string'.length())" }
100
+ m_hash = { 'type' => 'ayl', 'code' => "\"object\".method_name('string'.length())" }
93
101
  m = Ayl::Message.from_hash(m_hash)
94
- m.options.is_a?(Ayl::MessageOptions).should be_true
95
- m.to_hash.should === m_hash
102
+ expect(m.options.is_a?(Ayl::MessageOptions)).to be true
103
+ expect(m.to_hash).to be m_hash
96
104
  end
97
105
 
98
106
  # Sample._ayl_after_create(Sample.find(106))
99
107
  it "should be able to create a message from a hash with code that has one arguments with multiple parens" do
100
- m_hash = { :type => :ayl, :code => "String._ayl_after_create(2.to_s(2))" }
108
+ m_hash = { 'type' => 'ayl', 'code' => "String._ayl_after_create(2.to_s(2))" }
101
109
  m = Ayl::Message.from_hash(m_hash)
102
- m.options.is_a?(Ayl::MessageOptions).should be_true
103
- m.to_hash.should === m_hash
110
+ expect(m.options.is_a?(Ayl::MessageOptions)).to be true
111
+ expect(m.to_hash).to be m_hash
104
112
  end
105
113
 
106
114
  it "should create a message with decay_failed job set to false if not in the original hash" do
107
115
  Ayl::MessageOptions.default_failed_job_handler = 'delete'
108
- m_hash = { :type => :ayl, :code => "String._ayl_after_create(2.to_s(2))" }
116
+ m_hash = { 'type' => 'ayl', 'code' => "String._ayl_after_create(2.to_s(2))" }
109
117
  m = Ayl::Message.from_hash(m_hash)
110
- m.options.is_a?(Ayl::MessageOptions).should be_true
111
- m.to_hash.should === m_hash
112
- m.options.failed_job_handler.should == 'delete'
118
+ expect(m.options.is_a?(Ayl::MessageOptions)).to be true
119
+ expect(m.to_hash).to be m_hash
120
+ expect(m.options.failed_job_handler).to eq 'delete'
113
121
  end
114
122
 
115
123
  it "should create a message with decay_failed job set to false if in the original hash as false" do
116
- m_hash = { :type => :ayl, :failed_job_handler => 'delete', :code => "String._ayl_after_create(2.to_s(2))" }
124
+ m_hash = { 'type' => 'ayl', 'failed_job_handler' => 'delete', 'code' => "String._ayl_after_create(2.to_s(2))" }
117
125
  m = Ayl::Message.from_hash(m_hash)
118
- m.options.is_a?(Ayl::MessageOptions).should be_true
119
- m.to_hash.should === m_hash
120
- m.options.failed_job_handler.should == 'delete'
126
+ expect(m.options.is_a?(Ayl::MessageOptions)).to be true
127
+ expect(m.to_hash).to be m_hash
128
+ expect(m.options.failed_job_handler).to eq 'delete'
121
129
  end
122
130
 
123
131
  it "should create a message with decay_failed job set to true if in the original hash as true" do
124
- m_hash = { :type => :ayl, :failed_job_handler => 'decay', :code => "String._ayl_after_create(2.to_s(2))" }
132
+ m_hash = { 'type' => 'ayl', 'failed_job_handler' => 'decay', 'code' => "String._ayl_after_create(2.to_s(2))" }
125
133
  m = Ayl::Message.from_hash(m_hash)
126
- m.options.is_a?(Ayl::MessageOptions).should be_true
127
- m.to_hash.should === m_hash
128
- m.options.failed_job_handler.should == 'decay'
134
+ expect(m.options.is_a?(Ayl::MessageOptions)).to be true
135
+ expect(m.to_hash).to be m_hash
136
+ expect(m.options.failed_job_handler).to eq 'decay'
129
137
  end
130
138
 
131
139
 
@@ -136,7 +144,7 @@ describe Ayl::Message do
136
144
  it "should evaluate the code associated with the message" do
137
145
  array_of_nums = [ 3, 2, 8, 1 ]
138
146
  m = Ayl::Message.new(array_of_nums, :length, Ayl::MessageOptions.new)
139
- m.evaluate(binding).should == 4
147
+ expect(m.evaluate(binding)).to be 4
140
148
  end
141
149
 
142
150
  end
@@ -11,7 +11,7 @@ describe Ayl::Worker do
11
11
 
12
12
  it "should raise an exception if receive is called on an engine that is not asynchronous" do
13
13
  Kernel.stub(:puts)
14
- lambda { @worker.process_messages }.should raise_error(RuntimeError, "synchronous worker cannot receive messages")
14
+ expect { @worker.process_messages }.to raise_error(RuntimeError, "synchronous worker cannot receive messages")
15
15
  end
16
16
 
17
17
  end
metadata CHANGED
@@ -1,96 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ayl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dave Sieh
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-07 00:00:00.000000000 Z
11
+ date: 2015-06-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 2.3.0
19
+ version: '2.14'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 2.3.0
26
+ version: '2.14'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: 1.0.0
33
+ version: '1.10'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: 1.0.0
40
+ version: '1.10'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: jeweler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: 1.6.4
47
+ version: '2.0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: 1.6.4
62
- - !ruby/object:Gem::Dependency
63
- name: rcov
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
54
+ version: '2.0'
78
55
  - !ruby/object:Gem::Dependency
79
56
  name: pry
80
57
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
58
  requirements:
83
- - - ! '>='
59
+ - - "~>"
84
60
  - !ruby/object:Gem::Version
85
- version: '0'
61
+ version: '0.9'
86
62
  type: :development
87
63
  prerelease: false
88
64
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
65
  requirements:
91
- - - ! '>='
66
+ - - "~>"
92
67
  - !ruby/object:Gem::Version
93
- version: '0'
68
+ version: '0.9'
94
69
  description: Invoke code At Your Leisure. ayl is a small framework that simplifies
95
70
  the process of implementing asynchronous method calls in Ruby.
96
71
  email: j0hnds@gmail.com
@@ -100,8 +75,8 @@ extra_rdoc_files:
100
75
  - LICENSE.txt
101
76
  - README.rdoc
102
77
  files:
103
- - .document
104
- - .rspec
78
+ - ".document"
79
+ - ".rspec"
105
80
  - Gemfile
106
81
  - Gemfile.lock
107
82
  - LICENSE.txt
@@ -130,29 +105,25 @@ files:
130
105
  homepage: http://github.com/j0hnds/ayl
131
106
  licenses:
132
107
  - MIT
108
+ metadata: {}
133
109
  post_install_message:
134
110
  rdoc_options: []
135
111
  require_paths:
136
112
  - lib
137
113
  required_ruby_version: !ruby/object:Gem::Requirement
138
- none: false
139
114
  requirements:
140
- - - ! '>='
115
+ - - ">="
141
116
  - !ruby/object:Gem::Version
142
117
  version: '0'
143
- segments:
144
- - 0
145
- hash: 831016271210020708
146
118
  required_rubygems_version: !ruby/object:Gem::Requirement
147
- none: false
148
119
  requirements:
149
- - - ! '>='
120
+ - - ">="
150
121
  - !ruby/object:Gem::Version
151
122
  version: '0'
152
123
  requirements: []
153
124
  rubyforge_project:
154
- rubygems_version: 1.8.23
125
+ rubygems_version: 2.4.6
155
126
  signing_key:
156
- specification_version: 3
127
+ specification_version: 4
157
128
  summary: Invoke code At Your Leisure
158
129
  test_files: []