calabash-cucumber 0.9.133 → 0.9.134

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,42 +4,95 @@ require 'calabash-cucumber/operations'
4
4
  class Calabash::IBase
5
5
  include Calabash::Cucumber::Operations
6
6
 
7
- def initialize(world)
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 puts(*args)
16
- @world.send(:puts, *args)
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 page(clz,*args)
24
- clz.new(@world,*args)
19
+ def current_page?
20
+ element_exists(trait)
25
21
  end
26
22
 
27
- def step(s)
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
- def steps(ss)
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
- end
59
+ if action.nil? && uiquery.nil?
60
+ raise "Called transition without providing a gesture (:tap or :action) #{transition_options}"
61
+ end
34
62
 
35
- def await(opts={})
36
- wait_for_elements_exist([trait], opts)
37
- self
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
@@ -1,6 +1,6 @@
1
1
  module Calabash
2
2
  module Cucumber
3
- VERSION = "0.9.133"
4
- FRAMEWORK_VERSION = "0.9.133"
3
+ VERSION = "0.9.134"
4
+ FRAMEWORK_VERSION = "0.9.134"
5
5
  end
6
6
  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.133
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-01 00:00:00.000000000 Z
12
+ date: 2013-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber