proxies 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -29,7 +29,7 @@ module Proxies
29
29
  @owner = owner
30
30
  @method_name = method_name
31
31
 
32
- extends = Array(options[:extend])
32
+ extends = ::Kernel.Array(options[:extend])
33
33
  extends << ::Module.new(&block)
34
34
  extends.each { |m| m.send(:extend_object, self) }
35
35
  end
@@ -33,9 +33,9 @@ module Proxies
33
33
  @target = target
34
34
  @owner = options[:owner] if options.key?(:owner)
35
35
 
36
- extends = Array(options[:extend])
36
+ extends = ::Kernel.Array(options[:extend])
37
37
  extends << ::Module.new(&block)
38
- extends << ObjectProxyOwner if defined?(@owner)
38
+ extends << ::Proxies::ObjectProxyOwner if defined?(@owner)
39
39
  extends.each { |m| m.send(:extend_object, self) }
40
40
  end
41
41
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{proxies}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jakub Kuźma"]
@@ -4,36 +4,51 @@ class TestMethodProxyTarget < Test::Unit::TestCase
4
4
  def setup
5
5
  @target = "target"
6
6
  @object = mock
7
- @object.expects(:target_method).once.returns(@target)
8
- @proxy = MethodProxy.new(@object, :target_method) do
9
- def length_plus_one
10
- proxy_target.length + 1
11
- end
12
- end
13
7
  end
14
8
 
15
9
  test "non-existing proxy method call is passed to the target" do
10
+ @object.expects(:target_method).once.returns(@target)
11
+ @proxy = MethodProxy.new(@object, :target_method)
16
12
  assert_equal @target.length, @proxy.length
17
13
  end
18
14
 
19
15
  test "proxy method returns correct result" do
16
+ @object.expects(:target_method).once.returns(@target)
17
+ @proxy = MethodProxy.new(@object, :target_method) do
18
+ def length_plus_one
19
+ proxy_target.length + 1
20
+ end
21
+ end
20
22
  assert_equal @target.length + 1, @proxy.length_plus_one
21
23
  end
22
24
 
23
25
  test "object_id method call is passed to proxy target" do
26
+ @object.expects(:target_method).once.returns(@target)
27
+ @proxy = MethodProxy.new(@object, :target_method)
24
28
  assert_equal @target.object_id, @proxy.object_id
25
29
  end
26
30
 
27
31
  test "send method call is passed to proxy target" do
32
+ @object.expects(:target_method).once.returns(@target)
33
+ @proxy = MethodProxy.new(@object, :target_method)
28
34
  assert_equal @target.send(:length), @proxy.send(:length)
29
35
  end
30
36
 
31
37
  test "== method is passed to proxy_target" do
38
+ @object.expects(:target_method).once.returns(@target)
39
+ @proxy = MethodProxy.new(@object, :target_method)
32
40
  assert @target == @proxy
33
41
  assert @proxy == @target
34
42
  end
35
43
 
36
44
  test "equal? method is passed to proxy_target" do
45
+ @object.expects(:target_method).once.returns(@target)
46
+ @proxy = MethodProxy.new(@object, :target_method)
37
47
  assert @proxy.equal?(@target)
38
48
  end
49
+
50
+ test "target_method is not called if not needed" do
51
+ @proxy = MethodProxy.new(@object, :target_method)
52
+ assert_equal @object, @proxy.proxy_owner
53
+ end
39
54
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Jakub Ku\xC5\xBAma"