UIAlertViewRACSupportSpec.m 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // UIAlertViewRACSupportSpec.m
  3. // ReactiveCocoa
  4. //
  5. // Created by Henrik Hodne on 6/16/13.
  6. // Copyright (c) 2013 GitHub, Inc. All rights reserved.
  7. //
  8. #import <Quick/Quick.h>
  9. #import <Nimble/Nimble.h>
  10. #import <objc/message.h>
  11. #import "RACSignal.h"
  12. #import "UIAlertView+RACSignalSupport.h"
  13. QuickSpecBegin(UIAlertViewRACSupportSpec)
  14. qck_describe(@"UIAlertView", ^{
  15. __block UIAlertView *alertView;
  16. qck_beforeEach(^{
  17. alertView = [[UIAlertView alloc] initWithFrame:CGRectZero];
  18. expect(alertView).notTo(beNil());
  19. });
  20. qck_it(@"sends the index of the clicked button to the buttonClickedSignal when a button is clicked", ^{
  21. __block NSInteger index = -1;
  22. [alertView.rac_buttonClickedSignal subscribeNext:^(NSNumber *sentIndex) {
  23. index = sentIndex.integerValue;
  24. }];
  25. [alertView.delegate alertView:alertView clickedButtonAtIndex:2];
  26. expect(@(index)).to(equal(@2));
  27. });
  28. qck_it(@"sends the index of the appropriate button to the willDismissSignal when dismissed programatically", ^{
  29. __block NSInteger index = -1;
  30. [alertView.rac_willDismissSignal subscribeNext:^(NSNumber *sentIndex) {
  31. index = sentIndex.integerValue;
  32. }];
  33. [alertView.delegate alertView:alertView willDismissWithButtonIndex:2];
  34. expect(@(index)).to(equal(@2));
  35. });
  36. });
  37. QuickSpecEnd