bean_counter 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,46 +4,75 @@ class BeanCounter::TubeExpectation
4
4
 
5
5
  def_delegators BeanCounter, :strategy
6
6
 
7
- # The value that the expectation expects
7
+ # The Hash of options given at instantiation that the expectation expects when
8
+ # matching.
9
+ # @return [Hash]
8
10
  attr_reader :expected
9
11
 
10
- # The tube found by the expecation during matching
12
+ # The tube found by the expecation during matching if one exists.
13
+ # @return [Strategy::Tube]
11
14
  attr_reader :found
12
15
 
13
16
 
14
17
  # Builds the failure message used in the event of a positive expectation
15
- # failure
18
+ # failure.
19
+ #
20
+ # @return [String] the failure message to be used in the event of a positive
21
+ # expectation failure.
16
22
  def failure_message
17
23
  return '' unless found.nil?
18
24
  return "expected tube matching #{expected.to_s}, found none."
19
25
  end
20
26
 
21
27
 
22
- # Create a new tube expectation. Uses the given +expected+ Hash to determine
28
+ # Creates a new tube expectation. Uses the given `expected` Hash to determine
23
29
  # if any tubes exist that match the expected options.
24
30
  #
25
- # Each _key_ in the +expected+ Hash is a String or a Symbol that identifies
26
- # an attribute of a tube that the corresponding _value_ should be compared
27
- # against. All attribute comparisons are performed using the triple equal
28
- # (===) operator/method of the given _value_.
31
+ # Each `key` in the `expected` Hash is a String or a Symbol that identifies
32
+ # an attribute of a tube that the corresponding `value` should be compared
33
+ # against. All attribute comparisons are performed using the triple-equal
34
+ # (===) operator/method of the given `value`.
35
+ #
36
+ # See {BeanCounter::Strategy::MATCHABLE_TUBE_ASSERTIONS} for a list of those
37
+ # attributes that can be used when matching.
38
+ #
39
+ # See {BeanCounter::TestAssertions} and/or {BeanCounter::SpecMatchers} for more
40
+ # information.
29
41
  #
30
- # See BeanCounter::MiniTest and/or BeanCounter::SpecMatchers for more information.
42
+ # @see BeanCounter::Strategy::MATCHABLE_TUBE_ATTRIBUTES
43
+ # @see BeanCounter::TestAssertions
44
+ # @see BeanCounter::SpecMatchers
45
+ # @param expected
46
+ # [Hash{String, Symbol => Numeric, Proc, Range, Regexp, String, Symbol}]
47
+ # Options expected when evaluating match.
31
48
  def initialize(expected)
32
49
  @expected = expected
33
50
  end
34
51
 
35
52
 
36
- # Checks all tubes in the beanstalkd pool for a tube matching the expected
37
- # options hash given at instantiation. The expectation succeeds if any tube
38
- # exists that matches all of the expected options. If no tube exists
53
+ # Checks all tubes in the Beanstalkd pool for a tube matching the expected
54
+ # options hash given during instantiation. The expectation succeeds if any
55
+ # tube exists that matches all of the expected options. If no tube exists
39
56
  # matching all of the given options, the expectation fails.
40
57
  #
41
- # See Strategy#tube_matches? and/or the #tube_matches? method of the strategy
42
- # in use for more detailed information on how it is determined whether or not
43
- # a tube matches the options expected.
58
+ # See {BeanCounter::Strategy::MATCHABLE_TUBE_ATTRIBUTES} for a list of those
59
+ # attributes that can be used when matching.
44
60
  #
45
- # See also BeanCounter::MiniTest and/or BeanCounter::SpecMatchers for additional
46
- # information.
61
+ # See {BeanCounter::Strategy#tube_matches?} and/or the #tube_matches? method
62
+ # of the strategy in use for more detailed information on how it is determined
63
+ # whether or not a tube matches the options expected.
64
+ #
65
+ # See also {BeanCounter::TestAssertions} and/or {BeanCounter::SpecMatchers}
66
+ # for additional information.
67
+ #
68
+ # @see BeanCounter::Strategy::MATCHABLE_TUBE_ATTRIBUTES
69
+ # @see BeanCounter::TestAssertions
70
+ # @see BeanCounter::SpecMatchers
71
+ # @param given [Object] ignored. All expectations should be included in
72
+ # the expected options given at instantiation. Nothing will be infered
73
+ # from the given Object.
74
+ # @return [Boolean] If a tube matching the expectation is found, returns true.
75
+ # Otherwise, returns false.
47
76
  def matches?(given = nil)
48
77
  @found = strategy.tubes.detect do |tube|
49
78
  strategy.tube_matches?(tube, expected)
@@ -54,7 +83,10 @@ class BeanCounter::TubeExpectation
54
83
 
55
84
 
56
85
  # Builds the failure message used in the event of a negative expectation
57
- # failure
86
+ # failure.
87
+ #
88
+ # @return [String] the message to be used in the event of a negative
89
+ # expectation failure.
58
90
  def negative_failure_message
59
91
  return '' if found.nil?
60
92
  return [
@@ -1,4 +1,4 @@
1
1
  module BeanCounter
2
2
  # BeanCounter version number
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
@@ -17,7 +17,7 @@ class CoreTest < BeanCounter::TestCase
17
17
  BeanCounter.beanstalkd_url
18
18
  end
19
19
 
20
- new_url = 'beanstalk://beaneater'
20
+ new_url = ['beanstalk://beaneater', 'beaneater:11300']
21
21
  Beaneater.configuration.beanstalkd_url = new_url
22
22
  assert_equal new_url, BeanCounter.beanstalkd_url
23
23
  Beaneater.configuration.beanstalkd_url = original_url_beaneater
@@ -25,10 +25,9 @@ class CoreTest < BeanCounter::TestCase
25
25
 
26
26
  new_url = 'beanstalk://bean_counter'
27
27
  BeanCounter.beanstalkd_url = new_url
28
- assert_equal new_url, BeanCounter.beanstalkd_url
28
+ assert_equal [new_url], BeanCounter.beanstalkd_url
29
29
  BeanCounter.beanstalkd_url = original_url_bean_counter
30
30
 
31
- # Env beanstalkd_url is always turned into an array
32
31
  new_url = 'beanstalk://env'
33
32
  ENV['BEANSTALKD_URL'] = new_url
34
33
  assert_equal [new_url], BeanCounter.beanstalkd_url
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bean_counter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-15 00:00:00.000000000 Z
12
+ date: 2013-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beaneater