Skip to content

Instantly share code, notes, and snippets.

View bleonard's full-sized avatar

Brian Leonard bleonard

View GitHub Profile
begin
require 'offshore/tasks' if defined?(Offshore)
rescue
end
group :test do
gem 'offshore'
end
describe "Integration Test", type: :request do
it "should work as expected" do
Offshore.test.start(example)
user = users(:billy)
worker = users(:robby)
task = FactoryOffshore.create(:task_posted, :user_id => user.id)
offer = FactoryOffshore.create(:offer, :worker_id => worker.id)
// MyAuthController.m
-(void) didSubmitLogin {
[CurrentUser loginWithEmail:self.emailField.text password:self.passwordField.text success:^{
[self closeAuthentication:YES];
} failure:^(NSError *error) {
[self showError:error];
}];
}
-(void) didTapCancelButton {
[self closeAuthentication:NO];
// MyAppDelegate.m
- (void) authenticateWithSuccess:(MyVoidBlock)success {
if ([CurrentUser isLoggedIn]) {
// return immediately if the user is already logged in
success();
}
else {
// otherwise, launch view that allows login or signup, passing block along
MyAuthController * auth = [[MyAuthController alloc] initWithSuccess:success];
auth.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
// MyAppDelegate.h
- (void) authenticateWithSuccess:(MyVoidBlockWithUser)success;
// MyIdeaViewController.m
-(void) favoriteButtonPressed: {
MyAppDelegate * delegate = (MyAppDelegate*) [[UIApplication sharedApplication] delegate];
[delegate authenticateWithSuccess:^{
[[CurrentUser shared] setIdeaAsFavorite: self.idea];
}];
}
// MyAppDelegate.h
#import <UIKit/UIKit.h>
@interface MyAppDelegate : UIResponder <UIApplicationDelegate>
- (void) authenticateWithSuccess:(MyVoidBlock)success;
@end
typedef void (^MyVoidBlock)();
typedef void (^MyVoidBlockWithBool)(BOOL);
typedef void (^MyVoidBlockWithString)(NSString *);
typedef void (^MyVoidBlockWithDictionary)(NSDictionary *);
typedef BOOL (^MyBoolBlockWithString)(NSString *);
NSComparator finderSortBlock = ^(id string1, id string2) {
NSRange string1Range = NSMakeRange(0, [string1 length]);
return [string1 compare:string2 options:comparisonOptions range:string1Range locale:currentLocale];
};
NSArray *finderSortArray = [stringsArray sortedArrayUsingComparator:finderSortBlock];