Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Yield matchers #129

Merged
merged 17 commits into from Apr 19, 2012
Commits on Mar 27, 2012
Commits on Mar 29, 2012
Commits on Mar 30, 2012
  1. Match yielded args with == or ===.

    myronmarston committed Mar 30, 2012
    Previously, this expectation failed:
    
      expect { |b| _yield_with_args(String, Fixnum, &b) }.to yield_with_args(String, Fixnum)
    
    ...because Class=== returns false when given itself.
Commits on Mar 31, 2012
  1. Remove diffability from yield matchers for now.

    myronmarston committed Mar 31, 2012
    I'm not sure it makes sense given that they don't match strictly but instead match using === or ==.
  2. Fix yield matchers to handle instance_eval.

    myronmarston committed Mar 31, 2012
    It's debatable if instance_eval'ing a block can be considered yielding, but it's important that we use local variables in the lambdas rather than instance variables, because we don't want to modify the state of the receiver of #instance_eval.
  3. Raise an error if a yield matcher is used w/ an expect block that acc…

    myronmarston committed Mar 31, 2012
    …epts no args.
    
    The expect block must accept an arg, and pass it on to the method-under-test as a block, in order for these yield matchers to work properly.  Since this is atypical for an expect block, this error will help guide people when they use these matchers incorrectly.
Commits on Apr 1, 2012
  1. Add API docs for yield matchers.

    myronmarston committed Apr 1, 2012
    Cukes are still to come.
Commits on Apr 10, 2012
  1. Raise an error if expect block arg isn't passed on as a block.

    myronmarston committed Apr 10, 2012
    Otherwise, the matcher is unable to detect anything about if the method-under-test yields, and the user may get false positives.
  2. Refactor yield matchers a bit.

    myronmarston committed Apr 10, 2012
    This allows the YieldProbe to take care of defining the probe block, and simplifies the #matches? methods.
  3. Raise an error if a single-yield matcher is used with a multi-yield m…

    myronmarston committed Apr 10, 2012
    …ethod.
    
    Only the yield_successive_args matcher is designed for the multi-yield case.
Commits on Apr 11, 2012