Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion progressrus.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "ruby-progressbar", "~> 1.0"

spec.add_development_dependency "rake"
spec.add_development_dependency "mocha", "~> 0.14"
spec.add_development_dependency "mocha", "~> 2.7"
spec.add_development_dependency "pry"
spec.add_development_dependency "byebug"
spec.add_development_dependency "pry-byebug"
Expand Down
3 changes: 1 addition & 2 deletions test/progressrus_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ def test_persist_yields_persist_to_each_store
end

def test_tick_and_complete_dont_raise_if_store_is_unavailable
store = Progressrus.stores[:redis]
store.redis.expects(:hset).at_least_once.raises(::Redis::BaseError)
Redis::PipelinedConnection.any_instance.expects(:hset).at_least_once.raises(::Redis::BaseError)
@progress.tick
@progress.complete
end
Expand Down
42 changes: 21 additions & 21 deletions test/store/redis_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ def self.call(scope)
end
end
def setup
@scope = ["walrus", "1234"]
@scope = ["walrus", "1234"]
@progress = Progressrus.new(
scope: @scope,
id: "oemg",
total: 100,
name: "oemg-name"
)

@another_progress = Progressrus.new(
@another_progress = Progressrus.new(
scope: @scope,
id: "oemg-two",
total: 100,
Expand All @@ -38,16 +38,16 @@ def test_prefix_can_be_a_proc
end

def test_persist_should_set_key_value_if_outdated
@store.persist(@progress)
@store.persist(@progress)

assert_equal 'oemg', @store.find(['walrus', '1234'], 'oemg').id
assert_equal 'oemg', @store.find(['walrus', '1234'], 'oemg').id
end

def test_persist_should_not_set_key_value_if_not_outdated
@store.redis.expects(:hset).once
Redis::PipelinedConnection.any_instance.expects(:hset).once

@store.persist(@progress)
@store.persist(@progress)
@store.persist(@progress)
@store.persist(@progress)
end

def test_scope_should_return_progressruses_indexed_by_id
Expand All @@ -62,7 +62,7 @@ def test_scope_should_return_progressruses_indexed_by_id
end

def test_scope_should_return_an_empty_hash_if_nothing_is_found
assert_equal({}, @store.scope(@scope))
assert_equal({}, @store.scope(@scope))
end

def test_find_should_return_a_single_progressrus_for_scope_and_id
Expand All @@ -73,41 +73,41 @@ def test_find_should_return_a_single_progressrus_for_scope_and_id
end

def test_find_should_return_nil_if_nothing_is_found
assert_nil @store.find(@scope, 'oemg')
assert_nil @store.find(@scope, 'oemg')
end

def test_flush_should_delete_by_scope
@store.persist(@progress)
@store.persist(@another_progress)
@store.persist(@progress)
@store.persist(@another_progress)

@store.flush(@scope)
@store.flush(@scope)

assert_equal({}, @store.scope(@scope))
assert_equal({}, @store.scope(@scope))
end

def test_flush_should_delete_by_scope_and_id
@store.persist(@progress)
@store.persist(@another_progress)
@store.persist(@progress)
@store.persist(@another_progress)

@store.flush(@scope, 'oemg')
@store.flush(@scope, 'oemg')

assert_nil @store.find(@scope, 'oemg')
assert @store.find(@scope, 'oemg-two')
assert_nil @store.find(@scope, 'oemg')
assert @store.find(@scope, 'oemg-two')
end

def test_initializes_name_to_redis
assert_equal :redis, @store.name
assert_equal :redis, @store.name
end

def test_persist_should_not_write_by_default
@store.redis.expects(:hset).once
Redis::PipelinedConnection.any_instance.expects(:hset).once

@store.persist(@progress)
@store.persist(@progress)
end

def test_persist_should_write_if_forced
@store.redis.expects(:hset).twice
Redis::PipelinedConnection.any_instance.expects(:hset).twice

@store.persist(@progress)
@store.persist(@progress, force: true)
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Coveralls.wear!

require 'minitest/autorun'
require "mocha/setup"
require 'mocha/minitest'
require 'pry'
require 'byebug'
require 'pry-byebug'
Expand Down
Loading