calabash-cucumber 0.9.163.pre1 → 0.9.163.pre2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb9435164c3c6e1fbb27d115c6ff95695103d92e
4
- data.tar.gz: 6d2ee3912d659216fd6196d8746c5bf35d00aa1c
3
+ metadata.gz: d74a738566ae6afbbef306f650121183621ada97
4
+ data.tar.gz: 63ba438671209a80a5af7b1421ebe4026f9ed534
5
5
  SHA512:
6
- metadata.gz: 14e98c7878f6cc256c2931e55f5bc19d58b91c33433a0aeb23771de5e59c28e0ec153b923dbeccd5560207bdd09c69271c422071afddcc9b78267c8c83e6ad8c
7
- data.tar.gz: 9d271ee5d68b714bb05629b3b9a394c4df5d7b0869458f624d987212e03c8495a2a2cc9fcb8524bf029effbac942239efe93c62da5cf5e4f46dcc43bc45acd63
6
+ metadata.gz: f9035529252d31c95347db61c5f43476a58cd781c745f62190510392d083bfc01f201692455f724e91c4c0fe24776f9acf13879ab941a29e81bd10c17d914af2
7
+ data.tar.gz: 5d3360cee7f483c4a3bb8964c92f386faa9b20aa169ef894fc334a746015fc5b475c47c08e8a8e7ecfb4d13980a0c4e82ca516b5dcfaea56685c5572dfb9bfd5
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency( "CFPropertyList" )
24
24
  s.add_dependency( "sim_launcher", "0.4.6")
25
25
  s.add_dependency( "slowhandcuke" )
26
- s.add_dependency( "location-one", "~>0.0.10")
26
+ s.add_dependency( "geocoder", "~>1.1.8")
27
27
  s.add_dependency( "httpclient","~> 2.3.3")
28
28
  s.add_dependency( "bundler", "~> 1.1")
29
29
  s.add_dependency( "run_loop", "~> 0.1.0.pre1" )
@@ -4,5 +4,5 @@ require 'calabash-cucumber/keyboard_helpers'
4
4
  require 'calabash-cucumber/wait_helpers'
5
5
  require 'calabash-cucumber/operations'
6
6
  require 'calabash-cucumber/version'
7
- require 'calabash-cucumber/location'
7
+ require 'calabash-cucumber/uia'
8
8
  require 'calabash-cucumber/date_picker.rb'
@@ -1,4 +1,5 @@
1
1
  require 'httpclient'
2
+ require 'geocoder'
2
3
  require 'calabash-cucumber/launch/simulator_helper'
3
4
  require 'calabash-cucumber/uia'
4
5
  require 'calabash-cucumber/ios7_operations'
@@ -378,6 +379,47 @@ module Calabash
378
379
  uia_send_app_to_background(secs)
379
380
  end
380
381
 
382
+ def console_attach
383
+ Calabash::Cucumber::Launcher.attach
384
+ end
385
+
386
+ def set_location(options)
387
+ if Calabash::Cucumber::Launcher.instruments?
388
+ uia_set_location(options)
389
+ else
390
+ if options[:place]
391
+ res = location_for_place(options[:place])
392
+ lat = res.latitude
393
+ lon = res.longitude
394
+ else
395
+ lat = options[:latitude]
396
+ lon = options[:longitude]
397
+ end
398
+ body_data = {:action => :change_location,
399
+ :latitude => lat,
400
+ :longitude => lon}
401
+
402
+ body = http({:method => :post, :path => 'location'}, body_data)
403
+
404
+ res = JSON.parse(res)
405
+ if res['outcome'] != 'SUCCESS'
406
+ screenshot_and_raise "Set location change failed, for #{lat}, #{lon} (#{body})."
407
+ end
408
+ res['results']
409
+
410
+ end
411
+ end
412
+
413
+ def location_for_place(place)
414
+ search_results = locations_for_place(place)
415
+ raise "Got no results for #{place}" if search_results.empty?
416
+ search_results.first
417
+ end
418
+
419
+ def locations_for_place(place)
420
+ Geocoder.search(place)
421
+ end
422
+
381
423
  def move_wheel(opts={})
382
424
  q = opts[:query] || "pickerView"
383
425
  wheel = opts[:wheel] || 0
@@ -388,6 +430,8 @@ module Calabash
388
430
 
389
431
  if ENV['OS'] == "ios4"
390
432
  playback "wheel_#{dir}", :query => "#{q} pickerTable index:#{wheel}"
433
+ elsif ios7?
434
+ raise NotImplementedError
391
435
  else
392
436
  playback "wheel_#{dir}", :query => "#{q} pickerTableView index:#{wheel}"
393
437
  end
@@ -27,8 +27,34 @@ class Calabash::Cucumber::Launcher
27
27
  class CalabashLauncherTimeoutErr < Timeout::Error
28
28
  end
29
29
 
30
+ def self.attach
31
+ l = launcher
32
+ return l if l && l.active?
33
+ l.attach
34
+
35
+ end
36
+
37
+ def attach
38
+ pids_str = `ps x -o pid,command | grep -v grep | grep "instruments" | awk '{printf "%s,", $1}'`
39
+ pids = pids_str.split(',').map { |pid| pid.to_i }
40
+ pid = pids.first
41
+ rl = {}
42
+ rl[:pid] = pid if pid
43
+
44
+ self.run_loop= rl
45
+ ensure_connectivity
46
+
47
+ self
48
+ end
49
+
50
+ def self.instruments?
51
+ l = launcher_if_used
52
+ return false unless l
53
+ l.active?
54
+ end
55
+
30
56
  def self.launcher
31
- @@launcher ||= Launcher.new
57
+ @@launcher ||= Calabash::Cucumber::Launcher.new
32
58
  end
33
59
 
34
60
  def self.launcher_if_used
@@ -357,7 +383,7 @@ class Calabash::Cucumber::Launcher
357
383
  end
358
384
 
359
385
  def run_with_instruments?(args)
360
- args[:launch_method] == :instruments
386
+ args && args[:launch_method] == :instruments
361
387
  end
362
388
 
363
389
  def active?
@@ -365,7 +391,7 @@ class Calabash::Cucumber::Launcher
365
391
  end
366
392
 
367
393
  def inspect
368
- msg = ["#{self.class}: Launch Method #{launch_args[:launch_method]}"]
394
+ msg = ["#{self.class}: Launch Method #{launch_args && launch_args[:launch_method]}"]
369
395
  if run_with_instruments?(self.launch_args) && self.run_loop
370
396
  msg << "Log file: #{self.run_loop[:log_file]}"
371
397
  end
@@ -2,7 +2,6 @@ require 'calabash-cucumber/core'
2
2
  require 'calabash-cucumber/tests_helpers'
3
3
  require 'calabash-cucumber/keyboard_helpers'
4
4
  require 'calabash-cucumber/wait_helpers'
5
- require 'calabash-cucumber/location'
6
5
  require 'calabash-cucumber/launcher'
7
6
  require 'net/http'
8
7
  require 'test/unit/assertions'
@@ -26,7 +25,6 @@ module Calabash
26
25
  include Calabash::Cucumber::TestsHelpers
27
26
  include Calabash::Cucumber::WaitHelpers
28
27
  include Calabash::Cucumber::KeyboardHelpers
29
- include Calabash::Cucumber::Location
30
28
  include Calabash::Cucumber::DatePicker
31
29
 
32
30
  def page(clz,*args)
@@ -1,24 +1,22 @@
1
1
  require 'edn'
2
- require 'location-one'
3
2
 
4
3
  module Calabash
5
4
  module Cucumber
6
5
  module UIA
7
6
 
8
- def send_uia_command(opts ={})
9
- #launcher = @calabash_launcher || Calabash::Cucumber::Launcher.launcher_if_used
10
- #run_loop = opts[:run_loop] || (launcher && launcher.active? && launcher.run_loop)
11
- command = opts[:command]
12
- #raise ArgumentError, 'please supply :run_loop or instance var @calabash_launcher' unless run_loop
13
- #raise ArgumentError, 'please supply :command' unless command
14
- #RunLoop.send_command(run_loop, opts[:command])
15
- res = http({:method => :post, :path => 'uia'}, {command:command})
7
+ def uia(command,options={})
8
+ res = http({:method => :post, :path => 'uia'}, {command:command}.merge(options))
16
9
  res = JSON.parse(res)
17
10
  if res['outcome'] != 'SUCCESS'
18
11
  screenshot_and_raise "uia send failed because: #{res['reason']}\n#{res['details']}"
19
12
  end
20
13
  res['results'].first
14
+ end
21
15
 
16
+ def send_uia_command(opts ={})
17
+ #deprecated, poor method signature
18
+ #use uia("uia-js...",options)
19
+ uia(opts[:command], opts)
22
20
  end
23
21
 
24
22
  def uia_query(*queryparts)
@@ -87,16 +85,20 @@ module Calabash
87
85
  uia_handle_command(:typeString, string)
88
86
  end
89
87
 
90
- def uia_enter()
88
+ def uia_enter
91
89
  uia_handle_command(:enter)
92
90
  end
93
91
 
94
- def uia_set_location(place)
95
- if place.is_a?(String)
96
- loc = LocationOne::Client.location_by_place(place)
97
- loc_data = {"latitude"=>loc.latitude, "longitude"=>loc.longitude}
98
- else
99
- loc_data = place
92
+ def uia_set_location(options)
93
+ validate_hash_is_location!(options)
94
+ if options[:place]
95
+ place = options[:place]
96
+ search_results = Geocoder.search(place)
97
+ raise "Got no results for #{place}" if search_results.empty?
98
+ loc = search_results.first
99
+ loc_data = {'latitude'=>loc.latitude, 'longitude'=>loc.longitude}
100
+ elsif options.is_a?(Hash)
101
+ loc_data = options
100
102
  end
101
103
  uia_handle_command(:setLocation, loc_data)
102
104
  end
@@ -118,7 +120,7 @@ module Calabash
118
120
  puts "Sending UIA command"
119
121
  puts command
120
122
  end
121
- s=send_uia_command :command => command
123
+ s = uia(command)
122
124
  if ENV['DEBUG'] == '1'
123
125
  puts "Result"
124
126
  p s
@@ -135,6 +137,18 @@ module Calabash
135
137
  escape_quotes string
136
138
  end
137
139
 
140
+ private
141
+ def validate_hash_is_location!(options)
142
+ return if options[:latitude] and options[:longitude]
143
+ if (options[:latitude] and not options[:longitude]) ||
144
+ (options[:longitude] and not options[:latitude])
145
+ raise 'Both latitude and longitude must be specified if either is.'
146
+ elsif not options[:place]
147
+ raise 'Either :place or :latitude and :longitude must be specified.'
148
+ end
149
+ end
150
+
151
+
138
152
  end
139
153
  end
140
154
  end
@@ -1,6 +1,6 @@
1
1
  module Calabash
2
2
  module Cucumber
3
- VERSION = '0.9.163.pre1'
4
- FRAMEWORK_VERSION = '0.9.163.pre1'
3
+ VERSION = '0.9.163.pre2'
4
+ FRAMEWORK_VERSION = '0.9.163.pre2'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.163.pre1
4
+ version: 0.9.163.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-20 00:00:00.000000000 Z
11
+ date: 2013-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -109,19 +109,19 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: location-one
112
+ name: geocoder
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 0.0.10
117
+ version: 1.1.8
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ~>
123
123
  - !ruby/object:Gem::Version
124
- version: 0.0.10
124
+ version: 1.1.8
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: httpclient
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -236,7 +236,6 @@ files:
236
236
  - lib/calabash-cucumber/keyboard_helpers.rb
237
237
  - lib/calabash-cucumber/launch/simulator_helper.rb
238
238
  - lib/calabash-cucumber/launcher.rb
239
- - lib/calabash-cucumber/location.rb
240
239
  - lib/calabash-cucumber/operations.rb
241
240
  - lib/calabash-cucumber/resources/cell_swipe_ios4_ipad.base64
242
241
  - lib/calabash-cucumber/resources/cell_swipe_ios4_iphone.base64
@@ -1,26 +0,0 @@
1
- require 'location-one'
2
- require 'geocoder'
3
-
4
- module Calabash
5
- module Cucumber
6
- module Location
7
- include Calabash::Cucumber::Core
8
-
9
- def set_location(options)
10
- uri = url_for('uia')
11
- client = LocationOne::Client.new({:host => uri.host, :port => uri.port, :path => '/uia'}, @http)
12
- res = client.change_location(options)
13
- res = JSON.parse(res)
14
- if res['outcome'] != 'SUCCESS'
15
- screenshot_and_raise "set_location #{options}, failed because: #{res['reason']}\n#{res['details']}"
16
- end
17
- res['results']
18
- end
19
-
20
- def location_for_place(place)
21
- LocationOne::Client.location_by_place place
22
- end
23
-
24
- end
25
- end
26
- end