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.
- data/README.md +1 -1
- data/lib/bean_counter/core.rb +67 -41
- data/lib/bean_counter/enqueued_expectation.rb +61 -20
- data/lib/bean_counter/spec_matchers.rb +21 -8
- data/lib/bean_counter/strategies/stalk_climber_strategy.rb +67 -46
- data/lib/bean_counter/strategy.rb +101 -77
- data/lib/bean_counter/test_assertions.rb +148 -98
- data/lib/bean_counter/tube_expectation.rb +50 -18
- data/lib/bean_counter/version.rb +1 -1
- data/test/unit/core_test.rb +2 -3
- metadata +2 -2
@@ -4,46 +4,75 @@ class BeanCounter::TubeExpectation
|
|
4
4
|
|
5
5
|
def_delegators BeanCounter, :strategy
|
6
6
|
|
7
|
-
# The
|
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
|
-
#
|
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
|
26
|
-
# an attribute of a tube that the corresponding
|
27
|
-
# against. All attribute comparisons are performed using the triple
|
28
|
-
# (===) operator/method of the given
|
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
|
-
#
|
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
|
37
|
-
# options hash given
|
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
|
42
|
-
#
|
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
|
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 [
|
data/lib/bean_counter/version.rb
CHANGED
data/test/unit/core_test.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: beaneater
|