Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Dynamic predicate matchers #15

Closed
wants to merge 18 commits into from

2 participants

@lukeredpath

(sorry, this also includes the commits of my other pull request - not sure how to work around that).

The newest commits on this pull request add support for dynamic predicate matchers. You still need to define the matcher interfaces to satisfy the compiler but you don't need the corresponding matcher implementation as it will be handled at runtime.

Example from the test case:

@interface LightSwitch : NSObject
@property (nonatomic, assign, getter=isTurnedOn) BOOL turnedOn;
@end

@implementation LightSwitch
@synthesize turnedOn;
@end

EXPMatcherInterface(isTurnedOn, (void));
#define beTurnedOn isTurnedOn

@interface DynamicPredicateMatcherTest : SenTestCase
@end

@implementation DynamicPredicateMatcherTest

- (void)test_CanUseObjectPredicatesAsBooleanMatchers
{
  LightSwitch *lightSwitch = [[LightSwitch alloc] init];

  lightSwitch.turnedOn = YES;

  expect(lightSwitch).to.beTurnedOn();

  lightSwitch.turnedOn = NO;

  expect(lightSwitch).toNot.beTurnedOn();
}

@end
David Hart and others added some commits
David Hart Fixed a false negative bug with asynchronous negatives
When expecting an asynchronous negative, if the matchBlock returns
true, we will return a fail before waiting the timeout. I modified the
asynchronous tests to fail with that bug and fixed the bug by taking
into account the negative in the asynchronous loop.
c7c3e7b
David Hart Improved the naming convention. 177811f
David Hart Added beCloseTo matcher. 6229f4e
David Hart Missing beCloseTo import 55f55ea
David Hart Renamed test classes to correspond to the new naming scheme. 7e7482d
David Hart Removed a ghost of the exception handling in the project file. 64b8a0e
David Hart Updated to README to show the new modifications b418527
David Hart Added the ability for the contain matcher to use any NSFastEnumeratio…
…n object.
efa56e3
David Hart Upgraded to Xcode 4.3 e48fc10
David Hart Fix ARC warning and avoid having to bridge id objects fcb91db
David Hart Added a beCountOf matcher for collections fa90b27
@lukeredpath lukeredpath Start to move towards supporting a generic protocol for matching.
The EXPRuntimeMatcher supports the existing method of defining matchers,
and moves matcher state out of the EXPExpect object.
9c54336
@lukeredpath lukeredpath This seems like a better name for this class. 935bf00
@lukeredpath lukeredpath Make `applyMatcher:to:` actually depend solely on the EXPMatcher prot…
…ocol,

rather than the BlockDefinedMatcher implementation, by having BlockDefinedMatcher
actually implement the protocol.
b522b21
@lukeredpath lukeredpath Added a test that demonstrates the use of a custom matcher class. 54343d4
@lukeredpath lukeredpath Make everything in the EXPMatcher protocol optional, except for matches: 9b11fb6
@lukeredpath lukeredpath Added support for dynamic predicate matchers.
We still need to define the matcher interface to satisfy the compiler 
but we don't need to do any matcher implementation as it can be handled
at runtime.
d2a3068
@lukeredpath lukeredpath Added notes on dynamic dispatch predicates to README 3206188
@petejkim petejkim closed this
@petejkim
Owner

This is amazing. Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 7, 2012
  1. Fixed a false negative bug with asynchronous negatives

    David Hart authored
    When expecting an asynchronous negative, if the matchBlock returns
    true, we will return a fail before waiting the timeout. I modified the
    asynchronous tests to fail with that bug and fixed the bug by taking
    into account the negative in the asynchronous loop.
Commits on Mar 9, 2012
  1. Improved the naming convention.

    David Hart authored
  2. Added beCloseTo matcher.

    David Hart authored
Commits on Mar 12, 2012
  1. Missing beCloseTo import

    David Hart authored
Commits on Mar 14, 2012
Commits on Mar 15, 2012
  1. Updated to README to show the new modifications

    David Hart authored
Commits on Mar 16, 2012
  1. Upgraded to Xcode 4.3

    David Hart authored
  2. Added a beCountOf matcher for collections

    David Hart authored
Commits on Mar 26, 2012
  1. @lukeredpath

    Start to move towards supporting a generic protocol for matching.

    lukeredpath authored
    The EXPRuntimeMatcher supports the existing method of defining matchers,
    and moves matcher state out of the EXPExpect object.
  2. @lukeredpath
  3. @lukeredpath

    Make `applyMatcher:to:` actually depend solely on the EXPMatcher prot…

    lukeredpath authored
    …ocol,
    
    rather than the BlockDefinedMatcher implementation, by having BlockDefinedMatcher
    actually implement the protocol.
  4. @lukeredpath
  5. @lukeredpath
  6. @lukeredpath

    Added support for dynamic predicate matchers.

    lukeredpath authored
    We still need to define the matcher interface to satisfy the compiler 
    but we don't need to do any matcher implementation as it can be handled
    at runtime.
  7. @lukeredpath
Something went wrong with that request. Please try again.