Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Switched to real Resque and fakeredis. #44

Open
wants to merge 4 commits into
base: master
from
Open
Changes from all commits
Commits
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

@@ -1,27 +1,76 @@
PATH
remote: .
specs:
resque_unit (0.4.8)
json (>= 1.4.6)
resque_unit (1.0.0.beta.2)
fakeredis
resque

GEM
remote: https://rubygems.org/
specs:
byebug (4.0.5)
columnize (= 0.9.0)
coderay (1.1.0)
columnize (0.9.0)
fakeredis (0.5.0)
redis (~> 3.0)
json (1.8.3)
method_source (0.8.2)
minitest (5.8.0)
mono_logger (1.1.0)
multi_json (1.11.2)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-byebug (3.1.0)
byebug (~> 4.0)
pry (~> 0.10)
rack (1.6.4)
rack-protection (1.5.3)
rack
rake (10.2.2)
rdoc (4.1.1)
json (~> 1.4)
redis (3.2.1)
redis-namespace (1.5.2)
redis (~> 3.0, >= 3.0.4)
resque (1.25.2)
mono_logger (~> 1.0)
multi_json (~> 1.0)
redis-namespace (~> 1.3)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
resque-scheduler (4.0.0)
mono_logger (~> 1.0)
redis (~> 3.0)
resque (~> 1.25)
rufus-scheduler (~> 3.0)
rufus-scheduler (3.0.9)
tzinfo
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
slop (3.6.0)
thread_safe (0.3.5)
tilt (2.0.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
vegas (0.1.11)
rack (>= 1.0.0)

PLATFORMS
ruby

DEPENDENCIES
bundler
minitest (~> 5.0)
pry-byebug
rake
rdoc
resque-scheduler
resque_unit!

BUNDLED WITH
1.10.5
1.10.6
@@ -3,20 +3,14 @@ ResqueUnit

ResqueUnit provides some extra assertions and a mock Resque for
testing Rails code that depends on Resque. You can install it as
either a gem or a plugin:
either a gem:

gem install resque_unit

and in your test.rb:

config.gem 'resque_unit'

If you'd rather install it as a plugin, you should be able to run

script/plugin install git://github.com/justinweiss/resque_unit.git

inside your Rails projects.

Examples
========

@@ -103,10 +97,6 @@ Caveats

* You should make sure that you call `Resque.reset!` in your test's
setup method to clear all of the test queues.
* Hooks support is optional. Just because you probably don't want to call
them during unit tests if they play with a DB. Call `Resque.enable_hooks!`
in your tests's setup method to enable hooks. To disable hooks, call
`Resque.disable_hooks!`.

Resque-Scheduler Support
========================
@@ -6,12 +6,9 @@ module ResqueUnit
rescue LoadError
require 'json'
end

require 'resque_unit/helpers'
require 'resque'
require 'resque_unit/resque'
require 'resque_unit/errors'
require 'resque_unit/assertions'
require 'resque_unit/plugin'

if defined?(Test::Unit::TestCase)
Test::Unit::TestCase.send(:include, ResqueUnit::Assertions)
@@ -8,14 +8,14 @@ module ResqueUnit::Assertions
# want to assert that klass has been queued without arguments. Pass a block
# if you want to assert something was queued within its execution.
def assert_queued(klass, args = nil, message = nil, &block)
queue_name = Resque.queue_for(klass)
queue_name = Resque.queue_from_class(klass)
assert_job_created(queue_name, klass, args, message, &block)
end
alias assert_queues assert_queued

# The opposite of +assert_queued+.
def assert_not_queued(klass = nil, args = nil, message = nil, &block)
queue_name = Resque.queue_for(klass)
queue_name = Resque.queue_from_class(klass)

queue = if block_given?
snapshot = Resque.size(queue_name)
@@ -31,9 +31,9 @@ def assert_not_queued(klass = nil, args = nil, message = nil, &block)

# Asserts no jobs were queued within the block passed.
def assert_nothing_queued(message = nil, &block)
snapshot = Resque.size
snapshot = total_job_count
yield
present = Resque.size
present = total_job_count
assert_equal snapshot, present, message || "No jobs should have been queued"
end

@@ -53,6 +53,11 @@ def assert_job_created(queue_name, klass, args = nil, message = nil, &block)

private

# The total count of all the jobs in Resque.
def total_job_count
Resque.queues.inject(0) { |acc, queue| acc + Resque.size(queue) }
end

# In Test::Unit, +assert_block+ displays only the message on a test
# failure and +assert+ always appends a message to the end of the
# passed-in assertion message. In MiniTest, it's the other way

This file was deleted.

This file was deleted.

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.