lml / lev

Ride the rails but don't touch them.
MIT License
2 stars 6 forks source link

Specific statuses #43

Closed karenc closed 8 years ago

karenc commented 8 years ago

Changes taken from lml/lev#40 with better commit history.

Small changes I've made to the original branch:

diff --git a/lev.gemspec b/lev.gemspec
index f1373ab..36b41c0 100644
--- a/lev.gemspec
+++ b/lev.gemspec
@@ -30,7 +30,6 @@ Gem::Specification.new do |spec|
   spec.add_development_dependency "sqlite3"
   spec.add_development_dependency "debugger"
   spec.add_development_dependency "activejob"
-  spec.add_development_dependency "debugger"

   ## workaround for an issue using activerecord 4.2 outside of rails
   spec.add_development_dependency "rails"
diff --git a/spec/background_job_spec.rb b/spec/background_job_spec.rb
index d8958bf..af7ba2e 100644
--- a/spec/background_job_spec.rb
+++ b/spec/background_job_spec.rb
@@ -105,13 +105,14 @@ describe Lev::BackgroundJob do
     let!(:job) { described_class.create }

     it 'finds jobs that are in the store' do
+      expect(described_class.store).to_not receive(:write)
       found_job = described_class.find(job.id)
       expect(found_job.as_json).to eq(job.as_json)
     end

     it 'returns nil for jobs not in the store' do
       found_job = described_class.find('not-a-real-id')
-      expect(found_job.as_json).to eq nil
+      expect(found_job).to be_nil
     end
   end

diff --git a/spec/statused_routines_spec.rb b/spec/statused_routines_spec.rb
index 58c3a49..2264e6f 100644
--- a/spec/statused_routines_spec.rb
+++ b/spec/statused_routines_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe 'Statused Routines' do
   context 'in a routine' do
     it 'queues the job object on queue' do
       id = StatusedRoutine.perform_later
-      job = Lev::BackgroundJob.find!(id)
+      job = Lev::BackgroundJob.find(id)

       expect(job.status).to eq(Lev::BackgroundJob::STATE_QUEUED)
     end
@@ -31,7 +31,7 @@ RSpec.describe 'Statused Routines' do

       it 'completes the job object on completion, returning other data' do
         id = StatusedRoutine.perform_later
-        job = Lev::BackgroundJob.find!(id)
+        job = Lev::BackgroundJob.find(id)
         expect(job.status).to eq(Lev::BackgroundJob::STATE_SUCCEEDED)
         expect(job.progress).to eq(1.0)
       end