Skip to content

Commit

Permalink
make specs less coupled with implementation details
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgi committed Sep 24, 2024
1 parent 837b94e commit 63ce836
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ group :test do

gem 'pry'
gem 'pg_examiner', '~> 0.5.2'

gem 'timecop', '~> 0.9.10'
end

gemspec
5 changes: 3 additions & 2 deletions spec/que/poller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,9 @@ def assert_poll(priorities:, locked:)
result = poller.poll(priorities: { 500 => 7 }, held_locks: Set.new)
assert_equal job_ids, result.map(&:id)

poller.instance_variable_set(:@next_poll_at, Time.now)
assert_equal true, poller.should_poll?
Timecop.freeze(Time.now + 30) do
assert_equal true, poller.should_poll?
end
end
end
end
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
require 'minitest/hooks'
require 'minitest/profile'

# "time travel" capabilities.
require 'timecop'
Timecop.safe_mode = true

# Other support stuff.
Dir['./spec/support/**/*.rb'].sort.each(&method(:require))

Expand Down

0 comments on commit 63ce836

Please sign in to comment.