Skip to content

Commit

Permalink
Remove sample method from specs, added deterministic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JonaMX committed Oct 24, 2016
1 parent 59ef94f commit 1033054
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions spec/resque_spec/matchers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -459,20 +459,32 @@
let(:interval) { 10 * 60 }
let(:scheduled_at) { Time.now + 30 * 60 }

before(:each) do
if [true, false].sample
context "scheduling with #enqueu_in" do
before(:each) do
Resque.enqueue_in(interval, Person, first_name, last_name)
else
Resque.enqueue_at(scheduled_at, Person, first_name, last_name)
end
end

it "returns true if arguments, timestamp or interval matches positive expectation" do
Person.should have_scheduled(first_name, last_name).at_or_in(scheduled_at, interval)
it "returns true if arguments, timestamp or interval matches positive expectation" do
Person.should have_scheduled(first_name, last_name).at_or_in(scheduled_at, interval)
end

it "returns true if arguments, timestamp, and interval matches negative expectation" do
Person.should_not have_scheduled(first_name, last_name).at_or_in(Time.now + 60 * 60, 100 * 60)
end
end

it "returns true if arguments, timestamp, and interval matches negative expectation" do
Person.should_not have_scheduled(first_name, last_name).at_or_in(Time.now + 60 * 60, 100 * 60)
context "scheduling with #enqueu_at" do
before(:each) do
Resque.enqueue_at(scheduled_at, Person, first_name, last_name)
end

it "returns true if arguments, timestamp or interval matches positive expectation" do
Person.should have_scheduled(first_name, last_name).at_or_in(scheduled_at, interval)
end

it "returns true if arguments, timestamp, and interval matches negative expectation" do
Person.should_not have_scheduled(first_name, last_name).at_or_in(Time.now + 60 * 60, 100 * 60)
end
end
end

Expand Down

0 comments on commit 1033054

Please sign in to comment.