punchout 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/punchout.rb +20 -0
- data/lib/punchout/matcher.rb +17 -0
- data/lib/punchout/matcher/ancestry.rb +16 -0
- data/lib/punchout/matcher/class.rb +16 -0
- data/lib/punchout/matcher/equal.rb +16 -0
- data/lib/punchout/matcher/progeny.rb +15 -0
- data/lib/punchout/puncher.rb +32 -0
- data/lib/punchout/puncher/matchable.rb +20 -0
- data/lib/punchout/puncher/matchable/resolver.rb +15 -0
- data/lib/punchout/puncher/matchables.rb +36 -0
- data/test/integration/punchout_test.rb +39 -0
- data/test/integration/test_helper.rb +18 -0
- data/test/unit/punchout/matcher/ancestry_test.rb +46 -0
- data/test/unit/punchout/matcher/class_test.rb +48 -0
- data/test/unit/punchout/matcher/equal_test.rb +17 -0
- data/test/unit/punchout/matcher/progeny_test.rb +47 -0
- data/test/unit/punchout/matcher_test.rb +22 -0
- data/test/unit/punchout/puncher/matchable_test.rb +29 -0
- data/test/unit/punchout/puncher/matchables_test.rb +68 -0
- data/test/unit/punchout/puncher_test.rb +39 -0
- data/test/unit/punchout_test.rb +74 -0
- data/test/unit/test_helper.rb +18 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a28f37c6b1f21bf3390778bb0104757e9b1c2e81
|
4
|
+
data.tar.gz: de7232745143ba047eb6220f26f4e61e2def2947
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4f2177f1aaceb39aeac074f449d4433fde323a6096348503abcc64e6d5f0030393d70a3183745424b41a5ebbd76a89f51f2c3a5b559267937faee0db4e3d9d33
|
7
|
+
data.tar.gz: 23d3be7c90f197b9b6e9412cfc00216ec2ceb61948b64d03a09232f836a9504751a2b155937e81076d549bc23a6921da925ac28b9afe291337359d4e44749978
|
data/lib/punchout.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'punchout/puncher'
|
2
|
+
require 'punchout/matcher/class'
|
3
|
+
|
4
|
+
module Punchout
|
5
|
+
module Punchable
|
6
|
+
def punchable?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
|
10
|
+
attr_accessor :matcher
|
11
|
+
|
12
|
+
def puncher
|
13
|
+
@puncher ||= Puncher.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def punch(obj)
|
17
|
+
puncher.punch(obj)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'punchout/puncher/matchable'
|
2
|
+
|
3
|
+
module Punchout
|
4
|
+
class Matcher
|
5
|
+
def initialize(subject)
|
6
|
+
@subject = subject
|
7
|
+
end
|
8
|
+
|
9
|
+
def punches(thing)
|
10
|
+
Punchout::Puncher::Matchable.new(self, thing)
|
11
|
+
end
|
12
|
+
|
13
|
+
def conflicts?(other)
|
14
|
+
false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'punchout/puncher/matchable'
|
2
|
+
require 'punchout/puncher/matchables'
|
3
|
+
|
4
|
+
module Punchout
|
5
|
+
class Puncher
|
6
|
+
def initialize
|
7
|
+
@matchables = Matchables.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def add(matchable)
|
11
|
+
if !matchable.kind_of?(Matchable)
|
12
|
+
raise
|
13
|
+
end
|
14
|
+
|
15
|
+
@matchables.add(matchable)
|
16
|
+
end
|
17
|
+
|
18
|
+
def can_punch?(type)
|
19
|
+
@matchables.include?(type)
|
20
|
+
end
|
21
|
+
|
22
|
+
def punch(type)
|
23
|
+
|
24
|
+
match = @matchables.find(type)
|
25
|
+
|
26
|
+
if match
|
27
|
+
match.thing
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Punchout
|
2
|
+
class Puncher
|
3
|
+
class Matchable
|
4
|
+
def initialize(matcher, thing)
|
5
|
+
@matcher = matcher
|
6
|
+
@thing = thing
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :thing
|
10
|
+
|
11
|
+
def matches?(subject)
|
12
|
+
@matcher.matches?(subject)
|
13
|
+
end
|
14
|
+
|
15
|
+
def conflicts?(other)
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Punchout
|
2
|
+
class Puncher
|
3
|
+
class Matchables
|
4
|
+
def initialize
|
5
|
+
@matchables = []
|
6
|
+
end
|
7
|
+
|
8
|
+
def add(matchable)
|
9
|
+
if conflicts?(matchable)
|
10
|
+
raise
|
11
|
+
end
|
12
|
+
@matchables << matchable
|
13
|
+
end
|
14
|
+
|
15
|
+
def include?(type)
|
16
|
+
@matchables.any? do |p|
|
17
|
+
p.matches?(type)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def find(type)
|
22
|
+
@matchables.find do |p|
|
23
|
+
p.matches?(type)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def conflicts?(matchable)
|
30
|
+
@matchables.any? do |m|
|
31
|
+
m.conflicts?(matchable) || matchable.conflicts?(m)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
|
3
|
+
require 'punchout'
|
4
|
+
require 'punchout/matcher/class'
|
5
|
+
|
6
|
+
class Punchout::Test < ActiveSupport::TestCase
|
7
|
+
setup do
|
8
|
+
@punchout_klass = Class.new do
|
9
|
+
include Punchout::Punchable
|
10
|
+
end
|
11
|
+
|
12
|
+
@pairings = 3.times.map {
|
13
|
+
{match: Class.new, punchable: Class.new}
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
test "#punch" do
|
18
|
+
punchout = @punchout_klass.new
|
19
|
+
puncher = punchout.puncher
|
20
|
+
|
21
|
+
@pairings.each do |p|
|
22
|
+
matcher = Punchout::Matcher::Klass.new(p[:match])
|
23
|
+
|
24
|
+
matchable = matcher.punches(p[:punchable])
|
25
|
+
|
26
|
+
puncher.add(matchable)
|
27
|
+
end
|
28
|
+
|
29
|
+
expected = @pairings.first
|
30
|
+
|
31
|
+
expected_matching_instance = expected[:match].new
|
32
|
+
|
33
|
+
result = puncher.can_punch?(expected_matching_instance)
|
34
|
+
assert result, "#{punchout.puncher.inspect} CAN NOT PUNCH #{expected[:match]}"
|
35
|
+
|
36
|
+
result = puncher.punch(expected_matching_instance)
|
37
|
+
assert_equal expected[:punchable],result
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
$:.push('lib')
|
2
|
+
|
3
|
+
require 'coveralls'
|
4
|
+
Coveralls.wear!
|
5
|
+
|
6
|
+
if ENV["ENABLE_SIMPLE_COV"]
|
7
|
+
require 'simplecov'
|
8
|
+
# require File.expand_path('../simplecov_helper', __FILE__)
|
9
|
+
SimpleCov.start do
|
10
|
+
add_filter "test"
|
11
|
+
add_group 'API', "lib"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'active_support/time'
|
16
|
+
require 'active_support/test_case'
|
17
|
+
require 'test/unit'
|
18
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
require 'punchout/matcher/ancestry'
|
4
|
+
|
5
|
+
class Punchout::Matcher::AncestryTest < ActiveSupport::TestCase
|
6
|
+
setup do
|
7
|
+
@ancestor_klass = Class.new
|
8
|
+
|
9
|
+
@base_klass = Class.new(@ancestor_klass)
|
10
|
+
|
11
|
+
@derived_klass = Class.new(@base_klass)
|
12
|
+
|
13
|
+
@independent_klass = Class.new
|
14
|
+
|
15
|
+
@mock_thing = mock
|
16
|
+
end
|
17
|
+
|
18
|
+
test "#match none" do
|
19
|
+
matcher = Punchout::Matcher::Ancestry.new(@derived_klass)
|
20
|
+
result = matcher.matches?(@independent_klass.new)
|
21
|
+
|
22
|
+
assert_equal false, result
|
23
|
+
end
|
24
|
+
|
25
|
+
test "#match should match equivalence" do
|
26
|
+
matcher = Punchout::Matcher::Ancestry.new(@base_klass)
|
27
|
+
result = matcher.matches?(@base_klass.new)
|
28
|
+
|
29
|
+
assert_equal true, result
|
30
|
+
end
|
31
|
+
|
32
|
+
test "#match should match descendant" do
|
33
|
+
matcher = Punchout::Matcher::Ancestry.new(@base_klass)
|
34
|
+
result = matcher.matches?(@derived_klass.new)
|
35
|
+
|
36
|
+
assert_equal true, result
|
37
|
+
end
|
38
|
+
|
39
|
+
test "#match should not match ancestor" do
|
40
|
+
matcher = Punchout::Matcher::Ancestry.new(@derived_klass)
|
41
|
+
result = matcher.matches?(@base_klass.new)
|
42
|
+
|
43
|
+
assert_equal false, result
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
|
2
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
3
|
+
|
4
|
+
require 'punchout/matcher/class'
|
5
|
+
|
6
|
+
class Punchout::Matcher::KlassTest < ActiveSupport::TestCase
|
7
|
+
setup do
|
8
|
+
@ancestor_klass = Class.new
|
9
|
+
|
10
|
+
@base_klass = Class.new(@ancestor_klass)
|
11
|
+
|
12
|
+
@derived_klass = Class.new(@base_klass)
|
13
|
+
|
14
|
+
@independent_klass = Class.new
|
15
|
+
|
16
|
+
@mock_thing = mock
|
17
|
+
end
|
18
|
+
|
19
|
+
test "#match none" do
|
20
|
+
matcher = Punchout::Matcher::Klass.new(@derived_klass)
|
21
|
+
result = matcher.matches?(@independent_klass.new)
|
22
|
+
|
23
|
+
assert_equal false, result
|
24
|
+
end
|
25
|
+
|
26
|
+
test "#match should match equivalence" do
|
27
|
+
matcher = Punchout::Matcher::Klass.new(@base_klass)
|
28
|
+
result = matcher.matches?(@base_klass.new)
|
29
|
+
|
30
|
+
assert_equal true, result
|
31
|
+
end
|
32
|
+
|
33
|
+
test "#match should match descendant" do
|
34
|
+
matcher = Punchout::Matcher::Klass.new(@base_klass)
|
35
|
+
result = matcher.matches?(@derived_klass.new)
|
36
|
+
|
37
|
+
assert_equal false, result
|
38
|
+
end
|
39
|
+
|
40
|
+
test "#match should not match ancestor" do
|
41
|
+
matcher = Punchout::Matcher::Klass.new(@derived_klass)
|
42
|
+
result = matcher.matches?(@base_klass.new)
|
43
|
+
|
44
|
+
assert_equal false, result
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
3
|
+
|
4
|
+
require 'punchout/matcher/equal'
|
5
|
+
|
6
|
+
class Punchout::Matcher::EqualTest < ActiveSupport::TestCase
|
7
|
+
test "#match none" do
|
8
|
+
matcher = Punchout::Matcher::Equal.new("foo")
|
9
|
+
assert_equal false, matcher.matches?("bar")
|
10
|
+
end
|
11
|
+
|
12
|
+
test "#match should match equivalence" do
|
13
|
+
matcher = Punchout::Matcher::Equal.new("foo")
|
14
|
+
assert_equal true, matcher.matches?("foo")
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
require 'punchout/matcher/progeny'
|
4
|
+
|
5
|
+
class Punchout::Matcher::ProgenyTest < ActiveSupport::TestCase
|
6
|
+
setup do
|
7
|
+
@ancestor_klass = Class.new
|
8
|
+
|
9
|
+
@base_klass = Class.new(@ancestor_klass)
|
10
|
+
|
11
|
+
@derived_klass = Class.new(@base_klass)
|
12
|
+
|
13
|
+
@independent_klass = Class.new
|
14
|
+
|
15
|
+
@mock_thing = mock
|
16
|
+
end
|
17
|
+
|
18
|
+
test "#match none" do
|
19
|
+
matcher = Punchout::Matcher::Progeny.new(@derived_klass)
|
20
|
+
result = matcher.matches?(@independent_klass.new)
|
21
|
+
|
22
|
+
assert_equal false, result
|
23
|
+
end
|
24
|
+
|
25
|
+
test "#match should match equivalence" do
|
26
|
+
matcher = Punchout::Matcher::Progeny.new(@base_klass)
|
27
|
+
result = matcher.matches?(@base_klass.new)
|
28
|
+
|
29
|
+
assert_equal true, result
|
30
|
+
end
|
31
|
+
|
32
|
+
test "#match should match descendant" do
|
33
|
+
matcher = Punchout::Matcher::Progeny.new(@base_klass)
|
34
|
+
result = matcher.matches?(@derived_klass.new)
|
35
|
+
|
36
|
+
assert_equal false, result
|
37
|
+
end
|
38
|
+
|
39
|
+
test "#match should not match ancestor" do
|
40
|
+
matcher = Punchout::Matcher::Progeny.new(@derived_klass)
|
41
|
+
result = matcher.matches?(@base_klass.new)
|
42
|
+
|
43
|
+
assert_equal true, result
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
require 'punchout/matcher'
|
4
|
+
|
5
|
+
class Punchout::MatcherTest < ActiveSupport::TestCase
|
6
|
+
setup do
|
7
|
+
@mock_subject = mock
|
8
|
+
@matcher = Punchout::Matcher.new(@mock_subject)
|
9
|
+
end
|
10
|
+
|
11
|
+
test "#punches" do
|
12
|
+
mock_thing = mock
|
13
|
+
|
14
|
+
mock_matchable = mock
|
15
|
+
|
16
|
+
Punchout::Puncher::Matchable.expects(:new).returns(mock_matchable)
|
17
|
+
|
18
|
+
result = @matcher.punches(mock_thing)
|
19
|
+
|
20
|
+
assert_equal result, mock_matchable
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
require 'punchout/puncher/matchable'
|
4
|
+
|
5
|
+
class Punchout::Puncher::MatchableTest < ActiveSupport::TestCase
|
6
|
+
test "#matches? true" do
|
7
|
+
mock_matcher = mock
|
8
|
+
mock_thing = mock
|
9
|
+
|
10
|
+
mock_matcher.expects(:matches?).with(mock_thing).returns(true)
|
11
|
+
matchable = Punchout::Puncher::Matchable.new(mock_matcher, mock_thing)
|
12
|
+
|
13
|
+
result = matchable.matches?(mock_thing)
|
14
|
+
|
15
|
+
assert_equal true, result
|
16
|
+
end
|
17
|
+
|
18
|
+
test "#matches? false" do
|
19
|
+
mock_matcher = mock
|
20
|
+
mock_thing = mock
|
21
|
+
|
22
|
+
mock_matcher.expects(:matches?).with(mock_thing).returns(false)
|
23
|
+
matchable = Punchout::Puncher::Matchable.new(mock_matcher, mock_thing)
|
24
|
+
|
25
|
+
result = matchable.matches?(mock_thing)
|
26
|
+
|
27
|
+
assert_equal false, result
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require File.expand_path('../../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
require 'punchout/puncher/matchables'
|
4
|
+
|
5
|
+
class Punchout::Puncher::MatchablesTest < ActiveSupport::TestCase
|
6
|
+
setup do
|
7
|
+
|
8
|
+
@mock_matchables = 5.times.map {|x|
|
9
|
+
mock_matchable = mock
|
10
|
+
mock_matchable.expects(:conflicts?).at_least_once.returns(false)
|
11
|
+
mock_matchable
|
12
|
+
}
|
13
|
+
|
14
|
+
@matchables = Punchout::Puncher::Matchables.new
|
15
|
+
|
16
|
+
@mock_matchables.each {|p|
|
17
|
+
@matchables.add(p)
|
18
|
+
}
|
19
|
+
|
20
|
+
@mock_type = mock
|
21
|
+
end
|
22
|
+
|
23
|
+
test '#include? no match' do
|
24
|
+
@mock_matchables.each {|p|
|
25
|
+
p.expects(:matches?).with(@mock_type).returns(false)
|
26
|
+
}
|
27
|
+
|
28
|
+
result = @matchables.include?(@mock_type)
|
29
|
+
|
30
|
+
assert_equal false, result
|
31
|
+
end
|
32
|
+
|
33
|
+
test '#include? match located' do
|
34
|
+
@mock_matchables.take(4).each {|p|
|
35
|
+
p.expects(:matches?).with(@mock_type).returns(false)
|
36
|
+
}
|
37
|
+
|
38
|
+
|
39
|
+
@mock_matchables.last.expects(:matches?).with(@mock_type).returns(true)
|
40
|
+
|
41
|
+
result = @matchables.include?(@mock_type)
|
42
|
+
|
43
|
+
assert_equal true, result
|
44
|
+
end
|
45
|
+
|
46
|
+
test '#fetch no match' do
|
47
|
+
@mock_matchables.each {|p|
|
48
|
+
p.expects(:matches?).with(@mock_type).returns(false)
|
49
|
+
}
|
50
|
+
|
51
|
+
result = @matchables.find(@mock_type)
|
52
|
+
|
53
|
+
assert_equal nil, result
|
54
|
+
end
|
55
|
+
|
56
|
+
test '#fetch match located' do
|
57
|
+
@mock_matchables.take(4).each {|p|
|
58
|
+
p.expects(:matches?).with(@mock_type).returns(false)
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
@mock_matchables.last.expects(:matches?).with(@mock_type).returns(true)
|
63
|
+
|
64
|
+
result = @matchables.find(@mock_type)
|
65
|
+
|
66
|
+
assert_equal @mock_matchables.last, result
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
require 'punchout/puncher'
|
4
|
+
|
5
|
+
class Punchout::PuncherTest < ActiveSupport::TestCase
|
6
|
+
setup do
|
7
|
+
|
8
|
+
@mock_matchables = mock
|
9
|
+
|
10
|
+
@puncher = Punchout::Puncher.new
|
11
|
+
|
12
|
+
@mock_type = mock
|
13
|
+
end
|
14
|
+
|
15
|
+
test '#punch no match' do
|
16
|
+
@mock_matchables.expects(:find).with(@mock_type).returns(nil)
|
17
|
+
|
18
|
+
@puncher.instance_variable_set(:@matchables, @mock_matchables)
|
19
|
+
|
20
|
+
result = @puncher.punch(@mock_type)
|
21
|
+
|
22
|
+
assert_equal nil, result
|
23
|
+
end
|
24
|
+
|
25
|
+
test '#punch match located' do
|
26
|
+
mock_matchable = mock
|
27
|
+
|
28
|
+
@mock_matchables.expects(:find).with(@mock_type).returns(mock_matchable)
|
29
|
+
|
30
|
+
mock_thing = mock
|
31
|
+
mock_matchable.expects(:thing).returns(mock_thing)
|
32
|
+
|
33
|
+
@puncher.instance_variable_set(:@matchables, @mock_matchables)
|
34
|
+
|
35
|
+
result = @puncher.punch(@mock_type)
|
36
|
+
|
37
|
+
assert_equal mock_thing, result
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
|
3
|
+
require 'punchout'
|
4
|
+
|
5
|
+
class Punchout::PunchableTest < ActiveSupport::TestCase
|
6
|
+
test "#include" do
|
7
|
+
@klass = Class.new do
|
8
|
+
include Punchout::Punchable
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
test "#puncher greenfield" do
|
13
|
+
@klass = Class.new do
|
14
|
+
include Punchout::Punchable
|
15
|
+
end
|
16
|
+
|
17
|
+
instance = @klass.new
|
18
|
+
|
19
|
+
mock_matcher_klass = mock
|
20
|
+
|
21
|
+
mock_puncher = mock
|
22
|
+
Punchout::Puncher.expects(:new).returns(mock_puncher)
|
23
|
+
|
24
|
+
instance.matcher = mock_matcher_klass
|
25
|
+
|
26
|
+
result = instance.puncher
|
27
|
+
|
28
|
+
assert_equal mock_puncher, result
|
29
|
+
end
|
30
|
+
|
31
|
+
test "#puncher cached" do
|
32
|
+
@klass = Class.new do
|
33
|
+
include Punchout::Punchable
|
34
|
+
end
|
35
|
+
|
36
|
+
instance = @klass.new
|
37
|
+
|
38
|
+
mock_matcher_klass = mock
|
39
|
+
|
40
|
+
mock_puncher = mock
|
41
|
+
|
42
|
+
instance.matcher = mock_matcher_klass
|
43
|
+
instance.instance_variable_set(:@puncher, mock_puncher)
|
44
|
+
|
45
|
+
result = instance.puncher
|
46
|
+
|
47
|
+
assert_equal mock_puncher, result
|
48
|
+
end
|
49
|
+
|
50
|
+
test "#punch" do
|
51
|
+
@klass = Class.new do
|
52
|
+
include Punchout::Punchable
|
53
|
+
end
|
54
|
+
|
55
|
+
instance = @klass.new
|
56
|
+
|
57
|
+
mock_matcher_klass = mock
|
58
|
+
|
59
|
+
mock_puncher = mock
|
60
|
+
|
61
|
+
instance.matcher = mock_matcher_klass
|
62
|
+
instance.instance_variable_set(:@puncher, mock_puncher)
|
63
|
+
|
64
|
+
mock_obj = mock
|
65
|
+
|
66
|
+
mock_punched = mock
|
67
|
+
mock_puncher.expects(:punch).with(mock_obj).returns(mock_punched)
|
68
|
+
|
69
|
+
result = instance.punch(mock_obj)
|
70
|
+
|
71
|
+
assert_equal mock_punched, result
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
$:.push('lib')
|
2
|
+
|
3
|
+
require 'coveralls'
|
4
|
+
Coveralls.wear!
|
5
|
+
|
6
|
+
if ENV["ENABLE_SIMPLE_COV"]
|
7
|
+
require 'simplecov'
|
8
|
+
# require File.expand_path('../simplecov_helper', __FILE__)
|
9
|
+
SimpleCov.start do
|
10
|
+
add_filter "test"
|
11
|
+
add_group 'API', "lib"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'active_support/time'
|
16
|
+
require 'active_support/test_case'
|
17
|
+
require 'test/unit'
|
18
|
+
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: punchout
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ed Carrel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: active_support
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mocha
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: simplecov
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A flexible implementation of the Registry pattern, with an extensible
|
56
|
+
finder/matcher mechanism.
|
57
|
+
email:
|
58
|
+
- edward@carrel.org
|
59
|
+
- ed@pocketchange.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- lib/punchout/matcher/ancestry.rb
|
65
|
+
- lib/punchout/matcher/class.rb
|
66
|
+
- lib/punchout/matcher/equal.rb
|
67
|
+
- lib/punchout/matcher/progeny.rb
|
68
|
+
- lib/punchout/matcher.rb
|
69
|
+
- lib/punchout/puncher/matchable/resolver.rb
|
70
|
+
- lib/punchout/puncher/matchable.rb
|
71
|
+
- lib/punchout/puncher/matchables.rb
|
72
|
+
- lib/punchout/puncher.rb
|
73
|
+
- lib/punchout.rb
|
74
|
+
- test/integration/punchout_test.rb
|
75
|
+
- test/integration/test_helper.rb
|
76
|
+
- test/unit/punchout/matcher/ancestry_test.rb
|
77
|
+
- test/unit/punchout/matcher/class_test.rb
|
78
|
+
- test/unit/punchout/matcher/equal_test.rb
|
79
|
+
- test/unit/punchout/matcher/progeny_test.rb
|
80
|
+
- test/unit/punchout/matcher_test.rb
|
81
|
+
- test/unit/punchout/puncher/matchable_test.rb
|
82
|
+
- test/unit/punchout/puncher/matchables_test.rb
|
83
|
+
- test/unit/punchout/puncher_test.rb
|
84
|
+
- test/unit/punchout_test.rb
|
85
|
+
- test/unit/test_helper.rb
|
86
|
+
homepage:
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.1.10
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: A flexible registry pattern gem
|
110
|
+
test_files: []
|
111
|
+
has_rdoc:
|