Skip to content

Commit

Permalink
Merge pull request Shopify#4 from lvenegas/master
Browse files Browse the repository at this point in the history
Update to get wolverine working with the redis gem (redis-rb)
  • Loading branch information
burke committed Jan 3, 2013
2 parents 6c73899 + ecb2831 commit 2660f8e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ return exists
4) Call wolverine from your code:

```ruby
Wolverine.util.mexists('key1', 'key2', 'key3') #=> [0, 1, 0]
Wolverine.util.mexists(['key1', 'key2', 'key3']) #=> [0, 1, 0]
```

Or

```ruby
Wolverine.util.mexists(:keys => ['key1', 'key2', 'key3']) #=> [0, 1, 0]
```

Methods are available on `Wolverine` paralleling the directory structure
Expand Down
4 changes: 2 additions & 2 deletions lib/wolverine/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def call redis, *args

def run_evalsha redis, *args
instrument :evalsha do
redis.evalsha @digest, args.size, *args
redis.evalsha @digest, *args
end
end

def run_eval redis, *args
instrument :eval do
redis.eval @content, args.size, *args
redis.eval @content, *args
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/integration/wolverine_integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class WolverineIntegrationTest < MiniTest::Unit::TestCase
def mock_redis
stub.tap do |redis|
redis.expects(:evalsha).
with('fe24f4dd4ba7881608cca4b846f009195e06d79a', 2, :a, :b).
with('fe24f4dd4ba7881608cca4b846f009195e06d79a', :a, :b).
raises("NOSCRIPT").once
redis.expects(:eval).
with(CONTENT, 2, :a, :b).
with(CONTENT, :a, :b).
returns([1, 0]).once
end
end
Expand Down
8 changes: 3 additions & 5 deletions test/wolverine/script_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_instrumentation
}
Wolverine.config.instrumentation = callback
redis = Class.new do
define_method(:evalsha) do |digest, size, *args|
define_method(:evalsha) do |digest, *args|
nil
end
end
Expand All @@ -53,9 +53,8 @@ def test_instrumentation
def test_call_with_cache_hit
tc = self
redis = Class.new do
define_method(:evalsha) do |digest, size, *args|
define_method(:evalsha) do |digest, *args|
tc.assert_equal DIGEST, digest
tc.assert_equal 2, size
tc.assert_equal [:a, :b], args
end
end
Expand All @@ -68,9 +67,8 @@ def test_call_with_cache_miss
define_method(:evalsha) do |*|
raise "NOSCRIPT No matching script. Please use EVAL."
end
define_method(:eval) do |content, size, *args|
define_method(:eval) do |content, *args|
tc.assert_equal CONTENT, content
tc.assert_equal 2, size
tc.assert_equal [:a, :b], args
end
end
Expand Down
2 changes: 1 addition & 1 deletion wolverine.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_runtime_dependency 'redis', '>= 2.2.2'
s.add_runtime_dependency 'redis', '>= 3.0.0'
s.add_development_dependency 'mocha', '~> 0.10.5'
s.add_development_dependency 'minitest', '~> 2.11.3'
s.add_development_dependency 'rake'
Expand Down

0 comments on commit 2660f8e

Please sign in to comment.