Skip to content
This repository has been archived by the owner on Oct 5, 2018. It is now read-only.

Commit

Permalink
Merge pull request #164 from morgoth/rm-redis-dependency-from-tests
Browse files Browse the repository at this point in the history
Use fakeredis for tests to not require Redis server running
  • Loading branch information
ScotterC committed Feb 11, 2016
2 parents 520e179 + f8c88bd commit c9bd7fd
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 18 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Expand Up @@ -14,9 +14,6 @@ gemfile:

sudo: false

services:
- redis

script: "bundle exec rake clean spec"

notifications:
Expand Down
3 changes: 0 additions & 3 deletions CONTRIBUTING
Expand Up @@ -8,9 +8,6 @@ Testing

Please don't commit code without tests. You can bootstrap the development environment by running `bundle install`. After that, running `rake` should just work. If it doesn't then file a bug.

Dependencies for Testing:
- Redis. You need redis. For linux users, you can install the redis-server package and roll, Mac users will need to install it with homebrew, and I'm not entirely sure how to make it work with Windows users.

Versioning
=========

Expand Down
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -286,8 +286,7 @@ Yes.
Contributing
------------

Checkout out CONTRIBUTING. In short, you’ll need a redis server running
for testing. Run all tests with
Checkout out CONTRIBUTING. Run all tests with

````
# Rspec on all versions
Expand Down
4 changes: 2 additions & 2 deletions delayed_paperclip.gemspec
Expand Up @@ -19,13 +19,13 @@ Gem::Specification.new do |s|
s.add_development_dependency 'delayed_job'
s.add_development_dependency 'delayed_job_active_record'
s.add_development_dependency 'resque'
s.add_development_dependency 'sidekiq', '< 3.0'
s.add_development_dependency 'sidekiq', '>= 4.0'
s.add_development_dependency 'appraisal'
s.add_development_dependency 'rake'
s.add_development_dependency 'bundler'
s.add_development_dependency 'railties'
s.add_development_dependency 'fakeredis'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
end

17 changes: 9 additions & 8 deletions spec/integration/sidekiq_spec.rb
@@ -1,12 +1,14 @@
require 'spec_helper'
require 'sidekiq/api'
require 'sidekiq/testing'

describe "Sidekiq" do

before :all do
Sidekiq.logger.level = Logger::ERROR
DelayedPaperclip.options[:background_job_class] = DelayedPaperclip::Jobs::Sidekiq
Sidekiq::Queue.new(:paperclip).clear
end

before :each do
Sidekiq::Queues["paperclip"].clear
end

let(:dummy) { Dummy.new(:image => File.open("#{ROOT}/spec/fixtures/12k.png")) }
Expand All @@ -30,19 +32,18 @@
end

def process_jobs
Sidekiq::Queue.new(:paperclip).each do |job|
worker = job.klass.constantize.new
args = job.args
Sidekiq::Queues["paperclip"].each do |job|
worker = job["class"].constantize.new
args = job["args"]
begin
worker.perform(*args)
rescue # Assume sidekiq handle exception properly
end
job.delete
end
end

def jobs_count
Sidekiq::Queue.new(:paperclip).size
Sidekiq::Queues["paperclip"].size
end

end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Expand Up @@ -6,6 +6,7 @@
require 'active_support'
require 'active_support/core_ext'
require 'rspec'
require 'fakeredis/rspec'
require 'mocha/api'
begin
require 'active_job'
Expand Down

0 comments on commit c9bd7fd

Please sign in to comment.