Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe(@"UserController", ^{
- __block UserController *subject;
- __block User *user;
- beforeEach(^{
- subject = [[UserController alloc] init];
- user = fake_for([User class]);
- user stub_method(@selector(username)).and_return(@"this-is-my-username");
- user stub_method(@selector(email)).and_return(@"my-special-email@gmail.com");
- [subject setupWithUser:user];
- });
- describe(@"when the view loads", ^{
- context(@"when the user is an admin", ^{
- beforeEach(^{
- user stub_method(@selector(isAdmin)).and_return(YES);
- });
- context(@"when the user is premium ", ^{
- beforeEach(^{
- user stub_method(@selector(isPremium)).and_return(YES);
- [subject loadViewIfNeeded];
- });
- it(@"should set the username label", ^{
- subject.usernameLabel.text should equal(@"this-is-my-username");
- });
- it(@"should set the email label", ^{
- subject.emailLabel.text should equal(@"my-special-email@gmail.com");
- });
- it(@"should show the settings button", ^{
- subject.settingsButton.hidden should be_falsy;
- });
- it(@"should enable the 'See More' button", ^{
- subject.seeMoreButton.enabled should be_truthy;
- });
- });
- context(@"when the user is NOT premium ", ^{
- beforeEach(^{
- user stub_method(@selector(isPremium)).and_return(NO);
- [subject loadViewIfNeeded];
- });
- it(@"should set the username label", ^{
- subject.usernameLabel.text should equal(@"this-is-my-username");
- });
- it(@"should set the email label", ^{
- subject.emailLabel.text should equal(@"my-special-email@gmail.com");
- });
- it(@"should show the settings button", ^{
- subject.settingsButton.hidden should be_falsy;
- });
- it(@"should disable the 'See More' button", ^{
- subject.seeMoreButton.enabled should be_falsy;
- });
- });
- });
- context(@"when the user is NOT an admin", ^{
- beforeEach(^{
- user stub_method(@selector(isAdmin)).and_return(NO);
- });
- context(@"when the user is premium ", ^{
- beforeEach(^{
- user stub_method(@selector(isPremium)).and_return(YES);
- [subject loadViewIfNeeded];
- });
- it(@"should set the username label", ^{
- subject.usernameLabel.text should equal(@"this-is-my-username");
- });
- it(@"should set the email label", ^{
- subject.emailLabel.text should equal(@"my-special-email@gmail.com");
- });
- it(@"should hide the settings button", ^{
- subject.settingsButton.hidden should be_truthy;
- });
- it(@"should enable the 'See More' button", ^{
- subject.seeMoreButton.enabled should be_truthy;
- });
- });
- context(@"when the user is NOT premium ", ^{
- beforeEach(^{
- user stub_method(@selector(isPremium)).and_return(NO);
- [subject loadViewIfNeeded];
- });
- it(@"should set the username label", ^{
- subject.usernameLabel.text should equal(@"this-is-my-username");
- });
- it(@"should set the email label", ^{
- subject.emailLabel.text should equal(@"my-special-email@gmail.com");
- });
- it(@"should hide the settings button", ^{
- subject.settingsButton.hidden should be_truthy;
- });
- it(@"should disable the 'See More' button", ^{
- subject.seeMoreButton.enabled should be_falsy;
- });
- });
- });
- });
- });
Add Comment
Please, Sign In to add comment