Skip to content

Commit

Permalink
Fix keyword arguments and stream specs (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmthomas authored Nov 26, 2020
1 parent e82b205 commit 5393610
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ gem 'overcommit', '0.53.0'
# Pin tool versions (which are executed by Overcommit) for Travis builds
gem 'rubocop', '0.82.0'

gem 'ruby2_keywords'

gem 'coveralls', require: false
2 changes: 1 addition & 1 deletion lib/mock_redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def respond_to?(method, include_private = false)
super || @db.respond_to?(method, include_private)
end

def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
@db.send(method, *args, &block)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/mock_redis/expire_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(db)
@db = db
end

def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
@db.expire_keys
@db.send(method, *args, &block)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/mock_redis/geospatial_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module GeospatialMethods
D_R = Math::PI / 180.0
EARTH_RADIUS_IN_METERS = 6_372_797.560856

def geoadd(key, *args)
ruby2_keywords def geoadd(key, *args)
points = parse_points(args)

scored_points = points.map do |point|
Expand Down
2 changes: 1 addition & 1 deletion lib/mock_redis/multi_db_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def respond_to?(method, include_private = false)
super || current_db.respond_to?(method, include_private)
end

def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
current_db.send(method, *args, &block)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/mock_redis/pipelined_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def initialize_copy(source)
@pipelined_futures = @pipelined_futures.clone
end

def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
if in_pipeline?
future = MockRedis::Future.new([method, *args], block)
@pipelined_futures << future
Expand Down
2 changes: 1 addition & 1 deletion lib/mock_redis/transaction_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(db)
@multi_block_given = false
end

def method_missing(method, *args, &block)
ruby2_keywords def method_missing(method, *args, &block)
if in_multi?
future = MockRedis::Future.new([method, *args], block)
@transaction_futures << future
Expand Down
4 changes: 3 additions & 1 deletion spec/commands/del_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
end

before :each do
@redises._gsub(/\d{3}-\d/, '...-.')
# TODO: Redis appears to be returning a timestamp a few seconds in the future
# so we're ignoring the last 5 digits (time in milliseconds)
@redises._gsub(/\d{5}-\d/, '...-.')
end

it 'returns the number of keys deleted' do
Expand Down
5 changes: 4 additions & 1 deletion spec/commands/xadd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
end

before :each do
@redises._gsub(/\d{3}-\d/, '...-.')
# TODO: Redis appears to be returning a timestamp a few seconds in the future
# so we're ignoring the last 5 digits (time in milliseconds)
@redises._gsub(/\d{5}-\d/, '....-.')
end

it 'returns an id based on the timestamp' do
t = Time.now.to_i
id = @redises.xadd(@key, key: 'value')
expect(@redises.xadd(@key, key: 'value')).to match(/#{t}\d{3}-0/)
end

Expand Down
4 changes: 3 additions & 1 deletion spec/commands/xlen_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
end

before :each do
@redises._gsub(/\d{3}-\d/, '...-.')
# TODO: Redis appears to be returning a timestamp a few seconds in the future
# so we're ignoring the last 5 digits (time in milliseconds)
@redises._gsub(/\d{5}-\d/, '...-.')
end

it 'returns the number of items in the stream' do
Expand Down
2 changes: 1 addition & 1 deletion spec/support/redis_multiplexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _gsub_clear
@gsub_from = @gsub_to = ''
end

def method_missing(method, *args, &blk)
ruby2_keywords def method_missing(method, *args, &blk)
# If we're in a Redis command that accepts a block, and we execute more
# redis commands, ONLY execute them on the Redis implementation that the
# block came from.
Expand Down

0 comments on commit 5393610

Please sign in to comment.