Skip to content

Instantly share code, notes, and snippets.

View ecgreb's full-sized avatar

Chuck Greb ecgreb

View GitHub Profile
@ecgreb
ecgreb / NumberPickerWrapper.java
Created January 2, 2013 21:54
Sample code for back porting Android NumberPicker widget.
public abstract class NumberPickerWrapper {
static public NumberPickerWrapper createHolder(View view) {
NumberPickerWrapper numberPickerWrapper;
numberPickerWrapper = Build.VERSION.SDK_INT > 10 ? new NumberPickerWrapper_Sdk14()
: new NumberPickerWrapper_Sdk10();
numberPickerWrapper.setView(view);
return numberPickerWrapper;
}
@ecgreb
ecgreb / Podfile
Last active December 16, 2015 22:39
Simple Podfile
platform :ios
# Add logging framework to all targets.
pod 'CocoaLumberjack'
# Add Kiwi to unit test target only.
target :UnitTests, :exclusive => true do
pod 'Kiwi'
end
@interface HelloTDDViewController : UIViewController
@property(strong, nonatomic) id<HelloTDDViewControllerDelegate> delegate;
@property(weak, nonatomic) IBOutlet UITextField *nameField;
@property(weak, nonatomic) IBOutlet UILabel *helloLabel;
- (IBAction)onButtonClick:(id)sender;
- (void)showGreeting:(NSString *)message;
@end
@implementation HelloTDDViewController
- (void)viewDidLoad {
[super viewDidLoad];
GreetingFactory *greetingFactory = [[GreetingFactory alloc] init];
_delegate = greetingFactory;
}
//...
@implementation HelloTDDViewControllerTests {
HelloTDDViewController *viewController;
}
- (void)setUp {
viewController = [[HelloTDDViewController alloc] init];
}
//...
SPEC_BEGIN(HelloTDDViewControllerSpec)
describe(@"HelloTDDViewController", ^{
HelloTDDViewController *viewController =
[[HelloTDDViewController alloc] init];
MockHelloTDDViewControllerDelegate *delegate =
[[MockHelloTDDViewControllerDelegate alloc] init];
//...
@implementation HelloTDDTestController
- (void)initializeScenarios {
[self addScenario:[KIFTestScenario scenarioToDisplayGreeting]];
}
@end
@implementation KIFTestScenario (HelloTDDAdditions)
+ (id)scenarioToDisplayGreeting {
KIFTestScenario *scenario =
[KIFTestScenario scenarioWithDescription:
@"Test greeting with name."];
[scenario addStep:
[KIFTestStep stepToEnterText:
@"Chuck Norris"intoViewWithAccessibilityLabel:@"Name"]];
@implementation KIFTestStep (HelloTDDAdditions)
+ (id)stepToVerifyGreeting:(NSString *)expectedLabel {
NSString *description =
[NSString stringWithFormat:@"Verify output is '%@'",
expectedLabel];
return [self stepWithDescription:description
executionBlock:^(KIFTestStep *step, NSError **error) {
@implementation HelloTDDViewController
- (void)viewDidLoad {
[super viewDidLoad];
_nameField.accessibilityLabel = @"Name";
_helloLabel.accessibilityLabel = @"Greeting";
GreetingFactory *greetingFactory = [[GreetingFactory alloc] init];
_delegate = greetingFactory;
}