gametel 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
+
@@ -0,0 +1,5 @@
1
+ class String
2
+ def to_class
3
+ Object.const_get(self)
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ class NeverWillExist
2
+ include Gametel
3
+
4
+ def active?
5
+ false
6
+ end
7
+ end
@@ -13,7 +13,7 @@ module Gametel
13
13
  ROBOTIUM_RIGHT = 22
14
14
 
15
15
  def self.included(cls)
16
- cls.extend Gametel::Accessors
16
+ cls.extend Gametel::Accessors, Gametel::Waiter
17
17
  end
18
18
 
19
19
  def initialize(pform = :brazenhead)
@@ -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
- wait_until { @current_screen.active? } if @current_screen.respond_to?(:active?)
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
@@ -1,3 +1,3 @@
1
1
  module Gametel
2
- VERSION = "0.5.6"
2
+ VERSION = "0.5.7"
3
3
  end
@@ -1,8 +1,18 @@
1
1
  module Gametel
2
2
  module Waiter
3
- class Timeout < StandardError; end
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.6
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-03-13 00:00:00.000000000 Z
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: 2214503716202349439
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: 2214503716202349439
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