punchout 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d41e5e66093156e892f64ae4488e388d86788c7
4
- data.tar.gz: bb7f6416d9b5f6f9328ee105064307825421de8b
3
+ metadata.gz: 884d3dcab31235e809deb2c8d3f8779dd2f46dd5
4
+ data.tar.gz: 298a8d3c298bb1f6b7b406d272d25c0720f5b1be
5
5
  SHA512:
6
- metadata.gz: f2f89a361ec05f13413aecece10fb3a100fa8d661d1f4874065e8943350b103b4982f6d49e3a6dac15e735f50d3d677fe49128dc73e5fcada8e53266cb98ae77
7
- data.tar.gz: 791224925c8690f29ff5e498b252451458bec73964ea4ac7a47ce2c40202348c4b0929399cc7fdabe84d7eba7adc1ae60989283bd697923af9d74812b3c25b0d
6
+ metadata.gz: 5785de814f7d0923a21bf4dfb39d704e2d775911ed5af65e086dcb883849828d9f8594011ada36e74c819d611c7f7c56ef4790e4b098acf3b493399b943c0a87
7
+ data.tar.gz: fb47608dad0bc974f5f81aa45048ff4cf9235b9761ce2d77b2b7834e5a215db4d34651e5124c8ece875bbf3588439dff92a6fcf7109256bb2e95abea5ea1b164
@@ -1,3 +1,5 @@
1
+ require 'punchout/puncher'
2
+
1
3
  module Punchout
2
4
  class Fabricator
3
5
  def initialize(factory)
@@ -19,6 +19,12 @@ module Punchout
19
19
  @matchables.include?(type)
20
20
  end
21
21
 
22
+ def all
23
+ @matchables.all.map do |m|
24
+ m.thing
25
+ end
26
+ end
27
+
22
28
  def punch(type)
23
29
 
24
30
  match = @matchables.find(type)
@@ -24,6 +24,10 @@ module Punchout
24
24
  end
25
25
  end
26
26
 
27
+ def all
28
+ @matchables
29
+ end
30
+
27
31
  private
28
32
 
29
33
  def conflicts?(matchable)
@@ -3,7 +3,7 @@ require File.expand_path('../../test_helper', __FILE__)
3
3
  require 'punchout/fabricable'
4
4
  require 'punchout/matcher/class'
5
5
 
6
- class Punchout::Fabricator::Test < ActiveSupport::TestCase
6
+ class Punchout::Fabricator::Test < Test::Unit::TestCase
7
7
  class Factory
8
8
  def initialize(pairings)
9
9
  @pairings = pairings
@@ -3,7 +3,7 @@ require File.expand_path('../test_helper', __FILE__)
3
3
  require 'punchout'
4
4
  require 'punchout/matcher/class'
5
5
 
6
- class Punchout::Test < ActiveSupport::TestCase
6
+ class Punchout::Test < Test::Unit::TestCase
7
7
  setup do
8
8
  @punchout_klass = Class.new do
9
9
  include Punchout::Punchable
@@ -36,4 +36,22 @@ class Punchout::Test < ActiveSupport::TestCase
36
36
  result = puncher.punch(expected_matching_instance)
37
37
  assert_equal expected[:punchable],result
38
38
  end
39
+
40
+ test "#all" do
41
+ punchout = @punchout_klass.new
42
+ puncher = punchout.puncher
43
+
44
+ @pairings.each do |p|
45
+ matcher = Punchout::Matcher::Klass.new(p[:match])
46
+
47
+ matchable = matcher.punches(p[:punchable])
48
+
49
+ puncher.add(matchable)
50
+ end
51
+
52
+ expected = @pairings.map {|p| p[:punchable]}
53
+
54
+ result = puncher.all
55
+ assert_equal expected,result
56
+ end
39
57
  end
@@ -12,7 +12,5 @@ if ENV["ENABLE_SIMPLE_COV"]
12
12
  end
13
13
  end
14
14
 
15
- require 'active_support/time'
16
- require 'active_support/test_case'
17
- require 'test/unit'
18
-
15
+ require 'test/unit/testcase'
16
+ require 'mocha/setup'
@@ -3,7 +3,7 @@ require File.expand_path('../../test_helper', __FILE__)
3
3
  require 'punchout/fabricator'
4
4
  require 'punchout/puncher'
5
5
 
6
- class Punchout::FabricatorTest < ActiveSupport::TestCase
6
+ class Punchout::FabricatorTest < Test::Unit::TestCase
7
7
  setup do
8
8
  @mock_factory = mock
9
9
  @mock_puncher = mock
@@ -2,7 +2,7 @@ require File.expand_path('../../../test_helper', __FILE__)
2
2
 
3
3
  require 'punchout/matcher/ancestry'
4
4
 
5
- class Punchout::Matcher::AncestryTest < ActiveSupport::TestCase
5
+ class Punchout::Matcher::AncestryTest < Test::Unit::TestCase
6
6
  setup do
7
7
  @ancestor_klass = Class.new
8
8
 
@@ -3,7 +3,7 @@ require File.expand_path('../../../test_helper', __FILE__)
3
3
 
4
4
  require 'punchout/matcher/class'
5
5
 
6
- class Punchout::Matcher::KlassTest < ActiveSupport::TestCase
6
+ class Punchout::Matcher::KlassTest < Test::Unit::TestCase
7
7
  setup do
8
8
  @ancestor_klass = Class.new
9
9
 
@@ -3,7 +3,7 @@ require File.expand_path('../../../test_helper', __FILE__)
3
3
 
4
4
  require 'punchout/matcher/equal'
5
5
 
6
- class Punchout::Matcher::EqualTest < ActiveSupport::TestCase
6
+ class Punchout::Matcher::EqualTest < Test::Unit::TestCase
7
7
  test "#match none" do
8
8
  matcher = Punchout::Matcher::Equal.new("foo")
9
9
  assert_equal false, matcher.matches?("bar")
@@ -2,7 +2,7 @@ require File.expand_path('../../../test_helper', __FILE__)
2
2
 
3
3
  require 'punchout/matcher/progeny'
4
4
 
5
- class Punchout::Matcher::ProgenyTest < ActiveSupport::TestCase
5
+ class Punchout::Matcher::ProgenyTest < Test::Unit::TestCase
6
6
  setup do
7
7
  @ancestor_klass = Class.new
8
8
 
@@ -2,7 +2,7 @@ require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  require 'punchout/matcher'
4
4
 
5
- class Punchout::MatcherTest < ActiveSupport::TestCase
5
+ class Punchout::MatcherTest < Test::Unit::TestCase
6
6
  setup do
7
7
  @mock_subject = mock
8
8
  @matcher = Punchout::Matcher.new(@mock_subject)
@@ -2,7 +2,7 @@ require File.expand_path('../../../test_helper', __FILE__)
2
2
 
3
3
  require 'punchout/puncher/matchable'
4
4
 
5
- class Punchout::Puncher::MatchableTest < ActiveSupport::TestCase
5
+ class Punchout::Puncher::MatchableTest < Test::Unit::TestCase
6
6
  test "#matches? true" do
7
7
  mock_matcher = mock
8
8
  mock_thing = mock
@@ -2,7 +2,7 @@ require File.expand_path('../../../test_helper', __FILE__)
2
2
 
3
3
  require 'punchout/puncher/matchables'
4
4
 
5
- class Punchout::Puncher::MatchablesTest < ActiveSupport::TestCase
5
+ class Punchout::Puncher::MatchablesTest < Test::Unit::TestCase
6
6
  setup do
7
7
 
8
8
  @mock_matchables = 5.times.map {|x|
@@ -65,4 +65,9 @@ class Punchout::Puncher::MatchablesTest < ActiveSupport::TestCase
65
65
 
66
66
  assert_equal @mock_matchables.last, result
67
67
  end
68
+
69
+ test '#all' do
70
+ result = @matchables.all
71
+ assert_equal @mock_matchables, result
72
+ end
68
73
  end
@@ -2,7 +2,7 @@ require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  require 'punchout/puncher'
4
4
 
5
- class Punchout::PuncherTest < ActiveSupport::TestCase
5
+ class Punchout::PuncherTest < Test::Unit::TestCase
6
6
  setup do
7
7
 
8
8
  @mock_matchables = mock
@@ -36,4 +36,24 @@ class Punchout::PuncherTest < ActiveSupport::TestCase
36
36
 
37
37
  assert_equal mock_thing, result
38
38
  end
39
+
40
+ test '#all' do
41
+ mock_things = 5.times.map do
42
+ mock
43
+ end
44
+
45
+ mock_matchable_arr = mock_things.map do |thing|
46
+ mock_matchable = mock
47
+ mock_matchable.expects(:thing).returns(thing)
48
+ mock_matchable
49
+ end
50
+
51
+ @mock_matchables.expects(:all).returns(mock_matchable_arr)
52
+
53
+ @puncher.instance_variable_set(:@matchables, @mock_matchables)
54
+
55
+ result = @puncher.all
56
+
57
+ assert_equal mock_things, result
58
+ end
39
59
  end
@@ -2,7 +2,7 @@ require File.expand_path('../test_helper', __FILE__)
2
2
 
3
3
  require 'punchout'
4
4
 
5
- class Punchout::PunchableTest < ActiveSupport::TestCase
5
+ class Punchout::PunchableTest < Test::Unit::TestCase
6
6
  test "#include" do
7
7
  @klass = Class.new do
8
8
  include Punchout::Punchable
@@ -5,14 +5,11 @@ Coveralls.wear!
5
5
 
6
6
  if ENV["ENABLE_SIMPLE_COV"]
7
7
  require 'simplecov'
8
- # require File.expand_path('../simplecov_helper', __FILE__)
9
8
  SimpleCov.start do
10
9
  add_filter "test"
11
10
  add_group 'API', "lib"
12
11
  end
13
12
  end
14
13
 
15
- require 'active_support/time'
16
- require 'active_support/test_case'
17
- require 'test/unit'
18
-
14
+ require 'test/unit/testcase'
15
+ require 'mocha/setup'
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: punchout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Carrel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-11 00:00:00.000000000 Z
11
+ date: 2013-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: active_support
14
+ name: test-unit
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - '>='
@@ -61,32 +61,32 @@ executables: []
61
61
  extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
- - lib/punchout/fabricable.rb
64
+ - lib/punchout.rb
65
65
  - lib/punchout/fabricator.rb
66
- - lib/punchout/matcher/ancestry.rb
67
- - lib/punchout/matcher/class.rb
68
- - lib/punchout/matcher/equal.rb
69
- - lib/punchout/matcher/progeny.rb
70
- - lib/punchout/matcher.rb
71
- - lib/punchout/puncher/matchable/resolver.rb
72
66
  - lib/punchout/puncher/matchable.rb
73
67
  - lib/punchout/puncher/matchables.rb
68
+ - lib/punchout/puncher/matchable/resolver.rb
69
+ - lib/punchout/matcher.rb
70
+ - lib/punchout/matcher/equal.rb
71
+ - lib/punchout/matcher/class.rb
72
+ - lib/punchout/matcher/ancestry.rb
73
+ - lib/punchout/matcher/progeny.rb
74
74
  - lib/punchout/puncher.rb
75
- - lib/punchout.rb
76
- - test/integration/punchout/fabricable_test.rb
77
- - test/integration/punchout_test.rb
78
- - test/integration/test_helper.rb
79
- - test/unit/punchout/fabricator_test.rb
75
+ - lib/punchout/fabricable.rb
76
+ - test/unit/punchout_test.rb
77
+ - test/unit/test_helper.rb
78
+ - test/unit/punchout/puncher/matchables_test.rb
79
+ - test/unit/punchout/puncher/matchable_test.rb
80
80
  - test/unit/punchout/matcher/ancestry_test.rb
81
- - test/unit/punchout/matcher/class_test.rb
82
81
  - test/unit/punchout/matcher/equal_test.rb
82
+ - test/unit/punchout/matcher/class_test.rb
83
83
  - test/unit/punchout/matcher/progeny_test.rb
84
84
  - test/unit/punchout/matcher_test.rb
85
- - test/unit/punchout/puncher/matchable_test.rb
86
- - test/unit/punchout/puncher/matchables_test.rb
85
+ - test/unit/punchout/fabricator_test.rb
87
86
  - test/unit/punchout/puncher_test.rb
88
- - test/unit/punchout_test.rb
89
- - test/unit/test_helper.rb
87
+ - test/integration/punchout_test.rb
88
+ - test/integration/test_helper.rb
89
+ - test/integration/punchout/fabricable_test.rb
90
90
  homepage:
91
91
  licenses:
92
92
  - MIT
@@ -107,9 +107,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.1.10
110
+ rubygems_version: 2.0.14
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: A flexible registry pattern gem
114
114
  test_files: []
115
- has_rdoc: