forked from rspec/rspec-mocks
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue rspec#70 add support for #stub_chain to any_instance
- Loading branch information
Showing
7 changed files
with
109 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module RSpec | ||
module Mocks | ||
module AnyInstance | ||
class StubChainChain < Chain | ||
def initialize(*args, &block) | ||
record(:stub_chain, *args, &block) | ||
end | ||
|
||
def invocation_order | ||
@invocation_order ||= { | ||
:stub_chain => [nil], | ||
:and_return => [:stub_chain], | ||
:and_raise => [:stub_chain], | ||
:and_yield => [:stub_chain] | ||
} | ||
end | ||
|
||
def expectation_fulfilled? | ||
true | ||
end | ||
|
||
def expectation_fulfilled! | ||
end | ||
|
||
private | ||
def verify_invocation_order(rspec_method_name, *args, &block) | ||
unless invocation_order[rspec_method_name].include?(last_message) | ||
raise(NoMethodError, "Undefined method #{rspec_method_name}") | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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