Guest User

Untitled

a guest
May 21st, 2018
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. describe(@"UserController", ^{
  2. __block UserController *subject;
  3. __block User *user;
  4.  
  5.  
  6. beforeEach(^{
  7. subject = [[UserController alloc] init];
  8.  
  9. user = fake_for([User class]);
  10. user stub_method(@selector(username)).and_return(@"this-is-my-username");
  11. user stub_method(@selector(email)).and_return(@"my-special-email@gmail.com");
  12.  
  13. [subject setupWithUser:user];
  14. });
  15.  
  16. describe(@"when the view loads", ^{
  17. context(@"when the user is an admin", ^{
  18. beforeEach(^{
  19. user stub_method(@selector(isAdmin)).and_return(YES);
  20. });
  21.  
  22. context(@"when the user is premium ", ^{
  23. beforeEach(^{
  24. user stub_method(@selector(isPremium)).and_return(YES);
  25.  
  26. [subject loadViewIfNeeded];
  27. });
  28.  
  29. it(@"should set the username label", ^{
  30. subject.usernameLabel.text should equal(@"this-is-my-username");
  31. });
  32.  
  33. it(@"should set the email label", ^{
  34. subject.emailLabel.text should equal(@"my-special-email@gmail.com");
  35. });
  36.  
  37. it(@"should show the settings button", ^{
  38. subject.settingsButton.hidden should be_falsy;
  39. });
  40.  
  41. it(@"should enable the 'See More' button", ^{
  42. subject.seeMoreButton.enabled should be_truthy;
  43. });
  44. });
  45.  
  46. context(@"when the user is NOT premium ", ^{
  47. beforeEach(^{
  48. user stub_method(@selector(isPremium)).and_return(NO);
  49.  
  50. [subject loadViewIfNeeded];
  51. });
  52.  
  53. it(@"should set the username label", ^{
  54. subject.usernameLabel.text should equal(@"this-is-my-username");
  55. });
  56.  
  57. it(@"should set the email label", ^{
  58. subject.emailLabel.text should equal(@"my-special-email@gmail.com");
  59. });
  60.  
  61. it(@"should show the settings button", ^{
  62. subject.settingsButton.hidden should be_falsy;
  63. });
  64.  
  65. it(@"should disable the 'See More' button", ^{
  66. subject.seeMoreButton.enabled should be_falsy;
  67. });
  68. });
  69. });
  70.  
  71. context(@"when the user is NOT an admin", ^{
  72. beforeEach(^{
  73. user stub_method(@selector(isAdmin)).and_return(NO);
  74. });
  75.  
  76. context(@"when the user is premium ", ^{
  77. beforeEach(^{
  78. user stub_method(@selector(isPremium)).and_return(YES);
  79.  
  80. [subject loadViewIfNeeded];
  81. });
  82.  
  83. it(@"should set the username label", ^{
  84. subject.usernameLabel.text should equal(@"this-is-my-username");
  85. });
  86.  
  87. it(@"should set the email label", ^{
  88. subject.emailLabel.text should equal(@"my-special-email@gmail.com");
  89. });
  90.  
  91. it(@"should hide the settings button", ^{
  92. subject.settingsButton.hidden should be_truthy;
  93. });
  94.  
  95. it(@"should enable the 'See More' button", ^{
  96. subject.seeMoreButton.enabled should be_truthy;
  97. });
  98. });
  99.  
  100. context(@"when the user is NOT premium ", ^{
  101. beforeEach(^{
  102. user stub_method(@selector(isPremium)).and_return(NO);
  103.  
  104. [subject loadViewIfNeeded];
  105. });
  106.  
  107. it(@"should set the username label", ^{
  108. subject.usernameLabel.text should equal(@"this-is-my-username");
  109. });
  110.  
  111. it(@"should set the email label", ^{
  112. subject.emailLabel.text should equal(@"my-special-email@gmail.com");
  113. });
  114.  
  115. it(@"should hide the settings button", ^{
  116. subject.settingsButton.hidden should be_truthy;
  117. });
  118.  
  119. it(@"should disable the 'See More' button", ^{
  120. subject.seeMoreButton.enabled should be_falsy;
  121. });
  122. });
  123. });
  124. });
  125. });
Add Comment
Please, Sign In to add comment