-
-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide block syntax for sequences #61
Comments
Any update with this? I've taken to writing a little helper in my tests so that I can use class SequenceHelper
def initialize(name)
@seq = sequence(name)
end
def <<(expectation)
expectation.in_sequence(@seq)
end
end |
I noticed the sequence experiment branch. I came up with almost the same implementation independently for sequence blocks. Some other ideas:
For option 3, a trick is needed. As far as I can tell, any local variables in the block binding supersede everything else, so we'd have to get the source of the block (using Proc#source_location) and eval the code to make a new block, and then use method_missing to wrap the objects. Any thoughts? |
All expectations defined within the block are constrained by the sequence: egg = mock('egg') sequence('breakfast') do egg.expects(:crack) egg.expects(:fry) egg.expects(:eat) end Closes #61 (only 11 years late!)
All expectations defined within the block are constrained by the sequence. For example, the following requires that Egg#crack must be called 1st, Egg#fry must be called 2nd, and Egg#eat must be called 3rd: egg = mock('egg') sequence('breakfast') do egg.expects(:crack) egg.expects(:fry) egg.expects(:eat) end Closes #61 (only 11 years late!)
All expectations defined within the block are constrained by the sequence. For example, the following requires that Egg#crack must be called 1st, Egg#fry must be called 2nd, and Egg#eat must be called 3rd: egg = mock('egg') sequence('breakfast') do egg.expects(:crack) egg.expects(:fry) egg.expects(:eat) end Closes #61 (only 11 years late!)
All expectations defined within the block are constrained by the sequence. For example, the following requires that Egg#crack must be called 1st, Egg#fry must be called 2nd, and Egg#eat must be called 3rd: egg = mock('egg') sequence('breakfast') do egg.expects(:crack) egg.expects(:fry) egg.expects(:eat) end Closes #61 (only 11 years late!)
All expectations defined within the block are constrained by the sequence. For example, the following requires that Egg#crack must be called 1st, Egg#fry must be called 2nd, and Egg#eat must be called 3rd: egg = mock('egg') sequence('breakfast') do egg.expects(:crack) egg.expects(:fry) egg.expects(:eat) end Closes #61 (only 11 years late!)
It should be possible to provide the following syntax for a simple sequence i.e. one that is not interleaved with another :-
Any expectations within the block would be assigned to the sequence specified in the block.
See https://gist.github.com/1704783 for some relation discussions.
The text was updated successfully, but these errors were encountered: