Created
May 21, 2011 21:57
-
-
Save justinko/984935 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RSpec | |
module Mocks | |
module AnyInstance | |
class Chains < Array | |
def add(chain) | |
push(chain) | |
chain | |
end | |
def method_names | |
map {|chain| chain.method_name } | |
end | |
def unplayed | |
reject {|chain| chain.played? } | |
end | |
def expectations | |
chain { select {|chain| chain.is_a?(Expectation) } } | |
end | |
def find_with_siblings(chain) | |
chain { select {|c| c.method_name == chain.method_name } } | |
end | |
def find_by_id(id) | |
find {|chain| chain.object_id == id } | |
end | |
def has_playable_messages(args) | |
reject {|chain| chain.any_unplayable_messages?(args) } | |
end | |
private | |
def chain | |
self.class.new yield | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment