Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Upgrade to latest rspec syntax.

  • Loading branch information...
commit dc471c94c2d2e8b58de2f360dce9b3c54dbaab5e 1 parent 49847e2
@fnando authored
View
58 Gemfile.lock
@@ -7,14 +7,14 @@ PATH
GEM
remote: https://rubygems.org/
specs:
- activemodel (4.1.0)
- activesupport (= 4.1.0)
+ activemodel (4.1.1)
+ activesupport (= 4.1.1)
builder (~> 3.1)
- activerecord (4.1.0)
- activemodel (= 4.1.0)
- activesupport (= 4.1.0)
+ activerecord (4.1.1)
+ activemodel (= 4.1.1)
+ activesupport (= 4.1.1)
arel (~> 5.0.0)
- activesupport (4.1.0)
+ activesupport (4.1.1)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
@@ -41,19 +41,19 @@ GEM
i18n (0.6.9)
json (1.8.1)
method_source (0.8.2)
- minitest (5.3.3)
+ minitest (5.3.4)
mono_logger (1.1.0)
- multi_json (1.9.3)
- pry (0.9.12.6)
- coderay (~> 1.0)
- method_source (~> 0.8)
+ multi_json (1.10.1)
+ pry (0.10.0)
+ coderay (~> 1.1.0)
+ method_source (~> 0.8.1)
slop (~> 3.4)
qu (0.2.0)
multi_json
rack (1.5.2)
rack-protection (1.5.3)
rack
- rake (10.3.1)
+ rake (10.3.2)
redis (3.0.7)
redis-namespace (1.4.1)
redis (~> 3.0.4)
@@ -63,22 +63,26 @@ GEM
redis-namespace (~> 1.3)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
- resque-scheduler (2.5.5)
+ resque-scheduler (3.0.0)
mono_logger (~> 1.0)
- redis (~> 3.0.4)
- resque (~> 1.25.1)
- rufus-scheduler (~> 2.0.24)
- rspec (2.14.1)
- rspec-core (~> 2.14.0)
- rspec-expectations (~> 2.14.0)
- rspec-mocks (~> 2.14.0)
- rspec-core (2.14.8)
- rspec-expectations (2.14.5)
- diff-lcs (>= 1.1.3, < 2.0)
- rspec-mocks (2.14.6)
+ redis (~> 3.0)
+ resque (~> 1.25)
+ rufus-scheduler (~> 2.0)
+ rspec (3.0.0)
+ rspec-core (~> 3.0.0)
+ rspec-expectations (~> 3.0.0)
+ rspec-mocks (~> 3.0.0)
+ rspec-core (3.0.1)
+ rspec-support (~> 3.0.0)
+ rspec-expectations (3.0.1)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.0.0)
+ rspec-mocks (3.0.1)
+ rspec-support (~> 3.0.0)
+ rspec-support (3.0.0)
rufus-scheduler (2.0.24)
tzinfo (>= 0.3.22)
- sidekiq (3.0.2)
+ sidekiq (3.1.4)
celluloid (>= 0.15.2)
connection_pool (>= 2.0.0)
json
@@ -90,10 +94,10 @@ GEM
tilt (~> 1.3, >= 1.3.4)
slop (3.5.0)
sqlite3 (1.3.9)
- thread_safe (0.3.3)
+ thread_safe (0.3.4)
tilt (1.4.1)
timers (1.1.0)
- tzinfo (1.1.0)
+ tzinfo (1.2.1)
thread_safe (~> 0.1)
vegas (0.1.11)
rack (>= 1.0.0)
View
2  lib/qe/resque.rb
@@ -1,6 +1,6 @@
require "qe"
require "resque"
-require "resque_scheduler"
+require "resque-scheduler"
module Qe
class Resque
View
6 lib/qe/testing/rspec.rb
@@ -55,13 +55,15 @@ def description
"enqueue job for #{worker.inspect} worker"
end
- def failure_message_for_should
+ def failure_message
build_message "expect #{worker.inspect} to be enqueued"
end
+ alias_method :failure_message_for_should, :failure_message
- def failure_message_for_should_not
+ def failure_message_when_negated
build_message "expect #{worker.inspect} not to be enqueued"
end
+ alias_method :failure_message_for_should_not, :failure_message_when_negated
def build_message(base)
base << ((options || {}).empty? ? "" : " with #{options.inspect}")
View
11 spec/qe/action_mailer_spec.rb
@@ -28,10 +28,10 @@
end
it "returns object for :mail option" do
- job.stub :mailer => mailer
+ allow(job).to receive(:mailer).and_return(mailer)
- mailer
- .should_receive(:hello)
+ expect(mailer)
+ .to receive(:hello)
.with(job.options)
job.mail
@@ -49,9 +49,8 @@
describe "#perform" do
it "delivers e-mail" do
mail = double(:mail)
- job.stub :mail => mail
-
- mail.should_receive(:deliver)
+ allow(job).to receive_messages(:mail => mail)
+ expect(mail).to receive(:deliver)
job.perform
end
View
4 spec/qe/action_spec.rb
@@ -16,14 +16,14 @@ def default; end
end
it "performs specified action" do
- job.should_receive(:hello)
+ expect(job).to receive(:hello)
job.options[:action] = :hello
job.perform
end
it "executes default action when have no action" do
- job.should_receive(:default)
+ expect(job).to receive(:default)
job.perform
end
View
27 spec/qe/beanstalk_spec.rb
@@ -9,8 +9,8 @@
context "worker" do
it "performs job" do
- Qe::Worker
- .should_receive(:perform)
+ expect(Qe::Worker)
+ .to receive(:perform)
.with(:a, :b, :c)
Qe::Beanstalk::Worker.perform(:a, :b, :c)
@@ -23,20 +23,20 @@
}
before do
- Backburner.stub :enqueue
+ allow(Backburner).to receive(:enqueue)
end
it "sets queue name" do
- Qe::Beanstalk::Worker
- .should_receive(:queue)
+ expect(Qe::Beanstalk::Worker)
+ .to receive(:queue)
.with("some_queue")
Qe::Beanstalk.enqueue(worker)
end
it "enqueues job" do
- ::Backburner
- .should_receive(:enqueue)
+ expect(::Backburner)
+ .to receive(:enqueue)
.with(Qe::Beanstalk::Worker, "SomeWorker", :a => 1)
Qe::Beanstalk.enqueue(worker, :a => 1)
@@ -51,22 +51,21 @@
let(:date) { Time.parse("2012-12-05 02:00:00") }
before do
- Time.stub :now => date - 3600
- Backburner::Worker.stub :enqueue
+ allow(Time).to receive_messages(:now => date - 3600)
+ allow(Backburner::Worker).to receive(:enqueue)
end
it "sets queue name" do
- Qe::Beanstalk::Worker
- .should_receive(:queue)
+ expect(Qe::Beanstalk::Worker)
+ .to receive(:queue)
.with("some_queue")
Qe::Beanstalk.schedule(worker, date, :a => 1)
end
it "schedules job" do
- ::Backburner::Worker
- .should_receive(:enqueue)
- .with(Qe::Beanstalk::Worker, ["SomeWorker", :a => 1], :delay => 3600)
+ expect(::Backburner::Worker).to receive(:enqueue)
+ .with(Qe::Beanstalk::Worker, ["SomeWorker", :a => 1], :delay => 3600)
Qe::Beanstalk.schedule(worker, date, :a => 1)
end
View
36 spec/qe/delayed_job_spec.rb
@@ -12,8 +12,8 @@
it "performs job" do
job = Qe::DelayedJob::Worker.new("SomeWorker", :a => 1)
- Qe::Worker
- .should_receive(:perform)
+ expect(Qe::Worker)
+ .to receive(:perform)
.with("SomeWorker", :a => 1)
job.perform
@@ -26,20 +26,20 @@
}
before do
- Delayed::Job.stub :enqueue
+ allow(Delayed::Job).to receive(:enqueue)
end
it "sets queue name" do
- Delayed::Job
- .should_receive(:enqueue)
+ expect(Delayed::Job)
+ .to receive(:enqueue)
.with(anything, :queue => "some_queue")
Qe::DelayedJob.enqueue(worker)
end
it "instantiates worker" do
- Qe::DelayedJob::Worker
- .should_receive(:new)
+ expect(Qe::DelayedJob::Worker)
+ .to receive(:new)
.with("SomeWorker", :a => 1)
Qe::DelayedJob.enqueue(worker, :a => 1)
@@ -47,10 +47,10 @@
it "enqueues job" do
job = double("job")
- Qe::DelayedJob::Worker.stub :new => job
+ expect(Qe::DelayedJob::Worker).to receive_messages(:new => job)
- Delayed::Job
- .should_receive(:enqueue)
+ expect(Delayed::Job)
+ .to receive(:enqueue)
.with(job, kind_of(Hash))
Qe::DelayedJob.enqueue(worker, :a => 1)
@@ -65,20 +65,20 @@
let(:date) { Time.now }
before do
- Delayed::Job.stub :enqueue
+ allow(Delayed::Job).to receive :enqueue
end
it "sets queue name" do
- Delayed::Job
- .should_receive(:enqueue)
+ expect(Delayed::Job)
+ .to receive(:enqueue)
.with(anything, hash_including(:queue => "some_queue"))
Qe::DelayedJob.schedule(worker, date, :a => 1)
end
it "instantiates worker" do
- Qe::DelayedJob::Worker
- .should_receive(:new)
+ expect(Qe::DelayedJob::Worker)
+ .to receive(:new)
.with("SomeWorker", :a => 1)
Qe::DelayedJob.schedule(worker, date, :a => 1)
@@ -86,10 +86,10 @@
it "schedules job" do
job = double("job")
- Qe::DelayedJob::Worker.stub :new => job
+ allow(Qe::DelayedJob::Worker).to receive_messages :new => job
- Delayed::Job
- .should_receive(:enqueue)
+ expect(Delayed::Job)
+ .to receive(:enqueue)
.with(job, hash_including(:run_at => date))
Qe::DelayedJob.schedule(worker, date, :a => 1)
View
12 spec/qe/immediate_spec.rb
@@ -4,8 +4,8 @@
let(:job) { double("job").as_null_object }
it "sets options" do
- HelloWorker
- .should_receive(:new)
+ expect(HelloWorker)
+ .to receive(:new)
.with(:a => 1)
.and_return(job)
@@ -13,8 +13,8 @@
end
it "performs job" do
- HelloWorker.stub :new => job
- job.should_receive(:perform)
+ allow(HelloWorker).to receive_messages :new => job
+ expect(job).to receive(:perform)
Qe::Immediate.enqueue(HelloWorker)
end
@@ -22,8 +22,8 @@
it "schedules job" do
date = Time.now
- Qe::Immediate
- .should_receive(:enqueue)
+ expect(Qe::Immediate)
+ .to receive(:enqueue)
.with(HelloWorker, :a => 1)
Qe::Immediate.schedule(HelloWorker, date, :a => 1)
View
4 spec/qe/locale_spec.rb
@@ -50,8 +50,8 @@
context "when performing" do
it "sets locale" do
- i18n
- .should_receive(:locale=)
+ expect(i18n)
+ .to receive(:locale=)
.with(:en)
LocalizedWorker.enqueue
View
10 spec/qe/qu_spec.rb
@@ -9,8 +9,8 @@
context "worker" do
it "performs job" do
- Qe::Worker
- .should_receive(:perform)
+ expect(Qe::Worker)
+ .to receive(:perform)
.with(:a, :b, :c)
Qe::Qu::Worker.perform(:a, :b, :c)
@@ -23,7 +23,7 @@
}
before do
- Qu.stub :enqueue
+ allow(Qu).to receive :enqueue
end
it "sets queue name" do
@@ -32,8 +32,8 @@
end
it "enqueues job" do
- ::Qu
- .should_receive(:enqueue)
+ expect(::Qu)
+ .to receive(:enqueue)
.with(Qe::Qu::Worker, "SomeWorker", :a => 1)
Qe::Qu.enqueue(worker, :a => 1)
View
16 spec/qe/resque_spec.rb
@@ -9,8 +9,8 @@
context "worker" do
it "performs job" do
- Qe::Worker
- .should_receive(:perform)
+ expect(Qe::Worker)
+ .to receive(:perform)
.with(:a, :b, :c)
Qe::Resque::Worker.perform(:a, :b, :c)
@@ -23,7 +23,7 @@
}
before do
- Resque.stub :enqueue
+ allow(Resque).to receive(:enqueue)
end
it "sets queue name" do
@@ -32,8 +32,8 @@
end
it "enqueues job" do
- ::Resque
- .should_receive(:enqueue)
+ expect(::Resque)
+ .to receive(:enqueue)
.with(Qe::Resque::Worker, "SomeWorker", :a => 1)
Qe::Resque.enqueue(worker, :a => 1)
@@ -48,7 +48,7 @@
}
before do
- Resque.stub :enqueue_at => nil, :remove_delayed => nil
+ allow(Resque).to receive_messages(:enqueue_at => nil, :remove_delayed => nil)
end
it "sets queue name" do
@@ -57,8 +57,8 @@
end
it "schedules job" do
- ::Resque
- .should_receive(:enqueue_at)
+ expect(::Resque)
+ .to receive(:enqueue_at)
.with(date, Qe::Resque::Worker, "SomeWorker", :a => 1)
Qe::Resque.schedule(worker, date, :a => 1)
View
28 spec/qe/sidekiq_spec.rb
@@ -13,8 +13,8 @@
end
it "performs job" do
- Qe::Worker
- .should_receive(:perform)
+ expect(Qe::Worker)
+ .to receive(:perform)
.with(:a, :b, :c)
Qe::Sidekiq::Worker.new.perform(:a, :b, :c)
@@ -27,21 +27,19 @@
}
before do
- Qe::Sidekiq::Worker.stub :perform_async
+ allow(Qe::Sidekiq::Worker).to receive :perform_async
end
it "sets queue name" do
- Qe::Sidekiq::Worker
- .should_receive(:sidekiq_options)
- .with(:queue => "some_queue")
+ expect(Qe::Sidekiq::Worker).to receive(:sidekiq_options)
+ .with(:queue => "some_queue")
Qe::Sidekiq.enqueue(worker)
end
it "enqueues job" do
- Qe::Sidekiq::Worker
- .should_receive(:perform_async)
- .with("SomeWorker", :a => 1)
+ expect(Qe::Sidekiq::Worker).to receive(:perform_async)
+ .with("SomeWorker", :a => 1)
Qe::Sidekiq.enqueue(worker, :a => 1)
end
@@ -53,13 +51,12 @@
}
before do
- Qe::Sidekiq::Worker.stub :perform_at
+ allow(Qe::Sidekiq::Worker).to receive(:perform_at)
end
it "sets queue name" do
- Qe::Sidekiq::Worker
- .should_receive(:sidekiq_options)
- .with(:queue => "some_queue")
+ expect(Qe::Sidekiq::Worker).to receive(:sidekiq_options)
+ .with(:queue => "some_queue")
Qe::Sidekiq.enqueue(worker)
end
@@ -67,9 +64,8 @@
it "schedules job" do
date = Time.now
- Qe::Sidekiq::Worker
- .should_receive(:perform_at)
- .with(date, "SomeWorker", :a => 1)
+ expect(Qe::Sidekiq::Worker).to receive(:perform_at)
+ .with(date, "SomeWorker", :a => 1)
Qe::Sidekiq.schedule(worker, date, :a => 1)
end
View
6 spec/qe/testing_spec.rb
@@ -23,10 +23,10 @@
Qe::Testing.enqueue(HelloWorker, a: 1)
instance = double.as_null_object
- instance.should_receive(:perform)
+ expect(instance).to receive(:perform)
- HelloWorker
- .should_receive(:new)
+ expect(HelloWorker)
+ .to receive(:new)
.with(a: 1)
.and_return(instance)
View
34 spec/qe/worker_spec.rb
@@ -20,8 +20,8 @@
it "delegates #enqueue to adapter" do
adapter = double("adapter")
- adapter
- .should_receive(:enqueue)
+ expect(adapter)
+ .to receive(:enqueue)
.with(HelloWorker, :a => 1)
Qe.adapter = adapter
@@ -32,8 +32,8 @@
it "delegates scheduling to adapter" do
adapter = double("adapter")
date = Time.now
- adapter
- .should_receive(:schedule)
+ expect(adapter)
+ .to receive(:schedule)
.with(HelloWorker, date, :a => 1)
Qe.adapter = adapter
@@ -50,8 +50,8 @@
describe "#perform" do
it "finds worker by its name" do
- Qe::Worker
- .should_receive(:find)
+ expect(Qe::Worker)
+ .to receive(:find)
.with("HelloWorker")
.and_return(HelloWorker)
@@ -59,8 +59,8 @@
end
it "initializes worker with provided options" do
- HelloWorker
- .should_receive(:new)
+ expect(HelloWorker)
+ .to receive(:new)
.with(:a => 1)
.and_return(double.as_null_object)
@@ -69,16 +69,16 @@
it "performs job" do
worker = HelloWorker.new({})
- HelloWorker.stub :new => worker
- worker.should_receive(:before).ordered
- worker.should_receive(:perform).ordered
- worker.should_receive(:after).ordered
+ allow(HelloWorker).to receive_messages :new => worker
+ expect(worker).to receive(:before).ordered
+ expect(worker).to receive(:perform).ordered
+ expect(worker).to receive(:after).ordered
Qe::Worker.perform("HelloWorker", {})
end
it "triggers default error handler" do
- HelloWorker.any_instance.stub(:perform).and_raise("ZOMG!")
+ allow_any_instance_of(HelloWorker).to receive(:perform).and_raise("ZOMG!")
expect {
Qe::Worker.perform("HelloWorker", {})
@@ -86,12 +86,12 @@
end
it "passes error object to error handler" do
- HelloWorker.any_instance
- .should_receive(:error)
+ expect_any_instance_of(HelloWorker)
+ .to receive(:error)
.with(kind_of(StandardError))
- HelloWorker.any_instance
- .stub(:perform)
+ allow_any_instance_of(HelloWorker)
+ .to receive(:perform)
.and_raise("ZOMG!")
Qe::Worker.perform("HelloWorker", {})
Please sign in to comment.
Something went wrong with that request. Please try again.