A piece of workable ruby code to update jira tickets – with ruby 1.9.3-p448 and jiralicious(0.3.0)

require 'rubygems'
require 'jiralicious'

USERNAME = "***"
PASSWORD = "***"
JIRA_URL = "https://example.com"

Jiralicious.configure do |config|
# Leave out username and password
config.username = USERNAME
config.password = PASSWORD
config.uri = JIRA_URL
config.api_version = "latest"
config.auth_type = :basic
end

r = Jiralicious.search("project = PHX AND issuetype = Bug AND status = Resolved")
r.issues.each do |issue|

#print the key with issue.jira_key
p "+++++++++++++ resolved bug found: #{issue.jira_key} +++++++++++++"

#Trigger a transition on this issue: the id of this transition may different on another project.
Jiralicious::Issue::Transitions.go(issue.jira_key, 351)

#Add a comment on the issue.
Jiralicious::Issue::Comment.add("fix included in build: you build No.", issue.jira_key)
end

What is under Calabash-ios

Assume you already worked with calabash-ios for some time, but now you wonder how calabash do the job and what is underlying the cucumber code?

First layer: UIA functions:
Go to open “calabash-cucumber” gem and you will find this file:  uia.rb,  in this file there are uia_* methods. You can use those methods to simulate touch swipe and keyboard type on connected physical devices.

what are uia_functions?  UIA mean UIAutomation which is a xcode instrument. You can think them as “official api for interacting with IOS”, here is the link, and also another link for more detailed reference.

Lets use this method as the example: uia_tap_mark()

def uia_tap_mark(mark)
  uia_handle_command(:tapMark, mark)
end

Now the question is how calabash-ios send the uia command to ios and run it?

Second layer: uia-scripts
There comes the calabash-script, you can download it from calabash github repo. I am still tying to figure out how calabash-cucumber interact with calabash-script, but before that, we still can take a look at what is inside calabash-script.

The definition for tabMark is as below:

(defn tap-mark
  [mark]
  (tap [:view {:marked mark}]))

Basically, calabash-script translate the calabash uia commands to UI Automation commands. Read this:

CalabashScript is a ClojureScript library for writing automated 
functional tests for native iOS Apps.
CalabashScript provides friendly ClojureScript APIs based on 
the (perhaps not so friendly) UIAutomation APIs.

Third layer:
UI Automation (native ios api)

use ipfw on Mac to simulate slow network traffic (verified on 02/14/2014)

(1) create a pipe which limits the speed to 56kbit/s

  sudo ipfw pipe 1 config bw 56Kbit/s  

(2) add the pipe to ipfw list with simple option:

  sudo ipfw add 1 pipe 1 ip from any to any 

(3) delete the pipe:

 udo ipfw delete 1 

Reference links: (note some of them already been expired, but worth a reading)

http://cs.baylor.edu/~donahoo/tools/dummy/tutorial.htm
http://titaniumninja.com/simulating-slow-network-links-on-os-x/
http://backup.noiseandheat.com/blog/2012/02/throttling-bandwidth-on-os-x/
http://benlakey.com/2012/10/14/throttle-bandwidth-on-mac-os-x/

Caputre an IOS screenshot with UIAtuomation Instruments

This piece of script can do the job (inside UIAutomation Instruments):


var target = UIATarget.localTarget();
target.delay(5)
target.captureScreenWithName("1234.png")
target.delay(2)
target.tap({x:478.00, y:571.00})
target.tap({x:326.00, y:443.00})
target.delay(40)
target.captureScreenWithName("1234.png")
target.delay(2)

On tricky thing to notice is:

 you MUST add target.delay after the screenshot function, 
otherwise the screenshot will be empty. 

Also reference this link: http://www.smallte.ch/blog-read_en_29001.html

Objective-C in one page(continuing update)

Detailed Reference

String, Variable, Array and Dictionary

NSLog(@”hello, I am XY”);
NSString *firstName = @”Yan”;
NSLog(firstName);
NSLog(@”Hello there, %@.”, firstName);
NSLog(@”%@ %@”, firstName, firstName);
NSString *lastName = @”Xia”;
NSLog(@”%@ %@”, firstName, lastName);
NSNumber *age = @100
NSLog(@”%@ %@ is %@ years old”, firstName, lastName, age);
NSArray *apps = @[@”example1″, @”example2″, @”example3″];
NSDictionary *person = @{@”First Name”: @”Eric”};
NSDictionary *appRatings = @{@”AngryFowl”: @3, @”Lettertouch”: @5};
NSLog(@”%@”, appRatings[@”AngryFowl”]);
Continue reading

“Hello IOS World” on real device is not that easy and straightforward, first IOS app on the real device.

Setup the provisioning profile for the app and testing devices:

  1. Purchase the developer account.
  2. Download Xcode(always download or update to the latest Xcode).
  3. Go to Xcode, go to Window->Organizer, get the Organizer window.
  4. In Organizer window, go to Editor-> Refresh From Developer Portal.
  5. Follow the popups to create the provisioning files and register the testing devices.

3 issues/errors that blocked me for more than 10 minutes:

  1. By default, there will be a wild card app id got created, and it will match all single string app names e.g. myhelloworldapp, but it won’t match edu.self.myhelloworldapp. Update the app id in your developer center account settings.
  2. I used to set up the provisioning long time ago and left some trash files, I need to remove all the IOS certificate from keychains, xcode and developer accounts, and re-create all the files again.
  3. the Xcode was a little bit old, and my testing device has the latest IOS, I need to update my Xcode to run the app on my testing device.

Still in Xcode

  1. Create a empty helloworld app, can run it with your device. If get “provisioning matching” issue, go to check the app id.
  2. Should get the empty helloWorld app running in the testing device now.

Simulator:

  1. No need to configure any provisioning file for using simulator, pretty straightforward. Just select the simulator you want to use.
  2. But sometimes you need to configure the “Build Settings” of your app, and change the “IOS development target” to the correct version.