UIActionSheetRACSupportSpec.m 951 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // UIActionSheetRACSupportSpec.m
  3. // ReactiveCocoa
  4. //
  5. // Created by Dave Lee on 2013-06-22.
  6. // Copyright (c) 2013 GitHub, Inc. All rights reserved.
  7. //
  8. #import <Quick/Quick.h>
  9. #import <Nimble/Nimble.h>
  10. #import "RACSignal.h"
  11. #import "RACSignal+Operations.h"
  12. #import "UIActionSheet+RACSignalSupport.h"
  13. QuickSpecBegin(UIActionSheetRACSupportSpec)
  14. qck_describe(@"-rac_buttonClickedSignal", ^{
  15. __block UIActionSheet *actionSheet;
  16. qck_beforeEach(^{
  17. actionSheet = [[UIActionSheet alloc] init];
  18. [actionSheet addButtonWithTitle:@"Button 0"];
  19. [actionSheet addButtonWithTitle:@"Button 1"];
  20. expect(actionSheet).notTo(beNil());
  21. });
  22. qck_it(@"should send the index of the clicked button", ^{
  23. __block NSNumber *index = nil;
  24. [actionSheet.rac_buttonClickedSignal subscribeNext:^(NSNumber *i) {
  25. index = i;
  26. }];
  27. [actionSheet.delegate actionSheet:actionSheet clickedButtonAtIndex:1];
  28. expect(index).to(equal(@1));
  29. });
  30. });
  31. QuickSpecEnd