Module: RSpecProxies::ProxyChains
- Defined in:
- lib/rspecproxies/proxy_chains.rb
Instance Method Summary collapse
-
#proxy_message_chain(message_chain, &last_proxy_setup_block) ⇒ Object
Sets up proxies all down the selector chain, until the last where a simple method stub is created and on which the block is called.
-
#proxy_message_chain_a(messages, &last_proxy_setup_block) ⇒ Object
Same as #proxy_message_chain but using an array of symbols as message_chain instead of a dot separated string.
Instance Method Details
#proxy_message_chain(message_chain, &last_proxy_setup_block) ⇒ Object
Sets up proxies all down the selector chain, until the last where a simple method stub is created and on which the block is called. Allows to set up stub chains quickly and safely.
message_chain : a dot separated message chain, like the standard message_chain expectation
13 14 15 |
# File 'lib/rspecproxies/proxy_chains.rb', line 13 def (, &last_proxy_setup_block) ((.split('.').map &:intern), &last_proxy_setup_block) end |
#proxy_message_chain_a(messages, &last_proxy_setup_block) ⇒ Object
Same as #proxy_message_chain but using an array of symbols as message_chain instead of a dot separated string
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rspecproxies/proxy_chains.rb', line 19 def (, &last_proxy_setup_block) = .first return last_proxy_setup_block.call(receive()) if .size == 1 receive().and_wrap_original do |m, *args, &original_block| result = m.call(*args, &original_block) allow(result).to (.drop(1), &last_proxy_setup_block) result end end |