Permalink
Browse files

Alternate implementation for solution to #8.

  • Loading branch information...
1 parent bf88315 commit 2707f78a94f2ef1e7f3be71c4520073784aa9769 @justinko justinko committed with dchelimsky Jul 31, 2010
Showing with 2 additions and 4 deletions.
  1. +2 −3 lib/rspec/mocks/methods.rb
  2. +0 −1 spec/rspec/mocks/stub_chain_spec.rb
@@ -23,10 +23,9 @@ def unstub(sym)
alias_method :stub!, :stub
alias_method :unstub!, :unstub
-
+
def stub_chain(*methods)
- if methods.length > 1 or (methods.length == 1 and methods.first.is_a?(String) and (string_chain = methods.first))
- methods = string_chain.split('.').map{|x|x.to_sym} if string_chain
+ if methods = methods.join('.').split('.') and methods.length > 1
next_in_chain = Object.new
stub!(methods.shift) {next_in_chain}
next_in_chain.stub_chain(*methods)
@@ -34,7 +34,6 @@ module Mocks
@subject.stub_chain("msg1.msg2.msg3").and_return(:return_value)
@subject.msg1.msg2.msg3.should equal(:return_value)
end
-
end
end
end

0 comments on commit 2707f78

Please sign in to comment.