gouda 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,51 @@
1
+ module AssertHelper
2
+ # Same as "assert_changes" in Rails but for countable entities.
3
+ # @return [*] return value of the block
4
+ # @example
5
+ # assert_changes_by("Notification.count", exactly: 2) do
6
+ # cause_two_notifications_to_get_delivered
7
+ # end
8
+ def assert_changes_by(expression, message = nil, exactly: nil, at_least: nil, at_most: nil, &block)
9
+ # rubocop:disable Security/Eval
10
+ exp = expression.respond_to?(:call) ? expression : -> { eval(expression.to_s, block.binding) }
11
+ # rubocop:enable Security/Eval
12
+
13
+ raise "either exactly:, at_least: or at_most: must be specified" unless exactly || at_least || at_most
14
+ raise "exactly: is mutually exclusive with other options" if exactly && (at_least || at_most)
15
+ raise "at_most: must be larger than at_least:" if at_least && at_most && at_most < at_least
16
+
17
+ before = exp.call
18
+ retval = assert_nothing_raised(&block)
19
+
20
+ after = exp.call
21
+ delta = after - before
22
+
23
+ if exactly
24
+ at_most = exactly
25
+ at_least = exactly
26
+ end
27
+
28
+ # We do not make these an if/else since we allow both at_most and at_least
29
+ if at_most
30
+ error = "#{expression.inspect} changed by #{delta} which is more than #{at_most}"
31
+ error = "#{error}. It was #{before} and became #{after}"
32
+ error = "#{message.call}.\n" if message&.respond_to?(:call)
33
+ error = "#{message}.\n#{error}" if message && !message.respond_to?(:call)
34
+ assert delta <= at_most, error
35
+ end
36
+
37
+ if at_least
38
+ error = "#{expression.inspect} changed by #{delta} which is less than #{at_least}"
39
+ error = "#{error}. It was #{before} and became #{after}"
40
+ error = "#{message.call}.\n" if message&.respond_to?(:call)
41
+ error = "#{message}.\n#{error}" if message && !message.respond_to?(:call)
42
+ assert delta >= at_least, error
43
+ end
44
+
45
+ retval
46
+ end
47
+
48
+ def assert_same_set(exp, act, msg = nil)
49
+ assert_equal(exp.to_set, act.to_set, msg)
50
+ end
51
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gouda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian van Hesteren
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-06-11 00:00:00.000000000 Z
12
+ date: 2024-06-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -157,6 +157,14 @@ files:
157
157
  - lib/gouda/version.rb
158
158
  - lib/gouda/worker.rb
159
159
  - lib/gouda/workload.rb
160
+ - test/gouda/concurrency_extension_test.rb
161
+ - test/gouda/gouda_test.rb
162
+ - test/gouda/scheduler_test.rb
163
+ - test/gouda/seconds_to_start_distribution.csv
164
+ - test/gouda/test_helper.rb
165
+ - test/gouda/worker_test.rb
166
+ - test/gouda/workload_test.rb
167
+ - test/support/assert_helper.rb
160
168
  - tmp/.keep
161
169
  homepage: https://rubygems.org/gems/gouda
162
170
  licenses:
@@ -180,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
188
  - !ruby/object:Gem::Version
181
189
  version: '0'
182
190
  requirements: []
183
- rubygems_version: 3.5.9
191
+ rubygems_version: 3.5.11
184
192
  signing_key:
185
193
  specification_version: 4
186
194
  summary: Job Scheduler