Skip to content

Commit 38801ac

Browse files
author
Povilas Jurcys
committed
Include more negotate test examples
1 parent fb996b7 commit 38801ac

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

spec/rspec/rails/matchers/active_job_spec.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,34 @@ def self.name; "LoggingJob"; end
106106
}.to raise_error(/expected to enqueue exactly 1 jobs, but enqueued 2/)
107107
end
108108

109+
110+
it "shows correct fail message when negated with at_least matcher" do
111+
expect {
112+
expect {
113+
heavy_lifting_job.perform_later
114+
heavy_lifting_job.perform_later
115+
}.not_to have_enqueued_job.at_least(2)
116+
}.to raise_error(/expected not to enqueue at least 2 jobs, but enqueued 2/)
117+
end
118+
119+
it "shows correct fail message when negated with at_most matcher" do
120+
expect {
121+
expect {
122+
heavy_lifting_job.perform_later
123+
heavy_lifting_job.perform_later
124+
}.not_to have_enqueued_job.at_most(2)
125+
}.to raise_error(/expected not to enqueue at most 2 jobs, but enqueued 2/)
126+
end
127+
128+
it "fails when too many jobs enqueued in negated form" do
129+
expect {
130+
expect {
131+
heavy_lifting_job.perform_later
132+
heavy_lifting_job.perform_later
133+
}.not_to have_enqueued_job.exactly(2)
134+
}.to raise_error(/expected not to enqueue exactly 2 jobs, but enqueued 2/)
135+
end
136+
109137
it "reports correct number in fail error message" do
110138
heavy_lifting_job.perform_later
111139
expect {

0 commit comments

Comments
 (0)