Skip to content

Instantly share code, notes, and snippets.

View jmoody's full-sized avatar

Joshua Moody jmoody

  • Germany
View GitHub Profile
def non_location_items
all_items = query("view:'MKAnnotationView'")
location_items = query("view:'MKModernUserLocationView'")
all_items.delete_if { |item| location_items.include?(item) }
end
def touch_first_non_location
desc = non_location_items.first['description'].split(';').first
touch("view:'MKAnnotationView' {description BEGINSWITH '#{desc}'}")
sleep(0.4)
$ gem dependency mime-types
Gem mime-types-2.0
hoe (~> 3.7, development)
hoe-bundler (~> 1.2, development)
hoe-doofus (~> 1.0, development)
hoe-gemspec2 (~> 1.1, development)
hoe-git (~> 1.5, development)
hoe-rubygems (~> 1.0, development)
hoe-travis (~> 1.2, development)
minitest (~> 5.0, development)
@jmoody
jmoody / dotirbrc.rb
Last active December 31, 2015 19:09
pretty print view marks in calabash iOS
see https://github.com/jmoody/briar/blob/master/lib/briar/irbrc.rb
@jmoody
jmoody / wait_for_view_at_point
Created December 18, 2013 23:48
calabash wait for view with point to disappear
def view_at_point?(point, view_class='view')
res = query(view_class)
res.each { |view_hash|
center = {:x => view_hash['rect']['center_x'], :y => view_hash['rect']['center_y']}
return true if center == point
}
false
end
def wait_for_view_at_point_to_disappear(point, opts={})
@jmoody
jmoody / example.rb
Last active December 30, 2015 20:29
calabash-ios uia_pan_offset example
def move_appointment(appointment_mark, weekday, dir, hours, opts)
# asserts that the SelectCell has been touched
touch_and_hold_appointment(appointment_mark, weekday)
cell_view = custom_view_class('SelectCell', :mi)
res = query(cell_view).first
# no error checking!
normalize_rect_for_orientation!(res['rect'])
y_offset = hours * (res['frame']['height'] + 10)
@jmoody
jmoody / cucumber.yml
Last active December 15, 2015 22:09
read a file from cucumber.yml
common: SCREENSHOT_PATH=./cucumber-screenshots/ -f 'Slowhandcuke::Formatter' OS=ios5
rerun_out: -f rerun -o rerun.txt
no_launch: EMBED=1 NO_LAUNCH=1
ipad: DEVICE=ipad -p common -p no_launch
iphone: DEVICE=iphone -p common -p no_launch
<%
pluto_ip = IO.read("#{ENV['HOME']}/.lesspainful/devices/pluto")
neptune_ip = IO.read("#{ENV['HOME']}/.lesspainful/devices/neptune")
%>
@jmoody
jmoody / main.m
Created January 30, 2013 09:44
a main.m file for GHUnit that fixes problems described in gh-unit issue 96 - command line tests failing for Xcode 4.5 (and 4.6) for iOS 6
#import <objc/runtime.h>
#import <objc/message.h>
@interface UIWindow (Private)
- (void) swizzled_createContext;
@end
@implementation UIWindow (Private)
- (void) swizzled_createContext {
// nop
@jmoody
jmoody / some_table_steps.rb
Created November 16, 2012 10:06
cucumber steps for testing rows in table view
# examples of usage
# Scenario: the activities home view should have the right stuff on it
# Then I should see navbar with title "Coping Skills"
# Then I scroll down until I see the "recommendation" row limit 1
# Then I should see that the "recommendation" row has text "Recommendation" in the "title" label
# Then I should see that the "recommendation" row has text "custom selection based on your current needs" in the "details" label
#
# Then I scroll down until I see the "random" row limit 1
# Then I should see that the "random" row has text "Random" in the "title" label
# Then I should see that the "random" row has text "random selection from all the skills" in the "details" label
@jmoody
jmoody / LPWebQuery_arc_patch
Created June 28, 2012 13:40
git patch file for ARC calabash-js
diff --git CalabashJS/CalabashJSLib/LPWebQuery.m CalabashJS/CalabashJSLib/LPWebQuery.m
index a9593c1..a7e49d7 100644
--- CalabashJS/CalabashJSLib/LPWebQuery.m
+++ CalabashJS/CalabashJSLib/LPWebQuery.m
@@ -6,6 +6,10 @@
// Copyright (c) 2012 Trifork. All rights reserved.
//
+#ifndef DEBUG
+#define DEBUG 0
@jmoody
jmoody / keyboard_steps.rb
Created June 23, 2012 11:54
cucumber steps for interacting with native keyboard using calabash-cucumber
def should_see_keyboard
res = element_exists("keyboardAutomatic")
unless res
screenshot_and_raise "Expected keyboard to be visible."
end
end
def should_not_see_keyboard
res = element_exists("keyboardAutomatic")
if res