Skip to content

Commit

Permalink
Performance increase on RR module methods.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://rubyforge.org/var/svn/pivotalrb/rr/trunk@1619 af276e61-6b34-4dac-905b-574b5f35ef33
  • Loading branch information
btakita committed Jun 12, 2008
1 parent fb882ec commit ea2cf8a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- Proxying from RR module to RR::Space.instance

* 0.4.8
- Fixed issue with Hash arguments

Expand Down
10 changes: 7 additions & 3 deletions lib/rr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@

module RR
class << self
protected
def method_missing(method_name, *args, &block)
RR::Space.instance.__send__(method_name, *args, &block)
(RR::Space.instance_methods - Object.instance_methods).each do |method_name|
returns_method = <<-METHOD
def #{method_name}(*args, &block)
RR::Space.instance.__send__(:#{method_name}, *args, &block)
end
METHOD
class_eval(returns_method, __FILE__, __LINE__ - 4)
end
end
end
6 changes: 3 additions & 3 deletions lib/rr/adapters/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ def self.included(mod)

include RRMethods
def setup_mocks_for_rspec
rr_reset
RR.reset
end
def verify_mocks_for_rspec
rr_verify
RR.verify
end
def teardown_mocks_for_rspec
rr_reset
RR.reset
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rr/adapters/test_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ def self.included(mod)
alias_method :setup_without_rr, :setup
def setup_with_rr
setup_without_rr
rr_reset
RR.reset
end
alias_method :setup, :setup_with_rr

alias_method :teardown_without_rr, :teardown
def teardown_with_rr
rr_verify
RR.verify
teardown_without_rr
end
alias_method :teardown, :teardown_with_rr
Expand Down

0 comments on commit ea2cf8a

Please sign in to comment.