Skip to content

Commit

Permalink
Expose the clear method of strategy in Worker class
Browse files Browse the repository at this point in the history
  • Loading branch information
henrich-m committed Jun 25, 2018
1 parent af481a8 commit c1a6d3a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/upperkut/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module ClassMethods
extend Forwardable

def_delegators :setup, :strategy
def_delegators :strategy, :push_items, :size, :latency
def_delegators :strategy, :push_items, :size, :latency, :clear

def push_items(items)
strategy.push_items(items)
Expand Down
14 changes: 14 additions & 0 deletions spec/worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,18 @@ class DummyWorker

expect(items_saved).to eq(items)
end

describe '.clear' do
it 'clears the buffer completly' do
items = [
{ 'id' => 1, 'name' => 'Jose', 'role' => 'software engineer' },
{ 'id' => 2, 'name' => 'Paulo', 'role' => 'QA engineer' },
{ 'id' => 3, 'name' => 'Mario', 'role' => 'Tech Leader' }
]

DummyWorker.push_items(items)

expect { DummyWorker.clear }.to change { DummyWorker.size }.from(3).to(0)
end
end
end

0 comments on commit c1a6d3a

Please sign in to comment.