calabash-extras 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +4 -0
- data/Gemfile.lock +99 -0
- data/README.md +23 -0
- data/Rakefile +1 -0
- data/calabash-extras.gemspec +19 -0
- data/lib/android_runner.rb +95 -0
- data/lib/application_handler.rb +41 -0
- data/lib/ios_runner.rb +35 -0
- data/lib/page_object_comparator.rb +25 -0
- data/lib/test_case.rb +28 -0
- data/lib/walker.rb +95 -0
- data/test/page_object_comparator_test.rb +33 -0
- data/test/walker_test.rb +144 -0
- metadata +141 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
calabash-extras (0.0.1)
|
5
|
+
PriorityQueue
|
6
|
+
calabash-android
|
7
|
+
calabash-cucumber
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
CFPropertyList (2.2.7)
|
13
|
+
PriorityQueue (0.1.2)
|
14
|
+
awesome_print (1.1.0)
|
15
|
+
blankslate (2.1.2.4)
|
16
|
+
builder (3.0.4)
|
17
|
+
calabash-android (0.4.19.pre1)
|
18
|
+
awesome_print
|
19
|
+
cucumber
|
20
|
+
escape (~> 0.0.4)
|
21
|
+
httpclient (~> 2.3.2)
|
22
|
+
json
|
23
|
+
retriable (~> 1.3.3.1)
|
24
|
+
rubyzip (~> 0.9.9)
|
25
|
+
slowhandcuke
|
26
|
+
xamarin-test-cloud (>= 0.9.23)
|
27
|
+
calabash-common (0.0.1)
|
28
|
+
cucumber (~> 1.3.0)
|
29
|
+
calabash-cucumber (0.9.167)
|
30
|
+
CFPropertyList
|
31
|
+
awesome_print
|
32
|
+
bundler (~> 1.1)
|
33
|
+
calabash-common (~> 0.0.1)
|
34
|
+
cucumber (~> 1.3.0)
|
35
|
+
edn
|
36
|
+
geocoder (~> 1.1.8)
|
37
|
+
httpclient (~> 2.3.3)
|
38
|
+
json
|
39
|
+
run_loop (~> 0.1.4)
|
40
|
+
sim_launcher (= 0.4.6)
|
41
|
+
slowhandcuke
|
42
|
+
xamarin-test-cloud (~> 0.9.27)
|
43
|
+
cucumber (1.3.10)
|
44
|
+
builder (>= 2.1.2)
|
45
|
+
diff-lcs (>= 1.1.3)
|
46
|
+
gherkin (~> 2.12)
|
47
|
+
multi_json (>= 1.7.5, < 2.0)
|
48
|
+
multi_test (>= 0.0.2)
|
49
|
+
diff-lcs (1.2.4)
|
50
|
+
edn (1.0.2)
|
51
|
+
parslet (~> 1.4.0)
|
52
|
+
escape (0.0.4)
|
53
|
+
geocoder (1.1.9)
|
54
|
+
gherkin (2.12.1)
|
55
|
+
multi_json (~> 1.3)
|
56
|
+
httpclient (2.3.4.1)
|
57
|
+
json (1.8.0)
|
58
|
+
mime-types (1.24)
|
59
|
+
multi_json (1.7.9)
|
60
|
+
multi_test (0.0.2)
|
61
|
+
parslet (1.4.0)
|
62
|
+
blankslate (~> 2.0)
|
63
|
+
rack (1.5.2)
|
64
|
+
rack-protection (1.5.2)
|
65
|
+
rack
|
66
|
+
rake (10.1.0)
|
67
|
+
rest-client (1.6.7)
|
68
|
+
mime-types (>= 1.16)
|
69
|
+
retriable (1.3.3.1)
|
70
|
+
rubyzip (0.9.9)
|
71
|
+
run_loop (0.1.4)
|
72
|
+
json
|
73
|
+
thor
|
74
|
+
sim_launcher (0.4.6)
|
75
|
+
sinatra
|
76
|
+
sinatra (1.4.4)
|
77
|
+
rack (~> 1.4)
|
78
|
+
rack-protection (~> 1.4)
|
79
|
+
tilt (~> 1.3, >= 1.3.4)
|
80
|
+
slowhandcuke (0.0.3)
|
81
|
+
cucumber
|
82
|
+
thor (0.18.1)
|
83
|
+
tilt (1.4.1)
|
84
|
+
xamarin-test-cloud (0.9.29)
|
85
|
+
bundler (>= 1.3.0, < 2.0)
|
86
|
+
json
|
87
|
+
mime-types (< 2.0)
|
88
|
+
rest-client (~> 1.6.7)
|
89
|
+
retriable (~> 1.3.3.1)
|
90
|
+
rubyzip (~> 0.9.9)
|
91
|
+
thor (>= 0.18.1)
|
92
|
+
|
93
|
+
PLATFORMS
|
94
|
+
ruby
|
95
|
+
|
96
|
+
DEPENDENCIES
|
97
|
+
bundler (~> 1.3)
|
98
|
+
calabash-extras!
|
99
|
+
rake
|
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Calabash::Extras
|
2
|
+
|
3
|
+
Utils for using Calabash and page object pattern with minitest framework
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'calabash-extras'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install calabash-extras
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
1. Extend your testcases from Calabash::Extras::TestCase
|
22
|
+
2. Add Calabash::Extras::PageObjectComparator page objects for Android and Ios (read more on https://github.com/calabash/x-platform-example)
|
23
|
+
3. Link pages of mobile application and use Calabash::Extras::Walker to navigate
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = 'calabash-extras'
|
3
|
+
spec.version = '0.0.1'
|
4
|
+
spec.authors = ['Sergey Galkin']
|
5
|
+
spec.email = ['sergey@galkin.me']
|
6
|
+
spec.description = %q{TestCase and page traversal tool for writing xunit tests for Android and Ios apps}
|
7
|
+
spec.summary = %q{Utils for writing xunit tests with calabash and page objects}
|
8
|
+
|
9
|
+
spec.files = `git ls-files`.split($/)
|
10
|
+
spec.test_files = spec.files.grep(%r{^(test)/})
|
11
|
+
spec.require_paths = ['lib']
|
12
|
+
|
13
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
14
|
+
spec.add_development_dependency 'rake'
|
15
|
+
|
16
|
+
spec.add_dependency 'calabash-android'
|
17
|
+
spec.add_dependency 'calabash-cucumber'
|
18
|
+
spec.add_dependency 'PriorityQueue'
|
19
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'net/telnet'
|
3
|
+
require 'calabash-android/operations'
|
4
|
+
require 'calabash-android/abase'
|
5
|
+
|
6
|
+
module Calabash
|
7
|
+
module Extras
|
8
|
+
class AndroidRunner
|
9
|
+
|
10
|
+
include Calabash::Android::Operations
|
11
|
+
|
12
|
+
attr_reader :default_device
|
13
|
+
|
14
|
+
def initialize(config)
|
15
|
+
@config = config
|
16
|
+
end
|
17
|
+
|
18
|
+
def start
|
19
|
+
load Gem.bin_path('calabash-android', 'calabash-android')
|
20
|
+
|
21
|
+
path = File.expand_path(@config['apk_path'])
|
22
|
+
|
23
|
+
Emulator.launch(@config['emulator']) if @config['start_emulator']
|
24
|
+
|
25
|
+
build_test_server_if_needed(path)
|
26
|
+
set_default_device(Device.new(self, @config['name'], nil, path, test_server_path(path)))
|
27
|
+
end
|
28
|
+
|
29
|
+
def reinstall_app
|
30
|
+
reinstall_apps
|
31
|
+
sleep 1
|
32
|
+
start_test_server_in_background
|
33
|
+
reinstall_hook if defined? self.reinstall_hook
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def test_server_path(apk_file_path)
|
39
|
+
@config['test_server_dir'] + "test_servers/#{checksum(apk_file_path)}_#{Calabash::Android::VERSION}.apk"
|
40
|
+
end
|
41
|
+
|
42
|
+
class Emulator
|
43
|
+
def self.launch(config)
|
44
|
+
inst = self.new(config)
|
45
|
+
inst.kill_old
|
46
|
+
inst.run
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize(config)
|
50
|
+
@cfg = config
|
51
|
+
end
|
52
|
+
|
53
|
+
def run
|
54
|
+
@pid = fork { exec(@cfg['run']) }
|
55
|
+
sleep(@cfg['wait_for_emulator'])
|
56
|
+
unlock
|
57
|
+
sleep(@cfg['sleep_after_launch'])
|
58
|
+
end
|
59
|
+
|
60
|
+
def is_running?
|
61
|
+
defined? @pid && !@pid.nil? && @pid > 0
|
62
|
+
end
|
63
|
+
|
64
|
+
def unlock
|
65
|
+
emulator_cli = Net::Telnet::new('Host' => @cfg['host'], 'Port' => @cfg['port'])
|
66
|
+
emulator_cli.puts('event send EV_KEY:KEY_MENU:1 EV_KEY:KEY_MENU:0')
|
67
|
+
emulator_cli.close
|
68
|
+
end
|
69
|
+
|
70
|
+
def kill
|
71
|
+
Process.kill('QUIT', @pid) if is_running?
|
72
|
+
end
|
73
|
+
|
74
|
+
def kill_old
|
75
|
+
find_pids.each { |pid| Process.kill('QUIT', pid) }
|
76
|
+
end
|
77
|
+
|
78
|
+
protected
|
79
|
+
|
80
|
+
def find_pids
|
81
|
+
#TODO find all pids, not just one
|
82
|
+
command = 'ps ax | grep "/opt/android_sdk/tools/emulator64-x86" | grep -v grep |awk \'{print $1}\''
|
83
|
+
pid = %x(#{command})
|
84
|
+
if pid != '' && pid.to_i > 0
|
85
|
+
[pid.to_i]
|
86
|
+
else
|
87
|
+
[]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Calabash
|
2
|
+
module Extras
|
3
|
+
class ApplicationHandler
|
4
|
+
|
5
|
+
def initialize(config)
|
6
|
+
@conf = config
|
7
|
+
ENV['SCREENSHOT_PATH'] = @conf['screen_shot_dir']
|
8
|
+
start_device unless defined? @@device
|
9
|
+
end
|
10
|
+
|
11
|
+
def page (clz, *args)
|
12
|
+
@@device.page(clz, *args)
|
13
|
+
end
|
14
|
+
|
15
|
+
def reinstall
|
16
|
+
@@device.reinstall_app
|
17
|
+
end
|
18
|
+
|
19
|
+
def device
|
20
|
+
@@device
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def start_device
|
26
|
+
case @conf['os']
|
27
|
+
when 'android'
|
28
|
+
require 'android_runner'
|
29
|
+
@@device = Calabash::Extras::AndroidRunner.new(@conf['android'])
|
30
|
+
when 'ios'
|
31
|
+
require 'ios_runner'
|
32
|
+
@@device = Calabash::Extras::IosRunner.new(@conf['ios'])
|
33
|
+
else
|
34
|
+
raise 'Unsupported os type: "%s"' % @conf['os']
|
35
|
+
end
|
36
|
+
|
37
|
+
@@device.start
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/ios_runner.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'calabash-cucumber/operations'
|
2
|
+
require 'calabash-cucumber/launcher'
|
3
|
+
require 'calabash-cucumber/launch/simulator_helper'
|
4
|
+
require 'sim_launcher'
|
5
|
+
|
6
|
+
module Calabash
|
7
|
+
module Extras
|
8
|
+
class IosRunner
|
9
|
+
|
10
|
+
include Calabash::Cucumber::Core
|
11
|
+
include Calabash::Cucumber::Operations
|
12
|
+
|
13
|
+
def initialize(config)
|
14
|
+
@config = config
|
15
|
+
|
16
|
+
ENV['DEVICE'] = @config['DEVICE']
|
17
|
+
ENV['PROJECT_DIR'] = @config['PROJECT_DIR']
|
18
|
+
ENV['DEVICE_ENDPOINT'] = @config['DEVICE_ENDPOINT']
|
19
|
+
ENV['BUNDLE_ID'] = @config['BUNDLE_ID']
|
20
|
+
end
|
21
|
+
|
22
|
+
def start
|
23
|
+
reinstall_app
|
24
|
+
end
|
25
|
+
|
26
|
+
def reinstall_app
|
27
|
+
calabash_launcher = Calabash::Cucumber::Launcher.new
|
28
|
+
calabash_launcher.reset_app_jail
|
29
|
+
start_test_server_in_background
|
30
|
+
|
31
|
+
reinstall_hook if defined? self.reinstall_hook
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Calabash
|
2
|
+
module Extras
|
3
|
+
module PageObjectComparator
|
4
|
+
def name
|
5
|
+
self.class.name.rpartition('::').last
|
6
|
+
end
|
7
|
+
|
8
|
+
def ==(other)
|
9
|
+
name == other.name
|
10
|
+
end
|
11
|
+
|
12
|
+
def eql?(other)
|
13
|
+
name == other.name
|
14
|
+
end
|
15
|
+
|
16
|
+
def hash
|
17
|
+
name.hash
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
name
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/test_case.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'yaml'
|
3
|
+
require 'application_handler'
|
4
|
+
|
5
|
+
module Calabash
|
6
|
+
module Extras
|
7
|
+
class TestCase < Test::Unit::TestCase
|
8
|
+
def initialize(name)
|
9
|
+
super name
|
10
|
+
raise 'Config location not found in ENV' unless ENV.has_key? 'config_location'
|
11
|
+
@conf = YAML.load_file ENV['config_location']
|
12
|
+
@runner = Calabash::Extras::ApplicationHandler.new(@conf)
|
13
|
+
end
|
14
|
+
|
15
|
+
def page (clz, *args)
|
16
|
+
@runner.page(clz, *args)
|
17
|
+
end
|
18
|
+
|
19
|
+
def reinstall_force #todo rename
|
20
|
+
@runner.reinstall
|
21
|
+
end
|
22
|
+
|
23
|
+
def platform
|
24
|
+
@conf['os']
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/walker.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'priority_queue'
|
2
|
+
|
3
|
+
module Calabash
|
4
|
+
module Extras
|
5
|
+
class Walker
|
6
|
+
|
7
|
+
MAX_INT = (2**(0.size * 8 -2) -1)
|
8
|
+
|
9
|
+
def initialize(sleep_interval, matrix, log_callback)
|
10
|
+
@sleep_interval = sleep_interval
|
11
|
+
@matrix = matrix
|
12
|
+
@logger = log_callback
|
13
|
+
end
|
14
|
+
|
15
|
+
def go(to)
|
16
|
+
start_point = get_current_page
|
17
|
+
|
18
|
+
@end_point = to
|
19
|
+
|
20
|
+
raise 'Page "%s" does not exist' % [to] if @matrix[to].nil?
|
21
|
+
|
22
|
+
return if start_point == @end_point
|
23
|
+
|
24
|
+
path = find_path start_point, @end_point
|
25
|
+
|
26
|
+
raise 'Unable to find path from "%s" to "%s"' % [start_point, @end_point] if path.last != @end_point
|
27
|
+
|
28
|
+
resolve_path path
|
29
|
+
end
|
30
|
+
|
31
|
+
def last
|
32
|
+
@end_point
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_current_page
|
36
|
+
sleep @sleep_interval
|
37
|
+
all_page_elements = @matrix.keys.first.all_elements
|
38
|
+
@matrix.keys.find { |page| page.match all_page_elements} || raise('Unable to determine current page') #todo replace with match method
|
39
|
+
end
|
40
|
+
|
41
|
+
def resolve_path(path)
|
42
|
+
raise 'Empty path given' if path.empty?
|
43
|
+
|
44
|
+
for i in 0..(path.length - 2)
|
45
|
+
@logger.call('transition from %s to %s' % [path[i], path[i+1]])
|
46
|
+
@matrix[path[i]][path[i+1]].call
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def find_path(start, finish)
|
51
|
+
distances = {}
|
52
|
+
previous = {}
|
53
|
+
nodes = PriorityQueue.new
|
54
|
+
|
55
|
+
@matrix.each_key do |point|
|
56
|
+
if point == start
|
57
|
+
distances[point] = 0
|
58
|
+
nodes[point] = 0
|
59
|
+
else
|
60
|
+
distances[point] = MAX_INT
|
61
|
+
nodes[point] = MAX_INT
|
62
|
+
end
|
63
|
+
previous[point] = nil
|
64
|
+
end
|
65
|
+
|
66
|
+
while nodes
|
67
|
+
smallest = nodes.delete_min_return_key
|
68
|
+
|
69
|
+
if smallest == finish
|
70
|
+
path = []
|
71
|
+
while previous[smallest]
|
72
|
+
path.push(smallest)
|
73
|
+
smallest = previous[smallest]
|
74
|
+
end
|
75
|
+
return path.push(start).reverse
|
76
|
+
end
|
77
|
+
|
78
|
+
if smallest.nil? or distances[smallest] == MAX_INT
|
79
|
+
break
|
80
|
+
end
|
81
|
+
|
82
|
+
@matrix[smallest].each_key do |neighbor|
|
83
|
+
alt = distances[smallest] + 1
|
84
|
+
if alt < distances[neighbor]
|
85
|
+
distances[neighbor] = alt
|
86
|
+
previous[neighbor] = smallest
|
87
|
+
nodes[neighbor] = alt
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
distances.inspect
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'page_object_comparator'
|
3
|
+
|
4
|
+
class PageObjectComparatorTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
class DummyBasePage
|
7
|
+
|
8
|
+
include Calabash::Extras::PageObjectComparator
|
9
|
+
|
10
|
+
def initialize(value)
|
11
|
+
@value = value
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Page1 < DummyBasePage; end
|
16
|
+
class Page2 < DummyBasePage; end
|
17
|
+
|
18
|
+
def test_instances_of_same_class
|
19
|
+
page1 = Page1.new 'value'
|
20
|
+
page2 = Page1.new 'other'
|
21
|
+
|
22
|
+
assert_equal page1.hash, page2.hash, 'Hash should be unique per class, not instance'
|
23
|
+
assert_equal page1, page2, 'Object should be compared by class, not instance'
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_instances_of_different_classes
|
27
|
+
page1 = Page1.new 'same value'
|
28
|
+
page2 = Page2.new 'same value'
|
29
|
+
|
30
|
+
refute_equal page1.hash, page2.hash, 'Hash should be unique per class, not instance'
|
31
|
+
refute_equal page1, page2, 'Object should be compared by class, not instance'
|
32
|
+
end
|
33
|
+
end
|
data/test/walker_test.rb
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'walker'
|
3
|
+
require 'page_object_comparator'
|
4
|
+
|
5
|
+
class WalkerTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
class BaseDummyPage
|
8
|
+
include Calabash::Extras::PageObjectComparator
|
9
|
+
attr_accessor :will_match, :called, :back_called
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@called = false
|
13
|
+
@back_called = false
|
14
|
+
end
|
15
|
+
|
16
|
+
def all_elements
|
17
|
+
'list of all elements in string'
|
18
|
+
end
|
19
|
+
|
20
|
+
def match(all_elements)
|
21
|
+
@will_match
|
22
|
+
end
|
23
|
+
|
24
|
+
def go
|
25
|
+
@called = true
|
26
|
+
end
|
27
|
+
|
28
|
+
def back
|
29
|
+
@back_called = true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class EulaDummyPage < BaseDummyPage; end
|
34
|
+
class LoginDummyPage < BaseDummyPage; end
|
35
|
+
class MainMenuDummyPage < BaseDummyPage; end
|
36
|
+
class UnreachablePage < BaseDummyPage; end
|
37
|
+
class DeadEndPage < BaseDummyPage; end
|
38
|
+
class NonExistentPage < BaseDummyPage; end
|
39
|
+
class RefundDummyPage < BaseDummyPage; end
|
40
|
+
class OrderHistoryDummyPage < BaseDummyPage; end
|
41
|
+
class OrderInfoDummyPage < BaseDummyPage; end
|
42
|
+
|
43
|
+
def setup
|
44
|
+
@eula = EulaDummyPage.new
|
45
|
+
@login = LoginDummyPage.new
|
46
|
+
@main_menu = MainMenuDummyPage.new
|
47
|
+
@unreachable = UnreachablePage.new
|
48
|
+
@not_existent = NonExistentPage.new
|
49
|
+
@order_history = OrderHistoryDummyPage.new
|
50
|
+
@order_info = OrderInfoDummyPage.new
|
51
|
+
@refund = RefundDummyPage.new
|
52
|
+
|
53
|
+
@matrix = {
|
54
|
+
@eula => {
|
55
|
+
@login => lambda { @eula.go },
|
56
|
+
},
|
57
|
+
@login => {
|
58
|
+
@main_menu => lambda { @login.go },
|
59
|
+
@eula => lambda { @main_menu.back }
|
60
|
+
},
|
61
|
+
@main_menu => {
|
62
|
+
@login => lambda { @main_menu.back },
|
63
|
+
@order_history => lambda { @main_menu.go }
|
64
|
+
},
|
65
|
+
@order_history => {
|
66
|
+
@main_menu => lambda { @order_history.back },
|
67
|
+
@order_info => lambda { @order_history.go }
|
68
|
+
},
|
69
|
+
@order_info => {
|
70
|
+
@order_history => lambda { @order_info.back },
|
71
|
+
@refund => lambda { @order_info.go }
|
72
|
+
},
|
73
|
+
@refund => {
|
74
|
+
@order_info => lambda { @refund.back }
|
75
|
+
},
|
76
|
+
@unreachable => {
|
77
|
+
# unreachable
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
@walker = Calabash::Extras::Walker.new(0, @matrix, lambda { |str| } )
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_refund_to_main_menu
|
85
|
+
@refund.will_match = true
|
86
|
+
@walker.go @main_menu
|
87
|
+
|
88
|
+
assert_back_called @refund
|
89
|
+
assert_back_called @order_info
|
90
|
+
assert_back_called @order_history
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_eula_to_refund_page
|
94
|
+
@eula.will_match = true
|
95
|
+
@walker.go @refund
|
96
|
+
|
97
|
+
assert_called @eula
|
98
|
+
assert_called @login
|
99
|
+
assert_called @main_menu
|
100
|
+
assert_called @order_history
|
101
|
+
assert_called @order_info
|
102
|
+
assert_called @order_info
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_unreachable
|
106
|
+
@eula.will_match = true
|
107
|
+
|
108
|
+
err = assert_raise RuntimeError do
|
109
|
+
@walker.go @unreachable
|
110
|
+
end
|
111
|
+
|
112
|
+
assert_equal 'Unable to find path from "%s" to "%s"' % [@eula, @unreachable.name], err.message
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_not_found
|
116
|
+
@eula.will_match = true
|
117
|
+
|
118
|
+
err = assert_raise RuntimeError do
|
119
|
+
@walker.go @not_existent
|
120
|
+
end
|
121
|
+
|
122
|
+
assert_equal 'Page "%s" does not exist' % [@not_existent], err.message
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_unable_to_determine_current_page
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
private
|
130
|
+
|
131
|
+
def assert_called (page, method = :go)
|
132
|
+
assert page.called, 'Call to method "%s" of page %s was expected' % [method, page.name]
|
133
|
+
end
|
134
|
+
|
135
|
+
def assert_back_called (page)
|
136
|
+
assert page.back_called, 'Call to method "back" of page %s was expected' % [page.name]
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: calabash-extras
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sergey Galkin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-02-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: calabash-android
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: calabash-cucumber
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: PriorityQueue
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: TestCase and page traversal tool for writing xunit tests for Android
|
95
|
+
and Ios apps
|
96
|
+
email:
|
97
|
+
- sergey@galkin.me
|
98
|
+
executables: []
|
99
|
+
extensions: []
|
100
|
+
extra_rdoc_files: []
|
101
|
+
files:
|
102
|
+
- Gemfile
|
103
|
+
- Gemfile.lock
|
104
|
+
- README.md
|
105
|
+
- Rakefile
|
106
|
+
- calabash-extras.gemspec
|
107
|
+
- lib/android_runner.rb
|
108
|
+
- lib/application_handler.rb
|
109
|
+
- lib/ios_runner.rb
|
110
|
+
- lib/page_object_comparator.rb
|
111
|
+
- lib/test_case.rb
|
112
|
+
- lib/walker.rb
|
113
|
+
- test/page_object_comparator_test.rb
|
114
|
+
- test/walker_test.rb
|
115
|
+
homepage:
|
116
|
+
licenses: []
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options: []
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
none: false
|
129
|
+
requirements:
|
130
|
+
- - ! '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 1.8.23
|
136
|
+
signing_key:
|
137
|
+
specification_version: 3
|
138
|
+
summary: Utils for writing xunit tests with calabash and page objects
|
139
|
+
test_files:
|
140
|
+
- test/page_object_comparator_test.rb
|
141
|
+
- test/walker_test.rb
|