casting 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -64,6 +64,10 @@ module Casting
64
64
  end
65
65
  end
66
66
 
67
+ def respond_to_missing?(meth, *)
68
+ delegate_has_method?(meth) || super
69
+ end
70
+
67
71
  private
68
72
 
69
73
  def delegate_has_method?(meth)
@@ -1,3 +1,3 @@
1
1
  module Casting
2
- VERSION = '0.4.1'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -36,6 +36,19 @@ describe Casting, '.delegating' do
36
36
  client.greet
37
37
  }
38
38
  end
39
+
40
+ it 'responds to added methods inside the block' do
41
+ client = test_person.extend(Casting::Client)
42
+ client.delegate_missing_methods
43
+
44
+ assert !client.respond_to?(:greet)
45
+
46
+ Casting.delegating(client => TestPerson::Greeter) do
47
+ assert client.respond_to?(:greet)
48
+ end
49
+
50
+ assert !client.respond_to?(:greet)
51
+ end
39
52
  end
40
53
 
41
54
  describe Casting::Delegation do
@@ -81,15 +94,11 @@ describe Casting::Delegation do
81
94
 
82
95
  it 'assigns arguments to the delegated method using with' do
83
96
  client = test_person
84
- attendant = TestPerson.new
85
- attendant.extend(TestPerson::Verbose)
97
+ attendant = TestPerson::Verbose
86
98
 
87
99
  delegation = Casting::Delegation.new('verbose', client).to(attendant)
88
100
 
89
- attendant_output = attendant.verbose('hello', 'goodbye')
90
- delegation_output = delegation.with('hello', 'goodbye').call
91
-
92
- assert_equal attendant_output, delegation_output
101
+ assert_equal 'hello,goodbye', delegation.with('hello', 'goodbye').call
93
102
  end
94
103
 
95
104
  it 'prefers `call` arguments over `with`' do
@@ -98,10 +107,7 @@ describe Casting::Delegation do
98
107
 
99
108
  delegation = Casting::Delegation.new('verbose', client).to(attendant)
100
109
 
101
- attendant_output = attendant.verbose('call', 'args')
102
- delegation_output = delegation.with('hello', 'goodbye').call('call','args')
103
-
104
- assert_equal attendant_output, delegation_output
110
+ assert_equal 'call,args', delegation.with('hello', 'goodbye').call('call','args')
105
111
  end
106
112
  end
107
113
 
@@ -123,21 +129,17 @@ describe Casting::Client do
123
129
  it 'adds a delegate method to call a method on an attendant' do
124
130
  client = TestPerson.new
125
131
  client.extend(Casting::Client)
126
- attendant = TestPerson.new
127
- attendant.extend(TestPerson::Greeter)
128
- assert_equal attendant.greet, client.delegate('greet', attendant)
132
+ attendant = TestPerson::Greeter
133
+
134
+ assert_equal 'hello', client.delegate('greet', attendant)
129
135
  end
130
136
 
131
137
  it 'passes additional parameters to the attendant' do
132
138
  client = TestPerson.new
133
139
  client.extend(Casting::Client)
134
- attendant = TestPerson.new
135
- attendant.extend(TestPerson::Verbose)
136
-
137
- attendant_output = attendant.verbose('hello', 'goodbye')
138
- client_output = client.delegate('verbose', attendant, 'hello', 'goodbye')
140
+ attendant = TestPerson::Verbose
139
141
 
140
- assert_equal attendant_output, client_output
142
+ assert_equal 'hello,goodbye', client.delegate('verbose', attendant, 'hello', 'goodbye')
141
143
  end
142
144
 
143
145
  it 'passes the object as the client for delegation' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: casting
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
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-05-23 00:00:00.000000000 Z
12
+ date: 2013-05-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redcard