calabash-cucumber 0.9.133 → 0.9.134
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/lib/calabash-cucumber/ibase.rb +71 -18
- data/lib/calabash-cucumber/version.rb +2 -2
- metadata +2 -2
|
@@ -4,42 +4,95 @@ require 'calabash-cucumber/operations'
|
|
|
4
4
|
class Calabash::IBase
|
|
5
5
|
include Calabash::Cucumber::Operations
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
@world = world
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def embed(*args)
|
|
12
|
-
@world.send(:embed,*args)
|
|
13
|
-
end
|
|
7
|
+
attr_accessor :world, :transition_duration
|
|
14
8
|
|
|
15
|
-
def
|
|
16
|
-
|
|
9
|
+
def initialize(world, transition_duration=0.5)
|
|
10
|
+
self.world = world
|
|
11
|
+
self.transition_duration = transition_duration
|
|
17
12
|
end
|
|
18
13
|
|
|
19
14
|
def trait
|
|
15
|
+
raise "You should define a trait method or a title method" unless respond_to?(:title)
|
|
20
16
|
"navigationItemView marked:'#{self.title}'"
|
|
21
17
|
end
|
|
22
18
|
|
|
23
|
-
def
|
|
24
|
-
|
|
19
|
+
def current_page?
|
|
20
|
+
element_exists(trait)
|
|
25
21
|
end
|
|
26
22
|
|
|
27
|
-
def
|
|
23
|
+
def page(clz, *args)
|
|
24
|
+
clz.new(world, *args)
|
|
25
|
+
end
|
|
28
26
|
|
|
27
|
+
def await(wait_opts={})
|
|
28
|
+
wait_for_elements_exist([trait], wait_opts)
|
|
29
|
+
unless wait_opts.has_key?(:await_animation) && !wait_opts[:await_animation]
|
|
30
|
+
sleep(transition_duration)
|
|
31
|
+
end
|
|
32
|
+
self
|
|
29
33
|
end
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
##
|
|
36
|
+
# Performs a transition from receiver page to another by performing a +:tap+ gesture
|
|
37
|
+
# or a user specified +:action+.
|
|
38
|
+
# Caller must supply a hash of options +transition_options+ to describe the transition.
|
|
39
|
+
# Transition options may have the following keys
|
|
40
|
+
#
|
|
41
|
+
# +:tap+: A uiquery used to perform a tap gesture to begin transition
|
|
42
|
+
# +:action+: A proc to use begin transition (either :tap or :action must be supplied)
|
|
43
|
+
# +:page+: A page object or page object class to transition to (target page). If a class is provided this
|
|
44
|
+
# is instantiated using the +page+ method of self. If no +:page+ is supplied, +self+ is used.
|
|
45
|
+
# +:await+: If specified and truthy will await the +:page+ after performing gesture (usually to wait
|
|
46
|
+
# for animation to finish)
|
|
47
|
+
# +:tap_options+: If +:tap+ is provided used to pass as options to touch
|
|
48
|
+
# +:wait_options+: When awaiting target page, pass these options to the +await+ method
|
|
49
|
+
#
|
|
50
|
+
# Returns the transition target page
|
|
51
|
+
#
|
|
52
|
+
# Note it is assumed that the target page is a Calabash::IBase (or acts accordingly)
|
|
53
|
+
def transition(transition_options={})
|
|
54
|
+
uiquery = transition_options[:tap]
|
|
55
|
+
action = transition_options[:action]
|
|
56
|
+
page_arg = transition_options[:page]
|
|
57
|
+
should_await = transition_options.has_key?(:await) ? transition_options[:await] : true
|
|
32
58
|
|
|
33
|
-
|
|
59
|
+
if action.nil? && uiquery.nil?
|
|
60
|
+
raise "Called transition without providing a gesture (:tap or :action) #{transition_options}"
|
|
61
|
+
end
|
|
34
62
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
63
|
+
if uiquery
|
|
64
|
+
tap_options = transition_options[:tap_options] || {}
|
|
65
|
+
touch(uiquery, tap_options)
|
|
66
|
+
else
|
|
67
|
+
action.call()
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
page_obj = page_arg.is_a?(Class) ? page(page_arg) : page_arg
|
|
71
|
+
page_obj ||= self
|
|
72
|
+
|
|
73
|
+
if should_await
|
|
74
|
+
wait_opts = transition_options[:wait_options] || {}
|
|
75
|
+
if page_obj == self
|
|
76
|
+
unless wait_opts.has_key?(:await_animation) && !wait_opts[:await_animation]
|
|
77
|
+
sleep(transition_duration)
|
|
78
|
+
end
|
|
79
|
+
else
|
|
80
|
+
page_obj.await(wait_opts)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
page_obj
|
|
38
85
|
end
|
|
39
86
|
|
|
40
|
-
def await_screenshot(wait_opts={},screenshot_opts={})
|
|
87
|
+
def await_screenshot(wait_opts={}, screenshot_opts={})
|
|
41
88
|
await(wait_opts)
|
|
42
89
|
screenshot_embed(screenshot_opts)
|
|
43
90
|
end
|
|
44
91
|
|
|
92
|
+
|
|
93
|
+
protected
|
|
94
|
+
def method_missing(name, *args, &block)
|
|
95
|
+
world.send(name, *args, &block)
|
|
96
|
+
end
|
|
97
|
+
|
|
45
98
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: calabash-cucumber
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.134
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-03-
|
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: cucumber
|