mohawk 0.1.0 → 0.1.4

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.1.4
2
+ * Enhancements
3
+ * make it more explicit if you want to add a row to the selection
4
+
1
5
  === Version 0.1.0 / 2013-10-03
2
6
  * Enhancments
3
7
  * added multi-select support to tables and select lists
data/README.md CHANGED
@@ -51,6 +51,48 @@ on(LoginScreen) do |screen|
51
51
  end
52
52
  ```
53
53
 
54
+ ## Accessors
55
+ ### Window
56
+ #### window
57
+ The `window` accessor defines how to locate the top-level window that you would like to use for your screen. Valid locators are dictated by the [RAutomation::Window](https://github.com/jarmo/RAutomation/blob/master/lib/rautomation/adapter/ms_uia/window.rb) class.
58
+
59
+ #### parent
60
+ There are times where you need to define the root parent window for your screen, but it happens to be within a child window of a top-level window. The `parent` accessor allows you to specify further within `window`, and that will be used as the root of all other searches.
61
+
62
+ ### Controls
63
+ Control accessors are used to define various controls within your page object. Valid locators are dictated by the [RAutomation::Control](https://github.com/jarmo/RAutomation/blob/master/lib/rautomation/adapter/ms_uia/control.rb) class.
64
+
65
+ #### text
66
+ The `text` accessor is used to define an edit text control within your screen. Given `text(:user_name, id: 'txtUserName')`, you will get the following methods:
67
+
68
+ * `:user_name` - gets the value
69
+ * `:user_name=` - sets the value
70
+ * `:clear_user_name` - clears the value
71
+ * `:enter_user_name` - types the given value (useful for masked text fields)
72
+ * `:user_name_view` - the raw RAutomation view
73
+
74
+ #### button
75
+ The `button` accessor is used to define a button control within your screen. Given `button(:ok, value: 'OK')`, you will get the following methods:
76
+
77
+ * `:ok` - clicks the button
78
+ * `:ok_value` - returns the text value of the button
79
+ * `:ok_view` - the raw RAutomation view
80
+
81
+ #### combo_box
82
+ ##### aliases
83
+ * `:combobox`
84
+ * `:dropdown` / `:drop_down`
85
+ * `:select_list`
86
+
87
+ The `combo_box` accessor is used to define a control that implements the `SelectList` pattern, such as a `ComboBox`, `ListBox`, etc. Given `combo_box(:city, id: 'cbCities')`, you will get the following methods:
88
+
89
+ * `:city` - returns the currently selected item
90
+ * `:clear_city` - clears the item by either index, value or `RegEx`
91
+ * `:city_selections` - returns the currently selected options
92
+ * `:city=` / `:select_city` - sets the selected item by index, value or `RegEx`
93
+ * `:city_options` - returns the list of available options
94
+ * `:city_view` - the raw RAutomation view
95
+
54
96
  ## Contributing
55
97
 
56
98
  1. Fork it
@@ -20,7 +20,7 @@ end
20
20
  When(/^we add rows "([^"]*)" to the selection$/) do |which_rows|
21
21
  on(DataEntryForm) do |screen|
22
22
  which_rows.split(', ').map(&:to_i).each do |row|
23
- screen.people = row
23
+ screen.add_people row
24
24
  end
25
25
  end
26
26
  end
@@ -13,6 +13,14 @@ module Mohawk
13
13
  find_row_with(which_item).select
14
14
  end
15
15
 
16
+ def add(which_item)
17
+ find_row_with(which_item).add_to_selection
18
+ end
19
+
20
+ def clear_all
21
+ view.selected_rows.each(&:clear)
22
+ end
23
+
16
24
  def clear(which_item)
17
25
  find_row_with(which_item).clear
18
26
  end
@@ -50,7 +58,7 @@ module Mohawk
50
58
  end
51
59
 
52
60
  def find_by_value(which_item)
53
- view.row(text: which_item)
61
+ find { |r| r.row.value == which_item }
54
62
  end
55
63
 
56
64
  def find_by_hash(row_info)
@@ -15,6 +15,11 @@ module Mohawk
15
15
  end
16
16
 
17
17
  def select
18
+ UiaDll::table_single_select(@table.view.search_information, row.row)
19
+ self
20
+ end
21
+
22
+ def add_to_selection
18
23
  row.select
19
24
  self
20
25
  end
@@ -250,6 +250,9 @@ module Mohawk
250
250
  define_method("#{name}=") do |which_item|
251
251
  adapter.table(locator).select which_item
252
252
  end
253
+ define_method("add_#{name}") do |hash_info|
254
+ adapter.table(locator).add hash_info
255
+ end
253
256
  define_method("select_#{name}") do |hash_info|
254
257
  adapter.table(locator).select hash_info
255
258
  end
@@ -1,3 +1,3 @@
1
1
  module Mohawk
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.4"
3
3
  end
data/mohawk.gemspec CHANGED
@@ -18,10 +18,11 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency 'rautomation', '~> 0.13'
21
+ gem.add_dependency 'rautomation', '~> 0.14'
22
22
  gem.add_dependency 'require_all'
23
23
  gem.add_dependency 'page_navigation', '>= 0.7'
24
24
  gem.add_dependency 'childprocess', '~> 0.3.9'
25
+ gem.add_dependency 'ffi', '1.9.0'
25
26
 
26
27
  gem.add_development_dependency 'cucumber'
27
28
  gem.add_development_dependency 'rspec', '>= 2.12.0'
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mohawk::Accessors::TableRow do
4
+ let(:table) { double('RAutomation Table') }
5
+ let(:adapter) { double('mohawk adapter') }
6
+ let(:mohawk_table) { Mohawk::Accessors::Table.new(adapter, value: 'whatever') }
7
+ let(:stubber) do
8
+ TableStubber.stub(table)
9
+ .with_headers('Name', 'Age')
10
+ .and_row('Levi', '33')
11
+ end
12
+
13
+ subject { Mohawk::Accessors::TableRow.new(mohawk_table, 0) }
14
+
15
+ before(:each) do
16
+ adapter.stub_chain(:window, :table).and_return(table)
17
+ end
18
+
19
+ it '#add_to_selection' do
20
+ stubber.rows[0].should_receive(:select)
21
+ subject.add_to_selection
22
+ end
23
+
24
+ it '#select' do
25
+ stubber.should_singly_select_row(0)
26
+ subject.select
27
+ end
28
+ end
@@ -32,17 +32,18 @@ describe Mohawk::Accessors::Table do
32
32
  stubber = TableStubber.stub(table)
33
33
  .with_headers('Name')
34
34
  .and_row('First Person')
35
- .and_row('Secont Person')
35
+ .and_row('Second Person')
36
36
 
37
- stubber.rows[1].should_receive(:select)
37
+ stubber.should_singly_select_row 1
38
38
  screen.top = 1
39
39
  end
40
40
 
41
41
  it 'can select a row by value' do
42
- row = double('row')
43
- table.should_receive(:row).with(text: 'John Elway').and_return(row)
44
- row.should_receive(:select)
42
+ stubber = TableStubber.stub(table)
43
+ .with_headers('Name')
44
+ .and_row('John Elway')
45
45
 
46
+ stubber.should_singly_select_row 0
46
47
  screen.top = 'John Elway'
47
48
  end
48
49
 
@@ -55,10 +56,10 @@ describe Mohawk::Accessors::Table do
55
56
  end
56
57
 
57
58
  it 'can clear a row by value' do
58
- row = double('row')
59
- table.should_receive(:row).with(text: 'John Elway').and_return(row)
60
- row.should_receive(:clear)
59
+ stubber = TableStubber.stub(table)
60
+ .with_headers('Name').and_row('John Elway')
61
61
 
62
+ stubber.rows[0].should_receive(:clear)
62
63
  screen.clear_top('John Elway')
63
64
  end
64
65
 
@@ -102,12 +103,22 @@ describe Mohawk::Accessors::Table do
102
103
  end
103
104
 
104
105
  context 'selecting a row by hash' do
106
+ it 'singly selects the row' do
107
+ stubber = TableStubber.stub(table)
108
+ .with_headers('name', 'age')
109
+ .and_row('Levi', '33')
110
+ .and_row('John', '54')
111
+
112
+ stubber.should_singly_select_row(1)
113
+ screen.select_top(:age => 54)
114
+ end
115
+
105
116
  it 'returns the row that it selected' do
106
117
  stubber = TableStubber.stub(table)
107
118
  .with_headers('name', 'age')
108
119
  .and_row('Levi', '33')
109
120
 
110
- stubber.rows[0].should_receive(:select)
121
+ stubber.should_singly_select_row(0)
111
122
  screen.select_top(:age => 33).name.should eq('Levi')
112
123
  end
113
124
 
@@ -118,7 +129,7 @@ describe Mohawk::Accessors::Table do
118
129
 
119
130
  Mohawk::Accessors::Table.any_instance.should_receive(:find_row_with).with(:age => 33).and_call_original
120
131
 
121
- stubber.rows[0].should_receive(:select)
132
+ stubber.should_singly_select_row(0)
122
133
  screen.select_top :age => 33
123
134
  end
124
135
  end
@@ -145,6 +156,27 @@ describe Mohawk::Accessors::Table do
145
156
  end
146
157
  end
147
158
 
159
+ context 'adding a row to the selection' do
160
+ let(:stubber) do
161
+ TableStubber.stub(table)
162
+ .with_headers('name')
163
+ .and_row('Levi')
164
+ .and_row('John')
165
+ end
166
+
167
+ it 'returns the row that is added' do
168
+ stubber.rows[1].should_receive(:select)
169
+ screen.add_top(name: 'John').name.should eq('John')
170
+ end
171
+
172
+ it 'uses the find_row semantics' do
173
+ Mohawk::Accessors::Table.any_instance.should_receive(:find_row_with).with(name: 'Levi').and_call_original
174
+
175
+ stubber.rows[0].should_receive(:select)
176
+ screen.add_top name: 'Levi'
177
+ end
178
+ end
179
+
148
180
  it 'has rows' do
149
181
  TableStubber.stub(table)
150
182
  .with_headers('Column')
@@ -179,7 +211,7 @@ describe Mohawk::Accessors::Table do
179
211
  end
180
212
 
181
213
  it 'can be selected' do
182
- table_stubber.rows[0].should_receive(:select)
214
+ table_stubber.should_singly_select_row(0)
183
215
  screen.top[0].select
184
216
  end
185
217
 
@@ -1,7 +1,7 @@
1
1
  require 'securerandom'
2
2
 
3
3
  class TableStubber
4
- include RSpec::Mocks::ExampleMethods
4
+ include RSpec::Mocks::ExampleMethods, RAutomation::Adapter::MsUia
5
5
 
6
6
  attr_reader :table, :rows
7
7
 
@@ -9,6 +9,7 @@ class TableStubber
9
9
  @table = table
10
10
  @id = SecureRandom.base64
11
11
  @table.stub(:search_information).and_return(@id)
12
+ @table.stub(:selected_rows).and_return []
12
13
  @rows = []
13
14
  end
14
15
 
@@ -26,6 +27,10 @@ class TableStubber
26
27
  self
27
28
  end
28
29
 
30
+ def should_singly_select_row(which)
31
+ UiaDll.should_receive(:table_single_select).with(@id, which)
32
+ end
33
+
29
34
  private
30
35
  def add_row
31
36
  row = double("table #{@id}, row #{rows.count}")
@@ -44,6 +49,7 @@ class TableStubber
44
49
  cell.stub(:text).and_return(value)
45
50
  cells << cell
46
51
  end
52
+ row.stub(:value).and_return(values.first)
47
53
  row.stub(:cells).and_return(cells)
48
54
  end
49
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mohawk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.4
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-10-03 00:00:00.000000000 Z
12
+ date: 2014-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rautomation
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0.13'
21
+ version: '0.14'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: '0.13'
29
+ version: '0.14'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: require_all
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
77
  version: 0.3.9
78
+ - !ruby/object:Gem::Dependency
79
+ name: ffi
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - '='
84
+ - !ruby/object:Gem::Version
85
+ version: 1.9.0
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - '='
92
+ - !ruby/object:Gem::Version
93
+ version: 1.9.0
78
94
  - !ruby/object:Gem::Dependency
79
95
  name: cucumber
80
96
  requirement: !ruby/object:Gem::Requirement
@@ -335,6 +351,7 @@ files:
335
351
  - spec/lib/mohawk/accessors/menu_spec.rb
336
352
  - spec/lib/mohawk/accessors/radio_spec.rb
337
353
  - spec/lib/mohawk/accessors/spinner_spec.rb
354
+ - spec/lib/mohawk/accessors/table_row_spec.rb
338
355
  - spec/lib/mohawk/accessors/table_spec.rb
339
356
  - spec/lib/mohawk/accessors/tabs_spec.rb
340
357
  - spec/lib/mohawk/accessors/text_spec.rb
@@ -445,6 +462,7 @@ test_files:
445
462
  - spec/lib/mohawk/accessors/menu_spec.rb
446
463
  - spec/lib/mohawk/accessors/radio_spec.rb
447
464
  - spec/lib/mohawk/accessors/spinner_spec.rb
465
+ - spec/lib/mohawk/accessors/table_row_spec.rb
448
466
  - spec/lib/mohawk/accessors/table_spec.rb
449
467
  - spec/lib/mohawk/accessors/tabs_spec.rb
450
468
  - spec/lib/mohawk/accessors/text_spec.rb