gametel 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ === Version 0.3 / 2012-8-29
2
+ * Enhancements
3
+ * Added the ability to check the existence of a view by id
4
+
1
5
  === Version 0.2 / 2012-8-14
2
6
  * Enhancements
3
7
  * Added the enter method to Gametel module to press the enter key on the device
@@ -0,0 +1,9 @@
1
+ Feature: Determining whether or not a view exists
2
+
3
+ Scenario: Checking the existence of a view
4
+ When I'm on the buttons screen
5
+ Then we should know that the view with id "button_normal" exists
6
+
7
+ Scenario: Checking the absence of a view
8
+ When I'm on the buttons screen
9
+ Then we should know that the view with id "checkbox_button" does not exist
@@ -0,0 +1,5 @@
1
+ Feature: Working with Spinners
2
+
3
+ Scenario: Retrieving the selected Spinner text
4
+ When I'm on the controls screen
5
+ Then I can see the spinner value referenced by "id" is "Mercury"
@@ -26,3 +26,9 @@ end
26
26
  Then /^I should not have the value "(.*?)" on the control screen$/ do |text_value|
27
27
  on(ControlsScreen).should_not have_text text_value
28
28
  end
29
+
30
+ Then /^I should have the value "(.*?)" in the text field identified by "(.*?)"$/ do |text_value, how|
31
+ on(ControlsScreen) do |screen|
32
+ screen.send("text_field_#{how}").should eq(text_value)
33
+ end
34
+ end
@@ -0,0 +1,12 @@
1
+ Then /^we should know that the view with id "(.*?)" exists$/ do |with_this_id|
2
+ on(ButtonScreen) do |screen|
3
+ screen.should have_view(with_this_id)
4
+ end
5
+ end
6
+
7
+ Then /^we should know that the view with id "(.*?)" does not exist$/ do |with_this_id|
8
+ on(ButtonScreen) do |screen|
9
+ screen.should_not have_view(with_this_id)
10
+ end
11
+ end
12
+
@@ -0,0 +1,5 @@
1
+ Then /^I can see the spinner value referenced by "(.*?)" is "(.*?)"$/ do |how, the_selected_value|
2
+ on(ControlsScreen) do |screen|
3
+ screen.send("spinner_#{how}").should eq(the_selected_value)
4
+ end
5
+ end
@@ -2,18 +2,18 @@ require 'calabash-android/management/app_installation'
2
2
 
3
3
  AfterConfiguration do |config|
4
4
  FeatureNameMemory.feature_name = nil
5
+ uninstall_apps
6
+ install_app(ENV["TEST_APP_PATH"])
7
+ install_app(ENV["APP_PATH"])
5
8
  end
6
9
 
7
10
  Before do |scenario|
8
11
  feature_name = scenario.feature.name
9
12
  if FeatureNameMemory.feature_name != feature_name
10
13
  log "Is first scenario - reinstalling apps"
11
-
12
- uninstall_apps
13
- install_app(ENV["TEST_APP_PATH"])
14
- install_app(ENV["APP_PATH"])
14
+
15
15
  FeatureNameMemory.feature_name = feature_name
16
- end
16
+ end
17
17
  end
18
18
 
19
19
  FeatureNameMemory = Class.new
@@ -11,4 +11,5 @@ class ControlsScreen
11
11
  checkbox(:checkbox_id, :id => 'check1')
12
12
  radio_button(:radio_button_text, :text => 'RadioButton 1')
13
13
  radio_button(:radio_button_id, :id => 'radio2')
14
+ spinner(:spinner_id, :id => 'spinner1')
14
15
  end
@@ -35,3 +35,8 @@ Feature: Interacting with the standard text field
35
35
  Then I should have the value "example text" on the control screen
36
36
  When I clear the text from the text field identified by "name"
37
37
  Then I should not have the value "example text" on the control screen
38
+
39
+ Scenario: Retrieving text identified by index
40
+ Given I'm on the controls screen
41
+ When I enter "example text" into the text field identified by "id"
42
+ Then I should have the value "example text" in the text field identified by "id"
data/gametel.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Gametel::VERSION
17
17
 
18
- gem.add_dependency 'calabash-android', '>= 0.2.11'
18
+ gem.add_dependency 'calabash-android', '>= 0.2.12'
19
19
 
20
20
  gem.add_development_dependency 'rspec', '>= 2.6.0'
21
21
  gem.add_development_dependency 'cucumber'
@@ -6,7 +6,7 @@ module Gametel
6
6
  #
7
7
  # @example
8
8
  # text(:first_name, :index => 0)
9
- # # will generate 'first_name=' and 'clear_first_name' methods
9
+ # # will generate 'first_name', 'first_name=' and 'clear_first_name' methods
10
10
  #
11
11
  # @param [String] the name used for the generated methods
12
12
  # @param [Hash] locator for how the text is found The valid
@@ -16,6 +16,9 @@ module Gametel
16
16
  # * :index
17
17
  #
18
18
  def text(name, locator)
19
+ define_method("#{name}") do
20
+ platform.get_text(locator)
21
+ end
19
22
  define_method("#{name}=") do |value|
20
23
  platform.enter_text(value, locator)
21
24
  end
@@ -130,6 +133,23 @@ module Gametel
130
133
  platform.click_view(locator)
131
134
  end
132
135
  end
136
+
137
+ #
138
+ # Generates one method to get the selected item text.
139
+ # @example
140
+ # spinner(:spinner_item, :id => 'id_name_of_your_control')
141
+ # # will generate 'spinner_item' method
142
+ #
143
+ # @param [String] the name used for the generated methods
144
+ # @param [Hash] locator indicating an id for how the spinner is found.
145
+ # The only valid keys are:
146
+ # * :id
147
+ #
148
+ def spinner(name, locator)
149
+ define_method(name) do
150
+ platform.get_spinner_value(locator) if locator[:id]
151
+ end
152
+ end
133
153
  end
134
154
  end
135
155
 
@@ -6,6 +6,13 @@ module Gametel
6
6
  module Platforms
7
7
  class Calabash
8
8
 
9
+ #
10
+ # get text
11
+ #
12
+ def get_text(locator)
13
+ performAction('get_text_by_id', locator[:id])['message'] if locator[:id]
14
+ end
15
+
9
16
  #
10
17
  # enter text in a text box
11
18
  #
@@ -88,6 +95,18 @@ module Gametel
88
95
  true
89
96
  end
90
97
 
98
+ #
99
+ # determine if a view exists
100
+ #
101
+ def has_view?(locator)
102
+ begin
103
+ performAction 'has_view', locator
104
+ rescue
105
+ return false
106
+ end
107
+ true
108
+ end
109
+
91
110
  #
92
111
  # press the back button
93
112
  #
@@ -123,6 +142,14 @@ module Gametel
123
142
  performAction 'wait_for_text', text_to_find
124
143
  end
125
144
 
145
+ #
146
+ # get the selected spinner value
147
+ #
148
+ def get_spinner_value(spinner_id)
149
+ result = performAction 'get_selected_spinner_item_text', spinner_id[:id]
150
+ result['message']
151
+ end
152
+
126
153
  end
127
154
  end
128
155
  end
@@ -1,3 +1,3 @@
1
1
  module Gametel
2
- VERSION = "0.2"
2
+ VERSION = "0.3"
3
3
  end
data/lib/gametel.rb CHANGED
@@ -30,6 +30,13 @@ module Gametel
30
30
  platform.enabled?(locator)
31
31
  end
32
32
 
33
+ #
34
+ # Returns true if a view exists
35
+ #
36
+ def has_view?(locator)
37
+ platform.has_view?(locator)
38
+ end
39
+
33
40
  #
34
41
  # Press the back button
35
42
  #
@@ -19,6 +19,7 @@ class AccessorsSampleScreen
19
19
  radio_button(:radio_id, :id => 'some_radio_id')
20
20
  view(:view_id, :id => 'some_view_id')
21
21
  view(:view_text, :text => 'Any view text')
22
+ spinner(:spinner_id, :id => 'spinner_id')
22
23
  end
23
24
 
24
25
  describe Gametel::Accessors do
@@ -73,6 +74,12 @@ describe Gametel::Accessors do
73
74
  platform.should_receive(:performAction).with('clear_id_field', 'fnid')
74
75
  screen.clear_first_name_id
75
76
  end
77
+
78
+ it "should know how to get text by id" do
79
+ platform.should_receive(:performAction).with('get_text_by_id', 'fnid').and_return('message' => 'the value')
80
+ screen.first_name_id.should eq('the value')
81
+ end
82
+
76
83
  end
77
84
 
78
85
  context "buttons" do
@@ -133,5 +140,12 @@ describe Gametel::Accessors do
133
140
  screen.view_text
134
141
  end
135
142
  end
143
+
144
+ context "spinners" do
145
+ it "should be able to determine their selected item" do
146
+ platform.should_receive(:performAction).with('get_selected_spinner_item_text', 'spinner_id').and_return('message' => 'the text value')
147
+ screen.spinner_id.should eq('the text value')
148
+ end
149
+ end
136
150
  end
137
151
  end
@@ -31,6 +31,17 @@ describe Gametel do
31
31
  screen.should be_enabled('some_id')
32
32
  end
33
33
 
34
+ it "should know if a view exists" do
35
+ platform.should_receive(:performAction).with('has_view', 'some_id').and_return("success" => true)
36
+ screen.should have_view('some_id')
37
+ end
38
+
39
+ it "should know if a view does not exist" do
40
+ platform.should_receive(:performAction).with('has_view', 'some_id').and_throw('we do not care what this exception is')
41
+ screen.should_not have_view('some_id')
42
+ end
43
+
44
+
34
45
  it "should know how to press the back button" do
35
46
  platform.should_receive(:performAction).with('go_back')
36
47
  screen.back
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.2'
4
+ version: '0.3'
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: 2012-08-14 00:00:00.000000000 Z
13
+ date: 2012-08-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: calabash-android
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.2.11
22
+ version: 0.2.12
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
- version: 0.2.11
30
+ version: 0.2.12
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: rspec
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -953,18 +953,22 @@ files:
953
953
  - cucumber.yml
954
954
  - features/button.feature
955
955
  - features/checkbox.feature
956
+ - features/has_view.feature
956
957
  - features/is_enabled.feature
957
958
  - features/list_item.feature
958
959
  - features/main_screen.feature
959
960
  - features/radio_button.feature
961
+ - features/spinners.feature
960
962
  - features/step_definitions/button_steps.rb
961
963
  - features/step_definitions/calabash_steps.rb
962
964
  - features/step_definitions/checkbox_steps.rb
963
965
  - features/step_definitions/controls_steps.rb
966
+ - features/step_definitions/has_view_steps.rb
964
967
  - features/step_definitions/is_enabled_steps.rb
965
968
  - features/step_definitions/list_item_steps.rb
966
969
  - features/step_definitions/main_screen_steps.rb
967
970
  - features/step_definitions/radio_button_steps.rb
971
+ - features/step_definitions/spinners_steps.rb
968
972
  - features/step_definitions/view_steps.rb
969
973
  - features/support/app_installation_hooks.rb
970
974
  - features/support/app_life_cycle_hooks.rb
@@ -1019,18 +1023,22 @@ summary: High level wrapper around android drivers
1019
1023
  test_files:
1020
1024
  - features/button.feature
1021
1025
  - features/checkbox.feature
1026
+ - features/has_view.feature
1022
1027
  - features/is_enabled.feature
1023
1028
  - features/list_item.feature
1024
1029
  - features/main_screen.feature
1025
1030
  - features/radio_button.feature
1031
+ - features/spinners.feature
1026
1032
  - features/step_definitions/button_steps.rb
1027
1033
  - features/step_definitions/calabash_steps.rb
1028
1034
  - features/step_definitions/checkbox_steps.rb
1029
1035
  - features/step_definitions/controls_steps.rb
1036
+ - features/step_definitions/has_view_steps.rb
1030
1037
  - features/step_definitions/is_enabled_steps.rb
1031
1038
  - features/step_definitions/list_item_steps.rb
1032
1039
  - features/step_definitions/main_screen_steps.rb
1033
1040
  - features/step_definitions/radio_button_steps.rb
1041
+ - features/step_definitions/spinners_steps.rb
1034
1042
  - features/step_definitions/view_steps.rb
1035
1043
  - features/support/app_installation_hooks.rb
1036
1044
  - features/support/app_life_cycle_hooks.rb