Permalink
Browse files

Rename Job.mock to Job.build.

It's not really a true mock object. It's just building a true Job instance w/o needing all attributes specified.
  • Loading branch information...
1 parent 82859f3 commit c1a96680f00e2bc896e646a3b52726a478fcbe14 @myronmarston myronmarston committed Apr 20, 2012
Showing with 9 additions and 9 deletions.
  1. +1 −1 lib/qless/job.rb
  2. +6 −6 spec/unit/job_spec.rb
  3. +2 −2 spec/unit/worker_spec.rb
View
@@ -13,7 +13,7 @@ def perform
klass.perform(self)
end
- def self.mock(client, klass, attributes = {})
+ def self.build(client, klass, attributes = {})
defaults = {
"jid" => Qless.generate_jid,
"data" => {},
View
@@ -10,26 +10,26 @@ class Nested
let(:client) { stub.as_null_object }
- describe ".mock" do
+ describe ".build" do
it 'creates a job instance' do
- Job.mock(client, JobClass).should be_a(Job)
+ Job.build(client, JobClass).should be_a(Job)
end
it 'honors attributes passed as a symbol' do
- job = Job.mock(client, JobClass, data: { "a" => 5 })
+ job = Job.build(client, JobClass, data: { "a" => 5 })
job.data.should eq("a" => 5)
end
end
describe "#perform" do
it 'calls the #perform method on the job class with the job as an argument' do
- job = Job.mock(client, JobClass)
+ job = Job.build(client, JobClass)
JobClass.should_receive(:perform).with(job).once
job.perform
end
it 'properly finds nested classes' do
- job = Job.mock(client, JobClass::Nested)
+ job = Job.build(client, JobClass::Nested)
JobClass::Nested.should_receive(:perform).with(job).once
job.perform
end
@@ -42,7 +42,7 @@ class Nested
[:move, 'queue']
].each do |meth, *args|
describe "##{meth}" do
- let(:job) { Job.mock(client, JobClass) }
+ let(:job) { Job.build(client, JobClass) }
it 'updates #state_changed? from false to true' do
expect {
View
@@ -10,7 +10,7 @@ module Qless
describe "#perform" do
class MyJobClass; end
- let(:job) { Job.mock(client, MyJobClass) }
+ let(:job) { Job.build(client, MyJobClass) }
it 'performs the job' do
MyJobClass.should_receive(:perform)
@@ -64,7 +64,7 @@ def self.perform(job)
end
let(:output_file) { File.join(temp_dir, "job.out.#{Time.now.to_i}") }
- let(:job) { Job.mock(client, FileWriterJob, data: { 'file' => output_file }) }
+ let(:job) { Job.build(client, FileWriterJob, data: { 'file' => output_file }) }
let(:temp_dir) { "./spec/tmp" }
before do

0 comments on commit c1a9668

Please sign in to comment.