rr 1.0.2 → 1.0.3
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.
- data/CHANGES +6 -0
- data/Gemfile +8 -2
- data/Gemfile.lock +31 -0
- data/README.rdoc +8 -1
- data/lib/rr.rb +1 -0
- data/lib/rr/adapters/minitest.rb +31 -0
- data/lib/rr/double_definitions/double_definition.rb +0 -2
- data/lib/rr/injections/double_injection.rb +11 -4
- data/lib/rr/injections/method_missing_injection.rb +7 -2
- data/lib/rr/injections/singleton_method_added_injection.rb +3 -3
- data/lib/rr/space.rb +5 -0
- data/spec/minitest_spec_suite.rb +21 -0
- data/spec/rr/double_injection/double_injection_verify_spec.rb +1 -1
- data/spec/rr/minitest/minitest_integration_test.rb +59 -0
- data/spec/rr/minitest/test_helper.rb +7 -0
- data/spec/rr/space/space_spec.rb +8 -1
- data/spec/spec_suite.rb +7 -1
- metadata +10 -17
- data/scratch.rb +0 -118
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
1.0.3
|
2
|
+
- Eliminate usage of ObjectSpace._id2ref (Patch Evan Phoenix)
|
3
|
+
- Added minitest adapter (Patch Caleb Spare)
|
4
|
+
- Added instructions on installing the gem (Patch Gavin Miller)
|
5
|
+
- delete missing scratch.rb file from gemspec (Patch bonkydog)
|
6
|
+
|
1
7
|
1.0.2
|
2
8
|
- Fixed Two calls recorded to a mock expecting only one call when called via another mock's yield block (http://github.com/btakita/rr/issues/closed#issue/42). Patch by Eugene Pimenov (http://github.com/libc).
|
3
9
|
|
data/Gemfile
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
1
3
|
group :test do
|
2
4
|
gem "rspec", "1.3.0"
|
3
|
-
gem "session", "
|
5
|
+
gem "session", "3.1.0"
|
4
6
|
gem "diff-lcs", "1.1.2"
|
5
|
-
|
7
|
+
if RUBY_VERSION.include?("1.9")
|
8
|
+
gem "ruby-debug19", "0.11.6"
|
9
|
+
else
|
10
|
+
gem "ruby-debug", "0.10.4"
|
11
|
+
end
|
6
12
|
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
archive-tar-minitar (0.5.2)
|
5
|
+
columnize (0.3.2)
|
6
|
+
diff-lcs (1.1.2)
|
7
|
+
fattr (2.2.0)
|
8
|
+
linecache19 (0.5.12)
|
9
|
+
ruby_core_source (>= 0.1.4)
|
10
|
+
rspec (1.3.0)
|
11
|
+
ruby-debug-base19 (0.11.25)
|
12
|
+
columnize (>= 0.3.1)
|
13
|
+
linecache19 (>= 0.5.11)
|
14
|
+
ruby_core_source (>= 0.1.4)
|
15
|
+
ruby-debug19 (0.11.6)
|
16
|
+
columnize (>= 0.3.1)
|
17
|
+
linecache19 (>= 0.5.11)
|
18
|
+
ruby-debug-base19 (>= 0.11.19)
|
19
|
+
ruby_core_source (0.1.5)
|
20
|
+
archive-tar-minitar (>= 0.5.2)
|
21
|
+
session (3.1.0)
|
22
|
+
fattr
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
diff-lcs (= 1.1.2)
|
29
|
+
rspec (= 1.3.0)
|
30
|
+
ruby-debug19 (= 0.11.6)
|
31
|
+
session (= 3.1.0)
|
data/README.rdoc
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
RR (Double Ruby) is a test double framework that features a rich
|
4
4
|
selection of double techniques and a terse syntax.
|
5
5
|
|
6
|
+
To get started, install RR from the command prompt:
|
7
|
+
|
8
|
+
gem install rr
|
9
|
+
|
6
10
|
== More Information
|
7
11
|
=== Mailing Lists
|
8
12
|
* double-ruby-users@rubyforge.org
|
@@ -356,6 +360,7 @@ If you have directly contributed to RR and I missed you in this list, please let
|
|
356
360
|
* Andreas Haller for patches
|
357
361
|
* Aslak Hellesoy for Developing Rspec
|
358
362
|
* Bryan Helmkamp for patches
|
363
|
+
* Caleb Spare for patches
|
359
364
|
* Christopher Redinger for patches
|
360
365
|
* Dan North for syntax ideas
|
361
366
|
* Dave Astels for some BDD inspiration
|
@@ -364,8 +369,10 @@ If you have directly contributed to RR and I missed you in this list, please let
|
|
364
369
|
* Daniel Sudol for identifing performance issues with RR
|
365
370
|
* Dmitry Ratnikov for patches
|
366
371
|
* Eugene Pimenov for patches
|
372
|
+
* Evan Phoenix for patches
|
367
373
|
* Felix Morio for pairing with me
|
368
374
|
* Gabriel Horner for patches
|
375
|
+
* Gavin Miller for patches
|
369
376
|
* Gerard Meszaros for his excellent book "xUnit Test Patterns"
|
370
377
|
* James Mead for developing Mocha
|
371
378
|
* Jeff Whitmire for documentation suggestions
|
@@ -382,4 +389,4 @@ If you have directly contributed to RR and I missed you in this list, please let
|
|
382
389
|
* Pivotal Labs for sponsoring RR development
|
383
390
|
* Stephen Baker for Developing Rspec
|
384
391
|
* Tatsuya Ono for patches
|
385
|
-
* Tuomas Kareinen for a bug report
|
392
|
+
* Tuomas Kareinen for a bug report
|
data/lib/rr.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
module RR
|
2
|
+
module Adapters
|
3
|
+
module MiniTest
|
4
|
+
include RRMethods
|
5
|
+
def self.included(mod)
|
6
|
+
RR.trim_backtrace = true
|
7
|
+
mod.class_eval do
|
8
|
+
unless instance_methods.any? { |method_name| method_name.to_sym == :setup_with_rr }
|
9
|
+
alias_method :setup_without_rr, :setup
|
10
|
+
def setup_with_rr
|
11
|
+
setup_without_rr
|
12
|
+
RR.reset
|
13
|
+
end
|
14
|
+
alias_method :setup, :setup_with_rr
|
15
|
+
|
16
|
+
alias_method :teardown_without_rr, :teardown
|
17
|
+
def teardown_with_rr
|
18
|
+
RR.verify
|
19
|
+
teardown_without_rr
|
20
|
+
end
|
21
|
+
alias_method :teardown, :teardown_with_rr
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def assert_received(subject, &block)
|
27
|
+
block.call(received(subject)).call
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -119,11 +119,15 @@ module RR
|
|
119
119
|
self
|
120
120
|
end
|
121
121
|
|
122
|
+
BoundObjects = {}
|
123
|
+
|
122
124
|
def bind_method_that_self_destructs_and_delegates_to_method_missing
|
123
|
-
|
125
|
+
id = BoundObjects.size
|
126
|
+
BoundObjects[id] = subject_class
|
127
|
+
|
124
128
|
subject_class.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
125
129
|
def #{method_name}(*args, &block)
|
126
|
-
|
130
|
+
::RR::Injections::DoubleInjection::BoundObjects[#{id}].class_eval do
|
127
131
|
remove_method(:#{method_name})
|
128
132
|
end
|
129
133
|
method_missing(:#{method_name}, *args, &block)
|
@@ -133,11 +137,14 @@ module RR
|
|
133
137
|
end
|
134
138
|
|
135
139
|
def bind_method
|
136
|
-
|
140
|
+
id = BoundObjects.size
|
141
|
+
BoundObjects[id] = subject_class
|
142
|
+
|
137
143
|
subject_class.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
138
144
|
def #{method_name}(*args, &block)
|
139
145
|
arguments = MethodArguments.new(args, block)
|
140
|
-
RR::Injections::DoubleInjection
|
146
|
+
obj = ::RR::Injections::DoubleInjection::BoundObjects[#{id}]
|
147
|
+
RR::Injections::DoubleInjection.dispatch_method(self, obj, :#{method_name}, arguments.arguments, arguments.block)
|
141
148
|
end
|
142
149
|
RUBY
|
143
150
|
self
|
@@ -51,11 +51,16 @@ module RR
|
|
51
51
|
end
|
52
52
|
|
53
53
|
protected
|
54
|
+
BoundObjects = {}
|
55
|
+
|
54
56
|
def bind_method
|
55
|
-
|
57
|
+
id = BoundObjects.size
|
58
|
+
BoundObjects[id] = subject_class
|
59
|
+
|
56
60
|
subject_class.class_eval((<<-METHOD), __FILE__, __LINE__ + 1)
|
57
61
|
def method_missing(method_name, *args, &block)
|
58
|
-
|
62
|
+
obj = ::RR::Injections::MethodMissingInjection::BoundObjects[#{id}]
|
63
|
+
MethodDispatches::MethodMissingDispatch.new(self, obj, method_name, args, block).call
|
59
64
|
end
|
60
65
|
METHOD
|
61
66
|
end
|
@@ -29,9 +29,9 @@ module RR
|
|
29
29
|
unless class_instance_method_defined(subject_class, :singleton_method_added, false)
|
30
30
|
@placeholder_method_defined = true
|
31
31
|
subject_class.class_eval do
|
32
|
-
def singleton_method_added(method_name)
|
33
|
-
|
34
|
-
end
|
32
|
+
#def singleton_method_added(method_name)
|
33
|
+
# super
|
34
|
+
#end
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
data/lib/rr/space.rb
CHANGED
@@ -63,6 +63,7 @@ module RR
|
|
63
63
|
reset_method_missing_injections
|
64
64
|
reset_singleton_method_added_injections
|
65
65
|
reset_recorded_calls
|
66
|
+
reset_bound_objects
|
66
67
|
end
|
67
68
|
|
68
69
|
# Verifies the DoubleInjection for the passed in subject and method_name.
|
@@ -108,5 +109,9 @@ module RR
|
|
108
109
|
def reset_recorded_calls
|
109
110
|
@recorded_calls.clear
|
110
111
|
end
|
112
|
+
|
113
|
+
def reset_bound_objects
|
114
|
+
RR::Injections::DoubleInjection::BoundObjects.clear
|
115
|
+
end
|
111
116
|
end
|
112
117
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "spec"
|
3
|
+
|
4
|
+
class MiniTestTestSuite
|
5
|
+
def run
|
6
|
+
require_tests
|
7
|
+
|
8
|
+
puts "Running MiniTest Test Suite"
|
9
|
+
end
|
10
|
+
|
11
|
+
def require_tests
|
12
|
+
dir = File.dirname(__FILE__)
|
13
|
+
Dir["#{dir}/rr/minitest/**/*_test.rb"].each do |file|
|
14
|
+
require File.expand_path(file)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
if $0 == __FILE__
|
20
|
+
MiniTestTestSuite.new.run
|
21
|
+
end
|
@@ -4,7 +4,7 @@ module RR
|
|
4
4
|
module Injections
|
5
5
|
describe DoubleInjection, "#verify" do
|
6
6
|
it_should_behave_like "Swapped Space"
|
7
|
-
attr_reader :
|
7
|
+
attr_reader :subject, :method_name, :double_injection
|
8
8
|
before do
|
9
9
|
@subject = Object.new
|
10
10
|
@method_name = :foobar
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/test_helper")
|
2
|
+
|
3
|
+
class MiniTestIntegrationTest < MiniTest::Unit::TestCase
|
4
|
+
include RR::Adapters::MiniTest # Testing against double inclusion issues
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
@subject = Object.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_using_a_mock
|
16
|
+
mock(@subject).foobar(1, 2) {:baz}
|
17
|
+
assert_equal :baz, @subject.foobar(1, 2)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_using_a_stub
|
21
|
+
stub(@subject).foobar {:baz}
|
22
|
+
assert_equal :baz, @subject.foobar("any", "thing")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_using_a_mock_proxy
|
26
|
+
def @subject.foobar
|
27
|
+
:baz
|
28
|
+
end
|
29
|
+
|
30
|
+
mock.proxy(@subject).foobar
|
31
|
+
assert_equal :baz, @subject.foobar
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_using_a_stub_proxy
|
35
|
+
def @subject.foobar
|
36
|
+
:baz
|
37
|
+
end
|
38
|
+
|
39
|
+
stub.proxy(@subject).foobar
|
40
|
+
assert_equal :baz, @subject.foobar
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_times_called_verification
|
44
|
+
mock(@subject).foobar(1, 2) {:baz}
|
45
|
+
assert_raises RR::Errors::TimesCalledError do
|
46
|
+
teardown
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_using_assert_received
|
51
|
+
stub(@subject).foobar(1, 2)
|
52
|
+
@subject.foobar(1, 2)
|
53
|
+
assert_received(@subject) {|subject| subject.foobar(1, 2)}
|
54
|
+
|
55
|
+
assert_raises RR::Errors::SpyVerificationErrors::InvocationCountError do
|
56
|
+
assert_received(@subject) {|subject| subject.foobar(1, 2, 3)}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/spec/rr/space/space_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
|
3
3
|
module RR
|
4
4
|
describe Space do
|
5
5
|
it_should_behave_like "Swapped Space"
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :subject, :method_name, :double_injection
|
7
7
|
|
8
8
|
before do
|
9
9
|
@subject = Object.new
|
@@ -279,6 +279,13 @@ module RR
|
|
279
279
|
subject_2.respond_to?(:singleton_method_added).should be_false
|
280
280
|
Injections::SingletonMethodAddedInjection.exists?(subject_2).should be_false
|
281
281
|
end
|
282
|
+
|
283
|
+
it "clears RR::Injections::DoubleInjection::BoundObjects" do
|
284
|
+
stub(subject).foobar
|
285
|
+
RR::Injections::DoubleInjection::BoundObjects.should_not be_empty
|
286
|
+
space.reset
|
287
|
+
RR::Injections::DoubleInjection::BoundObjects.should be_empty
|
288
|
+
end
|
282
289
|
end
|
283
290
|
|
284
291
|
describe "#reset_double" do
|
data/spec/spec_suite.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "rubygems"
|
2
|
+
require "bundler"
|
2
3
|
require "session"
|
3
4
|
|
4
5
|
class ExampleSuite
|
@@ -11,6 +12,7 @@ class ExampleSuite
|
|
11
12
|
run_core_examples
|
12
13
|
run_rspec_examples
|
13
14
|
run_test_unit_examples
|
15
|
+
run_minitest_examples
|
14
16
|
end
|
15
17
|
|
16
18
|
def run_core_examples
|
@@ -25,6 +27,10 @@ class ExampleSuite
|
|
25
27
|
run_suite("#{dir}/test_unit_spec_suite.rb") || raise("Test::Unit suite Failed")
|
26
28
|
end
|
27
29
|
|
30
|
+
def run_minitest_examples
|
31
|
+
run_suite("#{dir}/minitest_spec_suite.rb") || raise("MiniTest suite Failed")
|
32
|
+
end
|
33
|
+
|
28
34
|
def run_suite(path)
|
29
35
|
# From http://www.eglug.org/node/946
|
30
36
|
bash.execute "exec 3>&1", :out => STDOUT, :err => STDERR
|
@@ -45,4 +51,4 @@ end
|
|
45
51
|
|
46
52
|
if $0 == __FILE__
|
47
53
|
ExampleSuite.new.run
|
48
|
-
end
|
54
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 1.0.2
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.3
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Brian Takita
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date:
|
13
|
+
date: 2011-06-16 00:00:00 -07:00
|
19
14
|
default_executable:
|
20
15
|
dependencies: []
|
21
16
|
|
@@ -31,11 +26,13 @@ extra_rdoc_files:
|
|
31
26
|
files:
|
32
27
|
- CHANGES
|
33
28
|
- Gemfile
|
29
|
+
- Gemfile.lock
|
34
30
|
- LICENSE
|
35
31
|
- README.rdoc
|
36
32
|
- Rakefile
|
37
33
|
- VERSION.yml
|
38
34
|
- lib/rr.rb
|
35
|
+
- lib/rr/adapters/minitest.rb
|
39
36
|
- lib/rr/adapters/rr_methods.rb
|
40
37
|
- lib/rr/adapters/rspec.rb
|
41
38
|
- lib/rr/adapters/test_unit.rb
|
@@ -109,7 +106,6 @@ files:
|
|
109
106
|
- lib/rr/wildcard_matchers/range.rb
|
110
107
|
- lib/rr/wildcard_matchers/regexp.rb
|
111
108
|
- lib/rr/wildcard_matchers/satisfy.rb
|
112
|
-
- scratch.rb
|
113
109
|
- spec/api/any_instance_of/all_instances_of_spec.rb
|
114
110
|
- spec/api/any_instance_of/any_instance_of_spec.rb
|
115
111
|
- spec/api/any_instance_of/instance_of_spec.rb
|
@@ -121,6 +117,7 @@ files:
|
|
121
117
|
- spec/api/stub/stub_spec.rb
|
122
118
|
- spec/core_spec_suite.rb
|
123
119
|
- spec/environment_fixture_setup.rb
|
120
|
+
- spec/minitest_spec_suite.rb
|
124
121
|
- spec/proc_from_block_spec.rb
|
125
122
|
- spec/rr/adapters/rr_methods_argument_matcher_spec.rb
|
126
123
|
- spec/rr/adapters/rr_methods_creator_spec.rb
|
@@ -148,6 +145,8 @@ files:
|
|
148
145
|
- spec/rr/expectations/times_called_expectation/times_called_expectation_integer_spec.rb
|
149
146
|
- spec/rr/expectations/times_called_expectation/times_called_expectation_proc_spec.rb
|
150
147
|
- spec/rr/expectations/times_called_expectation/times_called_expectation_range_spec.rb
|
148
|
+
- spec/rr/minitest/minitest_integration_test.rb
|
149
|
+
- spec/rr/minitest/test_helper.rb
|
151
150
|
- spec/rr/rspec/invocation_matcher_spec.rb
|
152
151
|
- spec/rr/rspec/rspec_adapter_spec.rb
|
153
152
|
- spec/rr/rspec/rspec_backtrace_tweaking_spec.rb
|
@@ -195,27 +194,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
194
|
requirements:
|
196
195
|
- - ">="
|
197
196
|
- !ruby/object:Gem::Version
|
198
|
-
hash: 3
|
199
|
-
segments:
|
200
|
-
- 0
|
201
197
|
version: "0"
|
202
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
199
|
none: false
|
204
200
|
requirements:
|
205
201
|
- - ">="
|
206
202
|
- !ruby/object:Gem::Version
|
207
|
-
hash: 3
|
208
|
-
segments:
|
209
|
-
- 0
|
210
203
|
version: "0"
|
211
204
|
requirements: []
|
212
205
|
|
213
206
|
rubyforge_project: pivotalrb
|
214
|
-
rubygems_version: 1.3.
|
207
|
+
rubygems_version: 1.3.9.2
|
215
208
|
signing_key:
|
216
209
|
specification_version: 3
|
217
210
|
summary: RR (Double Ruby) is a double framework that features a rich selection of double techniques and a terse syntax. http://xunitpatterns.com/Test%20Double.html
|
218
211
|
test_files:
|
219
|
-
- spec/spy_verification_spec.rb
|
220
212
|
- spec/proc_from_block_spec.rb
|
221
213
|
- spec/rr_spec.rb
|
214
|
+
- spec/spy_verification_spec.rb
|
data/scratch.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
o = Object.new
|
2
|
-
#p (class << o; self; end).singleton_methods
|
3
|
-
#p (class << o; self; end).superclass
|
4
|
-
|
5
|
-
klass = Class.new
|
6
|
-
p klass
|
7
|
-
p klass.superclass
|
8
|
-
p (class << klass; self; end).superclass
|
9
|
-
p (class << Class; self; end)
|
10
|
-
|
11
|
-
p Class.new
|
12
|
-
|
13
|
-
##any_instance_of(Person, :id => 111, :to_s => "Joe Smith")
|
14
|
-
##
|
15
|
-
##any_instance_of(Person) do |person|
|
16
|
-
## person.id {111}
|
17
|
-
## person.to_s {"Joe Smith"}
|
18
|
-
##end
|
19
|
-
##
|
20
|
-
##new_instance_of(Person, :id => 111, :to_s => "Joe Smith")
|
21
|
-
##new_instance_of(Person) do |person|
|
22
|
-
## person.id {111}
|
23
|
-
## person.to_s {"Joe Smith"}
|
24
|
-
##end
|
25
|
-
#
|
26
|
-
#class Sut
|
27
|
-
# def existing_method
|
28
|
-
# "existing_method"
|
29
|
-
# end
|
30
|
-
#end
|
31
|
-
#
|
32
|
-
#class Dispatcher
|
33
|
-
# def self.call(subject, method_name, *args, &block)
|
34
|
-
# new(subject, method_name, *args, &block).call
|
35
|
-
# end
|
36
|
-
#
|
37
|
-
# attr_reader :method_name
|
38
|
-
# def initialize(subject, method_name, *args, &block)
|
39
|
-
# @subject, @method_name, @args, @block = subject, method_name, args, block
|
40
|
-
# end
|
41
|
-
#
|
42
|
-
# def call
|
43
|
-
#
|
44
|
-
# end
|
45
|
-
#end
|
46
|
-
#
|
47
|
-
#Sut.class_eval do
|
48
|
-
# alias_method :existing_method_without_rr, :existing_method
|
49
|
-
#
|
50
|
-
# def existing_method(*args, &block)
|
51
|
-
# Dispatcher.call(self, :existing_method, *args, &block)
|
52
|
-
# end
|
53
|
-
#end
|
54
|
-
|
55
|
-
#class SubjectClass
|
56
|
-
# def foo
|
57
|
-
# :foo_original
|
58
|
-
# end
|
59
|
-
#
|
60
|
-
# def _dump(arg)
|
61
|
-
# ""
|
62
|
-
# end
|
63
|
-
#end
|
64
|
-
#subject = SubjectClass.new
|
65
|
-
#
|
66
|
-
#class << subject
|
67
|
-
# p self.class
|
68
|
-
# class << self
|
69
|
-
# def foobar
|
70
|
-
# :baz
|
71
|
-
# end
|
72
|
-
# end
|
73
|
-
# p foobar
|
74
|
-
#end
|
75
|
-
#
|
76
|
-
#Foo = Module.new do
|
77
|
-
# def foo
|
78
|
-
# :foo_module
|
79
|
-
# end
|
80
|
-
#end
|
81
|
-
#Bar = Module.new do
|
82
|
-
# def foo
|
83
|
-
# :bar_module
|
84
|
-
# end
|
85
|
-
#end
|
86
|
-
##module Foo
|
87
|
-
## def foo
|
88
|
-
## end
|
89
|
-
##end
|
90
|
-
#
|
91
|
-
#subject.extend Foo
|
92
|
-
#end
|
93
|
-
#p subject.foo
|
94
|
-
#p Marshal.dump(subject)
|
95
|
-
|
96
|
-
|
97
|
-
class Super
|
98
|
-
|
99
|
-
end
|
100
|
-
class Sub < Super
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
def Super.foo
|
105
|
-
:bar
|
106
|
-
end
|
107
|
-
|
108
|
-
def Sub.foo
|
109
|
-
super
|
110
|
-
end
|
111
|
-
|
112
|
-
s = Super.new
|
113
|
-
p s.object_id
|
114
|
-
p (class << s; self; end).object_id
|
115
|
-
p s.class
|
116
|
-
#subject.extend Bar
|
117
|
-
#def subject.foo
|
118
|
-
# :singleton_foo
|