gametel 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- data/features/navigation.feature +4 -0
- data/features/step_definitions/navigation_steps.rb +13 -0
- data/features/support/core_ext/string.rb +5 -0
- data/features/support/screens/never_will_exist.rb +7 -0
- data/lib/gametel.rb +1 -1
- data/lib/gametel/navigation.rb +4 -2
- data/lib/gametel/version.rb +1 -1
- data/lib/gametel/waiter.rb +13 -3
- data/spec/lib/gametel/navigation_spec.rb +6 -0
- data/spec/lib/gametel/waiter_spec.rb +4 -0
- metadata +8 -4
data/features/navigation.feature
CHANGED
@@ -12,3 +12,7 @@ Feature: Navigation through the screens of the application
|
|
12
12
|
Given I am on the the ViewsMenuScreen
|
13
13
|
When I continue navigating to the Controls screen
|
14
14
|
Then I should see the text "Checkbox 1" on the screen
|
15
|
+
|
16
|
+
Scenario: Waiting for screens to be active
|
17
|
+
When I wait for the "NeverWillExist" screen
|
18
|
+
Then the last error should tell me "Timed out waiting for NeverWillExist to be active"
|
@@ -13,3 +13,16 @@ end
|
|
13
13
|
Given /^I am on the the ViewsMenuScreen$/ do
|
14
14
|
navigate_to(ViewsMenuScreen)
|
15
15
|
end
|
16
|
+
|
17
|
+
When(/^I wait for the "(.*?)" screen$/) do |which|
|
18
|
+
begin
|
19
|
+
on(which.to_class)
|
20
|
+
rescue Exception => e
|
21
|
+
@last_error = e
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Then(/^the last error should tell me "(.*?)"$/) do |what|
|
26
|
+
@last_error.message.should eq(what)
|
27
|
+
end
|
28
|
+
|
data/lib/gametel.rb
CHANGED
data/lib/gametel/navigation.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'page_navigation'
|
2
|
+
require 'gametel/waiter'
|
2
3
|
|
3
4
|
module Gametel
|
4
5
|
#
|
@@ -6,14 +7,15 @@ module Gametel
|
|
6
7
|
# definitions.
|
7
8
|
#
|
8
9
|
module Navigation
|
9
|
-
include PageNavigation
|
10
|
+
include PageNavigation, Gametel::Waiter
|
10
11
|
|
11
12
|
#
|
12
13
|
# create a new screen given a class name
|
13
14
|
#
|
14
15
|
def on(cls, &block)
|
15
16
|
@current_screen = @current_page = cls.new
|
16
|
-
|
17
|
+
waiting_for = "#{cls} to be active"
|
18
|
+
wait_until(10, waiting_for) { @current_screen.active? } if @current_screen.respond_to?(:active?)
|
17
19
|
block.call @current_screen if block
|
18
20
|
@current_screen
|
19
21
|
end
|
data/lib/gametel/version.rb
CHANGED
data/lib/gametel/waiter.rb
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
module Gametel
|
2
2
|
module Waiter
|
3
|
-
class Timeout < StandardError
|
3
|
+
class Timeout < StandardError
|
4
|
+
def initialize(waiting_for=nil)
|
5
|
+
super(waiting_for)
|
6
|
+
@waiting_for = waiting_for
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
return super unless @waiting_for
|
11
|
+
"Timed out waiting for #{@waiting_for}"
|
12
|
+
end
|
13
|
+
end
|
4
14
|
|
5
|
-
def wait_until(timeout=10, &block)
|
15
|
+
def wait_until(timeout=10, message=nil, &block)
|
6
16
|
last_call = ::Time.now + timeout
|
7
17
|
while ::Time.now < last_call
|
8
18
|
stoppit = block.call if block
|
@@ -10,7 +20,7 @@ module Gametel
|
|
10
20
|
sleep 0.1
|
11
21
|
end
|
12
22
|
|
13
|
-
raise Timeout
|
23
|
+
raise Timeout.new message
|
14
24
|
end
|
15
25
|
end
|
16
26
|
end
|
@@ -27,4 +27,10 @@ describe Gametel::Navigation do
|
|
27
27
|
self.should_receive(:wait_until)
|
28
28
|
on(NavigationScreen)
|
29
29
|
end
|
30
|
+
|
31
|
+
it "should say what we are waiting on" do
|
32
|
+
screen.stub(:active?).and_return(true)
|
33
|
+
self.should_receive(:wait_until).with(10, "NavigationScreen to be active")
|
34
|
+
on(NavigationScreen)
|
35
|
+
end
|
30
36
|
end
|
@@ -18,4 +18,8 @@ describe Gametel::Waiter do
|
|
18
18
|
it "is not as forgiving if you make it wait" do
|
19
19
|
lambda { wait_until(0) }.should raise_error
|
20
20
|
end
|
21
|
+
|
22
|
+
it "can be told what it is waiting on" do
|
23
|
+
lambda { wait_until(0, "something to happen") }.should raise_error "Timed out waiting for something to happen"
|
24
|
+
end
|
21
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gametel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-04-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: brazenhead
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- features/step_definitions/text_steps.rb
|
141
141
|
- features/step_definitions/view_steps.rb
|
142
142
|
- features/support/ApiDemos.apk
|
143
|
+
- features/support/core_ext/string.rb
|
143
144
|
- features/support/debug.keystore
|
144
145
|
- features/support/env.rb
|
145
146
|
- features/support/hooks.rb
|
@@ -154,6 +155,7 @@ files:
|
|
154
155
|
- features/support/screens/efficient_adapter_screen.rb
|
155
156
|
- features/support/screens/lists_menu_screen.rb
|
156
157
|
- features/support/screens/main_menu_screen.rb
|
158
|
+
- features/support/screens/never_will_exist.rb
|
157
159
|
- features/support/screens/seek_bar_screen.rb
|
158
160
|
- features/support/screens/views_menu_screen.rb
|
159
161
|
- features/text.feature
|
@@ -199,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
201
|
version: '0'
|
200
202
|
segments:
|
201
203
|
- 0
|
202
|
-
hash:
|
204
|
+
hash: -1788323344300920655
|
203
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
206
|
none: false
|
205
207
|
requirements:
|
@@ -208,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
210
|
version: '0'
|
209
211
|
segments:
|
210
212
|
- 0
|
211
|
-
hash:
|
213
|
+
hash: -1788323344300920655
|
212
214
|
requirements: []
|
213
215
|
rubyforge_project:
|
214
216
|
rubygems_version: 1.8.25
|
@@ -240,6 +242,7 @@ test_files:
|
|
240
242
|
- features/step_definitions/text_steps.rb
|
241
243
|
- features/step_definitions/view_steps.rb
|
242
244
|
- features/support/ApiDemos.apk
|
245
|
+
- features/support/core_ext/string.rb
|
243
246
|
- features/support/debug.keystore
|
244
247
|
- features/support/env.rb
|
245
248
|
- features/support/hooks.rb
|
@@ -254,6 +257,7 @@ test_files:
|
|
254
257
|
- features/support/screens/efficient_adapter_screen.rb
|
255
258
|
- features/support/screens/lists_menu_screen.rb
|
256
259
|
- features/support/screens/main_menu_screen.rb
|
260
|
+
- features/support/screens/never_will_exist.rb
|
257
261
|
- features/support/screens/seek_bar_screen.rb
|
258
262
|
- features/support/screens/views_menu_screen.rb
|
259
263
|
- features/text.feature
|