bean_counter 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/.yardopts +7 -0
  2. data/README.md +70 -47
  3. data/lib/bean_counter/version.rb +1 -1
  4. metadata +17 -5
  5. checksums.yaml +0 -15
@@ -0,0 +1,7 @@
1
+ --output-dir doc/
2
+ --readme README.md
3
+ --title BeanCounter
4
+ --markup=markdown
5
+ --protected
6
+ --private
7
+ lib/bean_counter/**/*.rb
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # BeanCounter
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/bean_counter.png)](http://badge.fury.io/rb/bean_counter)
3
4
  [![Build Status](https://secure.travis-ci.org/gemeraldbeanstalk/bean_counter.png)](http://travis-ci.org/gemeraldbeanstalk/bean_counter)
4
5
  [![Dependency Status](https://gemnasium.com/gemeraldbeanstalk/bean_counter.png)](https://gemnasium.com/gemeraldbeanstalk/bean_counter)
5
6
  [![Coverage Status](https://coveralls.io/repos/gemeraldbeanstalk/bean_counter/badge.png?branch=master)](https://coveralls.io/r/gemeraldbeanstalk/bean_counter)
@@ -8,50 +9,61 @@
8
9
  BeanCounter provides additional TestUnit/MiniTest assertions and/or RSpec matchers for testing Ruby code that relies on
9
10
  [Beaneater](https://github.com/beanstalkd/beaneater) and [Beanstalkd](https://github.com/kr/beanstalkd).
10
11
 
11
- ##### TestUnit/MiniTest Assertions
12
+ ## Assertions/Matchers
13
+ ### TestUnit/MiniTest Assertions
12
14
  For TestUnit/MiniTest, BeanCounter provides 6 assertions/refutations
13
15
  for use in your tests:
14
- - ```assert_enqueued/refute_enqueued``` - Searches all jobs in the beanstalkd
16
+
17
+ - `assert_enqueued/refute_enqueued` - Searches all jobs in the beanstalkd
15
18
  pool for jobs with attributes matching the keys/values of the Hash given
16
- - ```assert_enqueues/refute_enqueues``` - Searches only those jobs in the
19
+ - `assert_enqueues/refute_enqueues` - Searches only those jobs in the
17
20
  beanstalkd pool enqueued during the execution of the provided block for jobs
18
21
  with attributes matching the keys/values of the Hash given
19
- - ```assert_tube/refute_tube``` - Searches all tubes in the beanstalkd pool
22
+ - `assert_tube/refute_tube` - Searches all tubes in the beanstalkd pool
20
23
  for a tube with attributes matching the keys/values of a given Hash
21
24
 
22
- BeanCounter also provides a helper, ```BeanCounter.reset!``` to reset a given tube or
25
+ BeanCounter also provides a helper, `BeanCounter.reset!` to reset a given tube or
23
26
  the entire beanstalkd pool by deleting the appropriate jobs.
24
27
 
25
- ##### RSpec Matchers
28
+ ### RSpec Matchers
26
29
  For RSpec, BeanCounter provides 2 equivalent should/should_not matchers for use in your specs:
27
- - ```have_enqueued``` - Searches for jobs in the beanstalkd
30
+
31
+ - `have_enqueued` - Searches for jobs in the beanstalkd
28
32
  pool with attributes matching the keys/values of the Hash given.
29
33
  If called on a block only inspects jobs enqueued during the execution of
30
34
  the block. Otherwise, inspects all jobs.
31
- - ```have_tube``` - Searches all tubes in the beanstalkd pool
35
+ - `have_tube` - Searches all tubes in the beanstalkd pool
32
36
  for a tube with attributes matching the keys/values of a given Hash
33
37
 
34
- BeanCounter also provides a helper, ```BeanCounter.reset!``` to reset a given tube or
38
+ BeanCounter also provides a helper, `BeanCounter.reset!` to reset a given tube or
35
39
  the entire beanstalkd pool by deleting the appropriate jobs.
36
40
 
37
41
  ## Installation
38
42
 
39
43
  Add this line to your application's Gemfile:
40
44
 
41
- gem 'bean_counter'
45
+ ```ruby
46
+ gem 'bean_counter'
47
+ ```
42
48
 
43
49
  And then execute:
44
50
 
45
- $ bundle
51
+ ```
52
+ $ bundle
53
+ ```
46
54
 
47
55
  Or install it without bundler:
48
56
 
49
- $ gem install bean_counter
57
+ ```
58
+ $ gem install bean_counter
59
+ ```
60
+
50
61
 
51
62
  ## Test Framework Configuration
52
63
  #### TestUnit/MiniTest
53
64
  In order to use BeanCounter in your tests you'll need to require and configure
54
65
  it in your test_helper:
66
+
55
67
  ```ruby
56
68
  # To make the assertions available to all test cases you can require one of the
57
69
  # following in test/test_helper.rb:
@@ -91,6 +103,7 @@ end
91
103
  #### RSpec
92
104
  In order to use BeanCounter in your specs you'll need to require and configure
93
105
  it in your spec_helper:
106
+
94
107
  ```ruby
95
108
  # To make the BeanCounter matchers available to all specs, require
96
109
  # bean_counter/spec in spec/spec_helper.rb:
@@ -122,25 +135,28 @@ Beyond the configuration required to utilize BeanCounter with your test
122
135
  framework, BeanCounter may also require other test framework agnostic
123
136
  configuration to work properly or as desired.
124
137
 
125
- #####BeanCounter.beanstalkd_url
126
- ```BeanCounter.beanstalkd_url``` allows you to directly provide a string or an
138
+ ###BeanCounter.beanstalkd_url
139
+
140
+ `BeanCounter.beanstalkd_url` allows you to directly provide a string or an
127
141
  Array of strings that will be used by BeanCounter when communicating with the
128
142
  beanstalkd pool. By default, BeanCounter will try to intelligently determine
129
143
  the location of beanstalkd servers by checking for configuration in a few
130
144
  different places, though in some cases special configuration may be required.
131
145
 
132
146
  First, and of higest precedence, BeanCounter will check
133
- ```ENV['BEANSTALKD_URL']``` for a comma separated list of beanstalkd
147
+ `ENV['BEANSTALKD_URL']` for a comma separated list of beanstalkd
134
148
  servers. If no evironment variable is found, any value provided for
135
- ```BeanCounter.beanstalkd_url``` will be used to connect to the the beanstalkd pool.
149
+ `BeanCounter.beanstalkd_url` will be used to connect to the the beanstalkd pool.
136
150
  Finally, if no environment variable is found and no value has been provided for
137
151
  BeanCounter.beanstalkd_url, BeanCounter will try to use any configuration
138
152
  provided to Beaneater. If no beanstalkd_url can be determined, a Runtime error
139
153
  will be raised.
140
154
 
141
155
  Beanstalkd urls can be provided in any of the variety of formats shown below:
142
- ```
143
- $ BEANSTALKD_URL='127.0.0.1,beanstalk://localhost:11300,localhost:11301' rake test
156
+
157
+ ```ruby
158
+ # Started with environment variable:
159
+ # BEANSTALKD_URL='127.0.0.1,beanstalk://localhost:11300,localhost:11301' rake test
144
160
  BeanCounter.beanstalkd_url
145
161
  #=> ['127.0.0.1', 'beanstalk://localhost:11300', 'localhost:11301']
146
162
 
@@ -153,8 +169,8 @@ BeanCounter.beanstalkd_url
153
169
  #=> ['127.0.0.1', 'beanstalk://localhost:11300', 'localhost:11301']
154
170
  ```
155
171
 
156
- #####BeanCounter.strategy
157
- ```BeanCounter.strategy``` allows you to choose and configure the strategy
172
+ ###BeanCounter.strategy
173
+ `BeanCounter.strategy` allows you to choose and configure the strategy
158
174
  BeanCounter uses for accessing and interacting with the beanstalkd pool. At
159
175
  present, there is only a single strategy available, but at least one other is
160
176
  in the works.
@@ -176,15 +192,16 @@ identifies an attribute of a job that the corresponding Hash value should be
176
192
  compared against. All attribute comparisons are performed using the triple-equal
177
193
  (===) operator/method of the given value.
178
194
 
179
- #####assert_enqueued/have_enqueued
180
- The attributes available on a job for comparison are: ```age```, ```body```,
181
- ```buries```, ```connection```, ```delay```, ```id```, ```kicks```, ```pri```,
182
- ```releases```, ```reserves```, ```state```, ```time-left```, ```timeouts```,
183
- ```ttr```, and ```tube```.
195
+ ###assert_enqueued/have_enqueued
196
+ The attributes available on a job for comparison are: `age`, `body`,
197
+ `buries`, `connection`, `delay`, `id`, `kicks`, `pri`,
198
+ `releases`, `reserves`, `state`, `time-left`, `timeouts`,
199
+ `ttr`, and `tube`.
184
200
 
185
201
  To assert or set the expectation that a job with the body of 'foo'
186
202
  should have been enqueued on the default tube you could use the following:
187
- ```
203
+
204
+ ```ruby
188
205
  # TestUnit/MiniTest
189
206
  assert_enqueued(:tube => 'default', :body => 'foo')
190
207
 
@@ -193,13 +210,14 @@ should have been enqueued on the default tube you could use the following:
193
210
  should have_enqueued(:tube => 'default', :body => /foo/)
194
211
  ```
195
212
 
196
- #####assert_enqueues/have_enqueued
213
+ ###assert_enqueues/have_enqueued
197
214
  The assert_enqueues assertion and the have_enqueued matcher also support a
198
215
  block form that will only check jobs enqueued during the execution of the given
199
216
  block for matches. For example, if you wanted to assert or set the expectation
200
217
  that a particular method caused a job to be enqueued to the exports tube in the
201
218
  ready state, you could use something like the following:
202
- ```
219
+
220
+ ```ruby
203
221
  # TestUnit/MiniTest
204
222
  assert_enqueues(:tube => 'exports', :state => 'ready') do
205
223
  method_that_should_enqueue_a_job
@@ -212,7 +230,8 @@ ready state, you could use something like the following:
212
230
  ```
213
231
 
214
232
  The refutations/negative matches work the same way:
215
- ```
233
+
234
+ ```ruby
216
235
  # TestUnit/MiniTest
217
236
  refute_enqueues(:tube => 'exports', :state => 'ready') do
218
237
  method_that_should_not_enqueue_a_job
@@ -237,7 +256,8 @@ triple-equal (===) operator/method of the value of the provided count evaluates
237
256
  to true when given the total number of matching jobs. Otherwise the assertion
238
257
  fails. The use of === allows for more advanced comparisons using Procs, Ranges,
239
258
  Regexps, etc.
240
- ```
259
+
260
+ ```ruby
241
261
  # TestUnit/MiniTest
242
262
  assert_enqueues(:tube => 'default', :body => 'foo', :count => 1) do
243
263
  method_that_should_enqueue_exactly_one_job
@@ -253,23 +273,24 @@ Regexps, etc.
253
273
  A count key can also be used with the refutations/negative matches, but tends
254
274
  to be better stated as an assertion/positive match with a count.
255
275
 
256
- #####assert_tube/have_tube
276
+ ###assert_tube/have_tube
257
277
  Similar to the other assertions/matchers, assert_tube and have_tube take a Hash
258
278
  of options that will be used to find matching tubes. Each key in the options
259
279
  Hash is a String or a Symbol that identifies an attribute of a tube that the
260
280
  corresponding Hash value should be compared against. All attribute comparisons
261
281
  are performed using the triple-equal (===) operator/method of the given value.
262
282
 
263
- The attributes available on a tube for matching are: ```cmd-delete```,
264
- ```cmd-pause-tube```, ```current-jobs-buried```, ```current-jobs-delayed```,
265
- ```current-jobs-ready```, ```current-jobs-reserved```,
266
- ```current-jobs-urgent```, ```current-using```, ```current-waiting```,
267
- ```current-watching```, ```name```, ```pause```, ```pause-time-left```,
268
- and ```total-jobs```.
283
+ The attributes available on a tube for matching are: `cmd-delete`,
284
+ `cmd-pause-tube`, `current-jobs-buried`, `current-jobs-delayed`,
285
+ `current-jobs-ready`, `current-jobs-reserved`,
286
+ `current-jobs-urgent`, `current-using`, `current-waiting`,
287
+ `current-watching`, `name`, `pause`, `pause-time-left`,
288
+ and `total-jobs`.
269
289
 
270
290
  For example to assert that no connections are waiting on the default tube
271
291
  something like the following could be used:
272
- ```
292
+
293
+ ```ruby
273
294
  # TestUnit/MiniTest
274
295
  assert_tube(:name => 'default', 'current-waiting' => 0)
275
296
 
@@ -279,7 +300,8 @@ something like the following could be used:
279
300
 
280
301
  Similarly one could use refute_tube or the negative matcher for have_tube to
281
302
  verify that the exports tube is paused:
282
- ```
303
+
304
+ ```ruby
283
305
  # TestUnit/MiniTest
284
306
  refute_tube(:name => 'exports', :pause => 0)
285
307
 
@@ -288,14 +310,15 @@ verify that the exports tube is paused:
288
310
  ```
289
311
 
290
312
  For more detailed explanations and more examples make sure to check out the
291
- docs, expectations, and respective tests:
292
- [docs](http://rubydoc.info/gems/bean_counter/0.0.2/frames)
293
- [enqueued_expectation](https://github.com/gemeraldbeanstalk/bean_counter/tree/master/lib/bean_counter/enqueued_expectation.rb)
294
- [tube_expectation](https://github.com/gemeraldbeanstalk/bean_counter/tree/master/lib/bean_counter/tube_expectation.rb)
295
- [test_assertions](https://github.com/gemeraldbeanstalk/bean_counter/tree/master/lib/bean_counter/test_assertions.rb)
296
- [spec_matchers](https://github.com/gemeraldbeanstalk/bean_counter/tree/master/lib/bean_counter/spec_matchers.rb)
297
- [test_assertions_test](https://github.com/gemeraldbeanstalk/bean_counter/tree/master/test/unit/test_assertions_test.rb)
298
- [spec_spec](https://github.com/gemeraldbeanstalk/bean_counter/tree/master/spec/spec_spec.rb)
313
+ docs, expectations, and respective tests:
314
+
315
+ - [docs](http://rubydoc.info/gems/bean_counter/0.0.3/frames)
316
+ - [enqueued_expectation](https://github.com/gemeraldbeanstalk/bean_counter/tree/master/lib/bean_counter/enqueued_expectation.rb)
317
+ - [tube_expectation](https://github.com/gemeraldbeanstalk/bean_counter/tree/master/lib/bean_counter/tube_expectation.rb)
318
+ - [test_assertions](https://github.com/gemeraldbeanstalk/bean_counter/tree/master/lib/bean_counter/test_assertions.rb)
319
+ - [spec_matchers](https://github.com/gemeraldbeanstalk/bean_counter/tree/master/lib/bean_counter/spec_matchers.rb)
320
+ - [test_assertions_test](https://github.com/gemeraldbeanstalk/bean_counter/tree/master/test/unit/test_assertions_test.rb)
321
+ - [spec_spec](https://github.com/gemeraldbeanstalk/bean_counter/tree/master/spec/spec_spec.rb)
299
322
 
300
323
  ## Contributing
301
324
 
@@ -1,4 +1,4 @@
1
1
  module BeanCounter
2
2
  # BeanCounter version number
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bean_counter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - gemeraldbeanstalk
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-12-11 00:00:00.000000000 Z
12
+ date: 2013-12-15 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: beaneater
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ! '>='
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ! '>='
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: stalk_climber
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: bundler
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ~>
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: rake
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ! '>='
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ! '>='
67
76
  - !ruby/object:Gem::Version
@@ -77,6 +86,7 @@ files:
77
86
  - .rdoc_options
78
87
  - .rspec
79
88
  - .travis.yml
89
+ - .yardopts
80
90
  - Gemfile
81
91
  - LICENSE
82
92
  - README.md
@@ -106,26 +116,27 @@ files:
106
116
  homepage: https://github.com/gemeraldbeanstalk/bean_counter
107
117
  licenses:
108
118
  - MIT
109
- metadata: {}
110
119
  post_install_message:
111
120
  rdoc_options: []
112
121
  require_paths:
113
122
  - lib
114
123
  required_ruby_version: !ruby/object:Gem::Requirement
124
+ none: false
115
125
  requirements:
116
126
  - - ! '>='
117
127
  - !ruby/object:Gem::Version
118
128
  version: '0'
119
129
  required_rubygems_version: !ruby/object:Gem::Requirement
130
+ none: false
120
131
  requirements:
121
132
  - - ! '>='
122
133
  - !ruby/object:Gem::Version
123
134
  version: '0'
124
135
  requirements: []
125
136
  rubyforge_project:
126
- rubygems_version: 2.1.11
137
+ rubygems_version: 1.8.25
127
138
  signing_key:
128
- specification_version: 4
139
+ specification_version: 3
129
140
  summary: BeanCounter provides additional assertions for testing Ruby code that relies
130
141
  on Beaneater
131
142
  test_files:
@@ -136,3 +147,4 @@ test_files:
136
147
  - test/unit/strategy_test.rb
137
148
  - test/unit/test_assertions_test.rb
138
149
  - test/unit/tube_expectation_test.rb
150
+ has_rdoc:
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YjY0YjBhNjJmMjgxNGNhMDZjODU0ODA1MzY1ZmU3OThmYTk2NTAzZQ==
5
- data.tar.gz: !binary |-
6
- MmFhOWJiYTUwOTk5YjQ3ZjY5YWFlNDFmMzE3YTgzMGMwNGEzMjdlMA==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- N2M4OWZiNzg2MWViZTkzMTcwMmIyNmJlN2M0ZTY5NzYxYTNjN2NlMmMyNjIy
10
- YzcyNDIwOTcwNDZiOWFhNzVkZDc0MDhjMWU3MjZjNDU0NmU5OGMxM2NjZDMx
11
- ZjcxZGQzNGQ2YmFjYjNiOThiZGRhOWE4YTNlZWViNmMxYjMyMzY=
12
- data.tar.gz: !binary |-
13
- YThmM2ZmYzNiNzFkNTIyOTIxYTYzNzllZWEyYmI2MzhlMjk3Y2Y3ZjhjNmEw
14
- OGE3NTQ3OTc0MmJlMDE4YWQ2NTNmNmYzZDA2MDUzOWE5OGJlOGNjN2E3MjBh
15
- MTM4MmI1YmQ5ZWQzYjRlYjA3ZTEzMTU3MmZmMjAwZmZjNGZlY2Q=