bean_counter 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,26 +25,25 @@ class BeanCounter::Strategy
25
25
  @@strategies = {}
26
26
 
27
27
 
28
- # Maintain an index of classes known to subclass Strategy.
28
+ # Used to maintain an index of classes known to subclass Strategy.
29
29
  def self.inherited(subclass)
30
30
  identifier = subclass.name || subclass.to_s[8, subclass.to_s.length - 9]
31
31
  @@strategies[identifier.to_sym] = subclass
32
32
  end
33
33
 
34
34
 
35
- # :call-seq:
36
- # known_strategy?(strategy_identifier) => Boolean
37
- #
38
- # Determines if the provided +strategy_identifer+ corresponds to a known
39
- # subclass of strategy. The provided +strategy_identifer+ can be a class
40
- # or any object that responds to :to_sym. Classes are compared directly.
35
+ # Determines if the provided `strategy_identifer` corresponds to a known
36
+ # subclass of strategy. The provided `strategy_identifer` can be a class
37
+ # or any object that implements :to_sym. Classes are compared directly.
41
38
  # For non-class objects that respond to :to_sym, the symbolized form
42
- # of +strategy_identifer+ is used as a key to attempt to retrieve a strategy
39
+ # of `strategy_identifer` is used as a key to attempt to retrieve a strategy
43
40
  # from the strategies Hash.
44
41
  #
45
- # Returns true if +strategy_identifier+ isa known strategy or maps to a known
46
- # strategy. Otherwise, false is returned.
47
- #
42
+ # @param strategy_identifier [Object] A class or any Object that implements
43
+ # :to_sym
44
+ # @return [Boolean] Returns true if `strategy_identifier` is a known
45
+ # strategy or maps to a known strategy. Otherwise, false is returned.
46
+ # @example
48
47
  # BeanCounter::Strategy.known_strategy?(Object)
49
48
  # #=> false
50
49
  #
@@ -59,16 +58,18 @@ class BeanCounter::Strategy
59
58
  end
60
59
 
61
60
 
62
- # :call-seq:
63
- # materialize_strategy(strategy_identifier) => subclass of Strategy
64
- #
65
- # Materialize the provided +strategy_identifier+ into a subclass of Strategy.
66
- # If +strategy_identifer+ is already a subclass of Strategy,
67
- # +strategy_identifier+ is returned. Otherwise, +strategy_identifer+ is
61
+ # Materialize the provided `strategy_identifier` into a subclass of Strategy.
62
+ # If `strategy_identifer` is already a subclass of Strategy,
63
+ # `strategy_identifier` is returned. Otherwise, `strategy_identifer` is
68
64
  # converted into a Symbol and is used as a key to retrieve a strategy from
69
- # the known subclasses of Strategy. If +strategy_identifier does not map to
65
+ # the known subclasses of Strategy. If `strategy_identifier` does not map to
70
66
  # a known subclass of Strategy, an ArgumentError is raised.
71
67
  #
68
+ # @param strategy_identifier [Object] A class or any Object that implements
69
+ # :to_sym
70
+ # @return [BeanCounter::Strategy] The strategy the given `strategy_identifier`
71
+ # was materialized into
72
+ # @example
72
73
  # BeanCounter::Strategy.materialize_strategy(:'BeanCounter::Strategy::StalkClimberStrategy')
73
74
  # #=> BeanCounter::Strategy::StalkClimberStrategy
74
75
  def self.materialize_strategy(strategy_identifier)
@@ -82,27 +83,30 @@ class BeanCounter::Strategy
82
83
  end
83
84
 
84
85
 
85
- # :call-seq:
86
- # strategies() => Hash
87
- #
88
86
  # Returns a list of known classes that inherit from BeanCounter::Strategy.
89
87
  # Typically this list represents the strategies available for interacting
90
88
  # with beanstalkd.
89
+ #
90
+ # @return [Array<BeanCounter::Strategy>] A list of classes known to inherit
91
+ # from BeanCounter::Strategy.
91
92
  def self.strategies
92
93
  return @@strategies.dup
93
94
  end
94
95
 
95
96
 
96
- # :call-seq:
97
- # collect_new_jobs { block } => Array[Strategy Job]
98
- #
99
97
  # Provide a means of collecting jobs enqueued during the execution of the
100
- # provided +block+. Returns an Array of Jobs as implemented by the Strategy.
98
+ # provided `block`. Returns an Array of Jobs as implemented by the Strategy.
101
99
  #
102
100
  # Used internally to reduce the set of jobs that must be examined to evaluate
103
101
  # the truth of an assertion to only those enqueued during the evaluation of
104
- # the given +block+.
105
- #
102
+ # the given `block`.
103
+ #
104
+ # @abstract Subclasses must override to implement
105
+ # @yield Nothing yielded to provided block
106
+ # @yieldreturn [void] No specific value is expected from provided block
107
+ # @return [Array<Strategy::Job>] Returns an Array of Jobs as implemented by
108
+ # the Strategy.
109
+ # @example
106
110
  # new_jobs = strategy.collect_new_jobs do
107
111
  # ...
108
112
  # end
@@ -112,45 +116,54 @@ class BeanCounter::Strategy
112
116
  end
113
117
 
114
118
 
115
- # :call-seq:
116
- # delete_job(job) => Boolean
117
- #
118
119
  # Provide a means for deleting a job specific to the job interface used by
119
- # the strategy. Should return true if the job was deleted successfully or
120
- # no longer exists and false if the job could not be deleted.
120
+ # the strategy.
121
+ # Should return true if the job was deleted successfully or no longer exists
122
+ # and false if the job could not be deleted.
121
123
  #
122
124
  # Used internally to delete a job, allowing the beanstalkd pool to be reset.
123
125
  #
124
- # strategy.delete_job(job)
125
- # #=> true
126
+ # @abstract Subclasses must override to implement
127
+ # @param job [Strategy::Job] The job to be deleted.
128
+ # @return [Boolean] True if the job was deleted successfully or no longer
129
+ # exists, false if the job could not be deleted.
130
+ # @example
131
+ # strategy.delete_job(job)
132
+ # #=> true
126
133
  def delete_job
127
134
  raise NotImplementedError
128
135
  end
129
136
 
130
137
 
131
- # :call-seq:
132
- # job_matches?(job, options => {Symbol,String => Numeric,Proc,Range,Regexp,String}) => Boolean
133
- #
134
- # Returns a boolean indicating whether or not the provided +job+ matches the
135
- # given Hash of +options. Each _key_ in +options+ is a String or a Symbol that
136
- # identifies an attribute of +job+ that the corresponding _value_ should be
137
- # compared against. True is returned if every _value_ in +options+ evaluates to
138
- # true when compared to the attribute of +job+ identified by the corresponding
139
- # _key_. False is returned if any of the comparisons evaluates to false.
138
+ # Returns a boolean indicating whether or not the provided `job` matches the
139
+ # given Hash of `options`. Each `key` in `options` is a String or a Symbol that
140
+ # identifies an attribute of `job` that the corresponding `value` should be
141
+ # compared against. True is returned if every `value` in `options` evaluates to
142
+ # true when compared to the attribute of `job` identified by the corresponding
143
+ # `key`. False is returned if any of the comparisons evaluates to false.
140
144
  #
141
145
  # If no options are given, returns true for any job that exists at the time of
142
146
  # evaluation.
143
147
  #
144
- # Each attribute comparison is performed using the triple equal (===)
145
- # operator/method of _value_ with the attribute of +job+ identified by _key_
148
+ # Each attribute comparison is performed using the triple-equal (===)
149
+ # operator/method of `value` with the attribute of `job` identified by `key`
146
150
  # passed into the method. Use of === allows for more complex comparisons
147
151
  # using Procs, Ranges, Regexps, etc.
148
152
  #
149
- # Consult MATCHABLE_JOB_ATTRIBUTES for a list of which attributes of +job+
153
+ # Consult {MATCHABLE_JOB_ATTRIBUTES} for a list of which attributes of `job`
150
154
  # can be matched against.
151
155
  #
152
156
  # Used internally to evaluate if a job matches an assertion.
153
157
  #
158
+ # @abstract Subclasses must override to implement
159
+ # @param job [Strategy::Job] The job to evaluate for a match.
160
+ # @param options [Hash{Symbol, String => Numeric, Proc, Range, Regexp, String, Symbol}]
161
+ # Options used to evaluate match.
162
+ # @return [Boolean] True if every value of the `options` Hash evaluates to
163
+ # true when comared to the attribute of `job` identified by the
164
+ # corresponding key. False is returned if any of the comparisons evaluates
165
+ # to false.
166
+ # @example
154
167
  # strategy.job_matches?(reserved_job, :state => 'reserved')
155
168
  # #=> true
156
169
  #
@@ -164,65 +177,75 @@ class BeanCounter::Strategy
164
177
  end
165
178
 
166
179
 
167
- # :call-seq:
168
- # jobs() => Enumerator
169
- #
170
- # Returns an Enumerator providing a means to enumerate all jobs in the beanstalkd
171
- # pool.
180
+ # Returns an Enumerator providing a means to enumerate all jobs in the
181
+ # Beanstalkd pool.
172
182
  #
173
183
  # Used internally to enumerate all jobs to find jobs matching an assertion.
184
+ #
185
+ # @abstract Subclasses must override to implement
186
+ # @return [Enumerator<Strategy::Job>] An Enumerator of all jobs in the
187
+ # Beanstalkd pool
174
188
  def jobs
175
189
  raise NotImplementedError
176
190
  end
177
191
 
178
192
 
179
- # :call-seq:
180
- # pretty_print_job(job) => String
181
- #
182
- # Returns a String representation of +job+ in a pretty, human readable
183
- # format.
193
+ # Returns a String representation of `job` in a pretty, human-readable
194
+ # format.
184
195
  #
185
196
  # Used internally to print a job when an assertion fails.
197
+ #
198
+ # @abstract Subclasses must override to implement
199
+ # @param job [Strategy::Job] The job to represent in a pretty, human-readable
200
+ # format
201
+ # @return [String] `job` in a more human-readable format
186
202
  def pretty_print_job
187
203
  raise NotImplementedError
188
204
  end
189
205
 
190
206
 
191
- # :call-seq:
192
- # pretty_print_tube(tube) => String
193
- #
194
- # Returns a String representation of the tube in a pretty, human readable
195
- # format. Used internally to print a tube when an assertion fails.
207
+ # Returns a String representation of the tube in a pretty, human-readable
208
+ # format.
196
209
  #
197
210
  # Used internally to print a tube when an assertion fails.
211
+ #
212
+ # @abstract Subclasses must override to implement
213
+ # @param tube [Strategy::Tube] The tube to represent in a pretty, human-readable
214
+ # format
215
+ # @return [String] `tube` in a more human-readable format.
198
216
  def pretty_print_tube
199
217
  raise NotImplementedError
200
218
  end
201
219
 
202
-
203
- # :call-seq:
204
- # tube_matches?(tube, options => {Symbol,String => Numeric,Proc,Range,Regexp,String}) => Boolean
205
- #
206
- # Returns a boolean indicating whether or not the provided +tube+ matches the
207
- # given Hash of +options. Each _key_ in +options+ is a String or a Symbol that
208
- # identifies an attribute of +tube+ that the corresponding _value_ should be
209
- # compared against. True is returned if every _value_ in +options+ evaluates to
210
- # true when compared to the attribute of +tube+ identified by the corresponding
211
- # _key_. False is returned if any of the comparisons evaluates to false.
220
+ # Returns a boolean indicating whether or not the provided `tube` matches the
221
+ # given Hash of `options`. Each `key` in `options` is a String or a Symbol that
222
+ # identifies an attribute of `tube` that the corresponding `value` should be
223
+ # compared against. True is returned if every `value` in `options` evaluates to
224
+ # true when compared to the attribute of `tube` identified by the corresponding
225
+ # `key`. False is returned if any of the comparisons evaluates to false.
212
226
  #
213
227
  # If no options are given, returns true for any tube that exists at the time of
214
228
  # evaluation.
215
229
  #
216
- # Each attribute comparison is performed using the triple equal (===)
217
- # operator/method of _value_ with the attribute of +job+ identified by _key_
230
+ # Each attribute comparison is performed using the triple-equal (===)
231
+ # operator/method of `value` with the attribute of `job` identified by `key`
218
232
  # passed into the method. Use of === allows for more complex comparisons using
219
233
  # Procs, Ranges, Regexps, etc.
220
234
  #
221
- # Consult MATCHABLE_TUBE_ATTRIBUTES for a list of which attributes of +tube+
235
+ # Consult {MATCHABLE_TUBE_ATTRIBUTES} for a list of which attributes of `tube`
222
236
  # can be matched against.
223
237
  #
224
238
  # Used internally to evaluate if a tube matches an assertion.
225
239
  #
240
+ # @abstract Subclasses must override to implement
241
+ # @param tube [Strategy::Tube] The tube to evaluate for a match.
242
+ # @param options [Hash{Symbol, String => Numeric, Proc, Range, Regexp, String, Symbol}]
243
+ # Options used to evaluate match.
244
+ # @return [Boolean] True if every value of the `options` Hash evaluates to
245
+ # true when comared to the attribute of `tube` identified by the
246
+ # corresponding key. False is returned if any of the comparisons evaluates
247
+ # to false.
248
+ # @example
226
249
  # strategy.tube_matches?(paused_tube, :state => 'paused')
227
250
  # #=> true
228
251
  #
@@ -236,13 +259,14 @@ class BeanCounter::Strategy
236
259
  end
237
260
 
238
261
 
239
- # :call-seq:
240
- # tubes() => Enumerator
241
- #
242
262
  # Returns an Enumerator providing a means to enumerate all tubes in the beanstalkd
243
263
  # pool.
244
264
  #
245
265
  # Used internally to enumerate all tubes to find tubes matching an assertion.
266
+ #
267
+ # @abstract Subclasses must override to implement
268
+ # @return [Enumerator<Strategy::Tube>] An Enumerator of all tubes in the
269
+ # Beanstalkd pool
246
270
  def tubes
247
271
  raise NotImplementedError
248
272
  end
@@ -1,32 +1,41 @@
1
1
  module BeanCounter::TestAssertions
2
2
 
3
- # :call-seq:
4
- # assert_enqueued(options = {Symbol,String => Numeric,Proc,Range,Regexp,String})
5
- #
6
3
  # Asserts that some number of jobs are enqueued that match the given Hash of
7
- # +options+. If no +options+ are given, asserts that at least one job exists.
4
+ # `options`. If no `options` are given, asserts that at least one job exists.
8
5
  #
9
- # Each _key_ in +options+ is a String or a Symbol that identifies an attribute
10
- # of a job that the corresponding _value_ should be compared against. All attribute
11
- # comparisons are performed using the triple equal (===) operator/method of
12
- # the given _value_.
6
+ # Each `key` in `options` is a String or a Symbol that identifies an attribute
7
+ # of a job that the corresponding `value` should be compared against. All attribute
8
+ # comparisons are performed using the triple-equal (===) operator/method of
9
+ # the given `value`.
13
10
  #
14
- # +options+ may additionally include a _count_ key of 'count' or :count that
11
+ # `options` may additionally include a `count` key ('count' or :count) that
15
12
  # can be used to assert that a particular number of matching jobs are found.
16
13
  #
17
- # If no _count_ option is provided, the assertion succeeds if any job is found
18
- # that matches all of the +options+ given. If no jobs are found that match the
19
- # +options+ given, the assertion fails.
14
+ # If no `count` option is provided, the assertion succeeds if any job is found
15
+ # that matches all of the `options` given. If no jobs are found that match the
16
+ # `options` given, the assertion fails.
20
17
  #
21
- # If a _count_ option is provided the assertion only succeeds if the triple equal
22
- # (===) operator/method of the value of _count_ evaluates to true when given the
18
+ # If a `count` option is provided the assertion only succeeds if the triple-equal
19
+ # (===) operator/method of the value of `count` evaluates to true when given the
23
20
  # total number of matching jobs. Otherwise the assertion fails. The use of ===
24
21
  # allows for more advanced comparisons using Procs, Ranges, Regexps, etc.
25
22
  #
26
- # See Strategy#job_matches? and/or the #job_matches? method of the strategy
27
- # in use for more detailed information on how it is determined whether or not
28
- # a job matches the given +options+.
29
- #
23
+ # See {BeanCounter::Strategy::MATCHABLE_JOB_ATTRIBUTES} for a list of what
24
+ # attributes can be used when matching.
25
+ #
26
+ # See {BeanCounter::Strategy#job_matches?} and/or the #job_matches? method of
27
+ # the strategy in use for more detailed information on how it is determined
28
+ # whether or not a job matches the given `options`.
29
+ #
30
+ # @see BeanCounter::Strategy::MATCHABLE_JOB_ATTRIBUTES
31
+ # @see BeanCounter::Strategy#job_matches?
32
+ # @param options
33
+ # [Hash{String, Symbol => Numeric, Proc, Range, Regexp, String, Symbol}]
34
+ # Options expected when evaluating match assertion.
35
+ # @option options [Numeric, Range] :count (nil) A particular number of matching
36
+ # jobs expected
37
+ # @return [true] if the assertion succeeds
38
+ # @example
30
39
  # assert_enqueued
31
40
  #
32
41
  # assert_enqueued(:body => /test/, :count => 5)
@@ -37,40 +46,51 @@ module BeanCounter::TestAssertions
37
46
  end
38
47
 
39
48
 
40
- # :call-seq:
41
- # assert_enqueues(options = {Symbol,String => Numeric,Proc,Range,Regexp,String}) { block }
49
+ # Asserts that the provided `block` enqueues some number of jobs that match
50
+ # the given Hash of `options`. If no `options` are given, asserts that at
51
+ # least one job is enqueued during the execution of the `block`.
42
52
  #
43
- # Asserts that the given +block+ enqueues some number of jobs that match the
44
- # given Hash of +options+. If no +options+ are given, asserts that at least
45
- # one job is enqueued during the execution of the +block+.
46
- #
47
- # Unlike #assert_enqueued, which will evaluate all jobs in the beanstalkd pool,
53
+ # Unlike {#assert_enqueued}, which will evaluate all jobs in the Beanstalkd pool,
48
54
  # this method will only evaluate jobs that were enqueued during the
49
- # execution of the given +block+. This can be useful for performance and for
55
+ # execution of the given `block`. This can be useful for performance and for
50
56
  # making assertions that could return false positives if all jobs were
51
57
  # evaluated.
52
58
  #
53
- # Each _key_ in +options+ is a String or a Symbol that identifies an attribute
54
- # of a job that the corresponding _value_ should be compared against. All attribute
55
- # comparisons are performed using the triple equal (===) operator/method of
56
- # the given _value_.
59
+ # Each `key` in `options` is a String or a Symbol that identifies an attribute
60
+ # of a job that the corresponding `value` should be compared against. All attribute
61
+ # comparisons are performed using the triple-equal (===) operator/method of
62
+ # the given `value`.
57
63
  #
58
- # +options+ may additionally include a _count_ key of 'count' or :count that
64
+ # `options` may additionally include a `count` key ('count' or :count) that
59
65
  # can be used to assert that a particular number of matching jobs are found.
60
66
  #
61
- # If no _count_ option is provided, the assertion succeeds if any job is found
62
- # that matches all of the +options+ given. If no jobs are found that match the
63
- # +options+ given, the assertion fails.
67
+ # If no `count` option is provided, the assertion succeeds if any job is found
68
+ # that matches all of the `options` given. If no jobs are found that match the
69
+ # `options` given, the assertion fails.
64
70
  #
65
- # If a _count_ option is provided the assertion only succeeds if the triple equal
66
- # (===) operator/method of the value of _count_ evaluates to true when given the
71
+ # If a `count` option is provided the assertion only succeeds if the triple-equal
72
+ # (===) operator/method of the value of `count` evaluates to true when given the
67
73
  # total number of matching jobs. Otherwise the assertion fails. The use of ===
68
74
  # allows for more advanced comparisons using Procs, Ranges, Regexps, etc.
69
75
  #
70
- # See Strategy#job_matches? and/or the #job_matches? method of the strategy
71
- # in use for more detailed information on how it is determined whether or not
72
- # a job matches the given +options+.
73
- #
76
+ # See {BeanCounter::Strategy::MATCHABLE_JOB_ATTRIBUTES} for a list of what
77
+ # attributes can be used when matching.
78
+ #
79
+ # See {BeanCounter::Strategy#job_matches?} and/or the #job_matches? method of
80
+ # the strategy in use for more detailed information on how it is determined
81
+ # whether or not a job matches the given `options`.
82
+ #
83
+ # @see BeanCounter::Strategy::MATCHABLE_JOB_ATTRIBUTES
84
+ # @see BeanCounter::Strategy#job_matches?
85
+ # @param options
86
+ # [Hash{String, Symbol => Numeric, Proc, Range, Regexp, String, Symbol}]
87
+ # Options expected when evaluating match assertion.
88
+ # @option options [Numeric, Range] :count (nil) A particular number of matching
89
+ # jobs expected
90
+ # @yield No value is yielded to the provided block.
91
+ # @raise [ArgumentError] if no block is given.
92
+ # @return [true] if the assertion succeeds
93
+ # @example
74
94
  # assert_enqueues(:body => /test/) do
75
95
  # enqueue_some_jobs
76
96
  # end
@@ -81,26 +101,32 @@ module BeanCounter::TestAssertions
81
101
  end
82
102
 
83
103
 
84
- # :call-seq:
85
- # assert_tube(options = {Symbol,String => Numeric,Proc,Range,Regexp,String})
86
- #
87
104
  # Asserts that at least one tube exist that matches the given Hash of
88
- # +options+. If no +options+ are given, asserts that at least one tube exists,
105
+ # `options`. If no `options` are given, asserts that at least one tube exists,
89
106
  # which will always succeed.
90
107
  #
91
- # Each _key_ in +options+ is a String or a Symbol that identifies an attribute
92
- # of a tube that the corresponding _value_ should be compared against. All attribute
93
- # comparisons are performed using the triple equal (===) operator/method of
94
- # the given _value_.
108
+ # Each `key` in `options` is a String or a Symbol that identifies an attribute
109
+ # of a tube that the corresponding `value` should be compared against. All attribute
110
+ # comparisons are performed using the triple-equal (===) operator/method of
111
+ # the given `value`.
95
112
  #
96
113
  # The assertion succeeds if any tube exists that matches all of the given
97
- # +options+. If no tube exists matching all of the given +options+, the assertion
114
+ # `options`. If no tube exists matching all of the given `options`, the assertion
98
115
  # fails.
99
116
  #
100
- # See Strategy#tube_matches? and/or the #tube_matches? method of the strategy
101
- # in use for more detailed information on how it is determined whether or not
102
- # a tube matches the given +options+.
117
+ # See {BeanCounter::Strategy::MATCHABLE_TUBE_ATTRIBUTES} for a list of those
118
+ # attributes that can be used when matching.
119
+ #
120
+ # See {BeanCounter::Strategy#tube_matches?} and/or the #tube_matches? method of
121
+ # the strategy in use for more detailed information on how it is determined
122
+ # whether or not a tube matches the given `options`.
103
123
  #
124
+ # @see BeanCounter::Strategy::MATCHABLE_TUBE_ATTRIBUTES
125
+ # @see BeanCounter::Strategy#tube_matches?
126
+ # @param options [Hash{Symbol, String => Numeric, Proc, Range, Regexp, String, Symbol}]
127
+ # Options expected when evaluating match assertion.
128
+ # @return [true] if the assertion succeeds
129
+ # @example
104
130
  # assert_tube
105
131
  #
106
132
  # assert_tube(:name => /test/)
@@ -111,24 +137,31 @@ module BeanCounter::TestAssertions
111
137
  end
112
138
 
113
139
 
114
- # :call-seq:
115
- # refute_enqueued(options = {Symbol,String => Numeric,Proc,Range,Regexp,String})
140
+ # Asserts that no jobs are enqueued that match the given Hash of `options`.
141
+ # If no `options` are given, asserts that no jobs exist.
116
142
  #
117
- # Asserts that no jobs are enqueued that match the given Hash of +options+.
118
- # If no +options+ are given, asserts that no jobs exist.
143
+ # Each `key` in `options` is a String or a Symbol that identifies an attribute
144
+ # of a job that the corresponding `value` should be compared against. All attribute
145
+ # comparisons are performed using the triple-equal (===) operator/method of
146
+ # the given `value`.
119
147
  #
120
- # Each _key_ in +options+ is a String or a Symbol that identifies an attribute
121
- # of a job that the corresponding _value_ should be compared against. All attribute
122
- # comparisons are performed using the triple equal (===) operator/method of
123
- # the given _value_.
124
- #
125
- # The refutation succeeds if no jobs are found that match all of the +options+
148
+ # The refutation succeeds if no jobs are found that match all of the `options`
126
149
  # given. If any matching jobs are found, the refutation fails.
127
150
  #
128
- # See Strategy#job_matches? and/or the #job_matches? method of the strategy
129
- # in use for more detailed information on how it is determined whether or not
130
- # a job matches the given +options+.
151
+ # See {BeanCounter::Strategy::MATCHABLE_JOB_ATTRIBUTES} for a list of what
152
+ # attributes can be used when matching.
153
+ #
154
+ # See {BeanCounter::Strategy#job_matches?} and/or the #job_matches? method of
155
+ # the strategy in use for more detailed information on how it is determined
156
+ # whether or not a job matches the given `options`.
131
157
  #
158
+ # @see BeanCounter::Strategy::MATCHABLE_JOB_ATTRIBUTES
159
+ # @see BeanCounter::Strategy#job_matches?
160
+ # @param options
161
+ # [Hash{String, Symbol => Numeric, Proc, Range, Regexp, String, Symbol}]
162
+ # Options expected when evaluating match assertion.
163
+ # @return [false] if the refutation succeeds
164
+ # @example
132
165
  # refute_enqueued
133
166
  #
134
167
  # refute_enqueued(:body => lambda {|body| body.length > 50})
@@ -139,31 +172,39 @@ module BeanCounter::TestAssertions
139
172
  end
140
173
 
141
174
 
142
- # :call-seq:
143
- # refute_enqueues(options = {Symbol,String => Numeric,Proc,Range,Regexp,String}) { block }
175
+ # Asserts that the given `block` enqueues no jobs that match the given Hash
176
+ # of `options`. If no `options` are given, asserts that no job are enqueued
177
+ # by the given `block`.
144
178
  #
145
- # Asserts that the given +block+ enqueues no jobs that match the given Hash
146
- # of +options+. If no +options+ are given, asserts that no job are enqueued
147
- # by the given +block+.
148
- #
149
- # Unlike #refute_enqueued, which will evaluate all jobs in the beanstalkd pool,
179
+ # Unlike {#refute_enqueued}, which will evaluate all jobs in the beanstalkd pool,
150
180
  # this method will only evaluate jobs that were enqueued during the
151
- # execution of the given +block+. This can be useful for performance and for
181
+ # execution of the given `block`. This can be useful for performance and for
152
182
  # making assertions that could return false positives if all jobs were
153
183
  # evaluated.
154
184
  #
155
- # Each _key_ in +options+ is a String or a Symbol that identifies an attribute
156
- # of a job that the corresponding _value_ should be compared against. All attribute
157
- # comparisons are performed using the triple equal (===) operator/method of
158
- # the given _value_.
185
+ # Each `key` in `options` is a String or a Symbol that identifies an attribute
186
+ # of a job that the corresponding `value` should be compared against. All attribute
187
+ # comparisons are performed using the triple-equal (===) operator/method of
188
+ # the given `value`.
159
189
  #
160
- # The refutation succeeds if no jobs are found that match all of the +options+
190
+ # The refutation succeeds if no jobs are found that match all of the `options`
161
191
  # given. If any matching jobs are found, the refutation fails.
162
192
  #
163
- # See Strategy#job_matches? and/or the #job_matches? method of the strategy
164
- # in use for more detailed information on how it is determined whether or not
165
- # a job matches the given +options+.
166
- #
193
+ # See {BeanCounter::Strategy::MATCHABLE_JOB_ATTRIBUTES} for a list of what
194
+ # attributes can be used when matching.
195
+ #
196
+ # See {BeanCounter::Strategy#job_matches?} and/or the #job_matches? method of
197
+ # the strategy in use for more detailed information on how it is determined
198
+ # whether or not a job matches the given `options`.
199
+ #
200
+ # @see BeanCounter::Strategy::MATCHABLE_JOB_ATTRIBUTES
201
+ # @see BeanCounter::Strategy#job_matches?
202
+ # @param options
203
+ # [Hash{String, Symbol => Numeric, Proc, Range, Regexp, String, Symbol}]
204
+ # Options expected when evaluating match assertion.
205
+ # @yield The provided block is given no parameters.
206
+ # @return [false] if the refutation succeeds
207
+ # @example
167
208
  # refute_enqueues do
168
209
  # do_some_work_that_should_not_enqueue_any_jobs
169
210
  # end
@@ -174,25 +215,34 @@ module BeanCounter::TestAssertions
174
215
  end
175
216
 
176
217
 
177
- # :call-seq:
178
- # refute_tube(options = {Symbol,String => Numeric,Proc,Range,Regexp,String})
179
- #
180
- # Asserts that no tube exist that matches the given Hash of +options+.
218
+ # Asserts that no tube exist that matches the given Hash of `options`.
181
219
  # If no options are given, asserts that no tubes exist which will always fail.
182
220
  #
183
- # Each _key_ in +options+ is a String or a Symbol that identifies an attribute
184
- # of a tube that the corresponding _value_ should be compared against. All attribute
185
- # comparisons are performed using the triple equal (===) operator/method of
186
- # the given _value_.
221
+ # Each `key` in `options` is a String or a Symbol that identifies an attribute
222
+ # of a tube that the corresponding `value` should be compared against. All attribute
223
+ # comparisons are performed using the triple-equal (===) operator/method of
224
+ # the given `value`.
187
225
  #
188
226
  # The refutation succeeds if no tube exists that matches all of the given
189
- # +options+. If any tubes exist that match all of the given +options+, the
227
+ # `options`. If any tubes exist that match all of the given `options`, the
190
228
  # refutation fails.
191
229
  #
192
- # See Strategy#tube_matches? and/or the #tube_matches? method of the strategy
193
- # in use for more detailed information on how it is determined whether or not
194
- # a tube matches the given +options+.
230
+ # See {BeanCounter::Strategy::MATCHABLE_TUBE_ATTRIBUTES} for a list of those
231
+ # attributes that can be used when matching.
195
232
  #
233
+ # See {BeanCounter::Strategy#tube_matches?} and/or the #tube_matches? method of the strategy
234
+ # in use for more detailed information on how it is determined whether or not
235
+ # a tube matches the given `options`.
236
+ #
237
+ # @see BeanCounter::Strategy::MATCHABLE_TUBE_ATTRIBUTES
238
+ # @see BeanCounter::Strategy#job_matches?
239
+ # @param options
240
+ # [Hash{String, Symbol => Numeric, Proc, Range, Regexp, String, Symbol}]
241
+ # Options expected when evaluating match assertion.
242
+ # @option options [Numeric, Range] :count (nil) A particular number of matching
243
+ # jobs expected
244
+ # @return [false] if the refutation succeeds
245
+ # @example
196
246
  # refute_tube
197
247
  # #=> always fails
198
248
  #
@@ -206,8 +256,8 @@ module BeanCounter::TestAssertions
206
256
  private
207
257
 
208
258
 
209
- # Builds job expectation object, evaluates and makes appropriate assertion
210
- # with appropriate failure message
259
+ # Builds job expectation object, evaluates, and makes appropriate assertion
260
+ # with appropriate failure message.
211
261
  def enqueue_expectation(assertion_method, options, &block)
212
262
  message_type = assertion_method == :assert ? :failure_message : :negative_failure_message
213
263
  expectation = BeanCounter::EnqueuedExpectation.new(options)
@@ -216,8 +266,8 @@ module BeanCounter::TestAssertions
216
266
  end
217
267
 
218
268
 
219
- # Builds tube expectation object, evaluates and makes appropriate assertion
220
- # with appropriate failure message
269
+ # Builds tube expectation object, evaluates, and makes appropriate assertion
270
+ # with appropriate failure message.
221
271
  def tube_expectation(assertion_method, message_type, options)
222
272
  expectation = BeanCounter::TubeExpectation.new(options)
223
273
  match = expectation.matches?