mohawk 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog CHANGED
@@ -1,3 +1,9 @@
1
+ === Version 0.1.0 / 2013-10-03
2
+ * Enhancments
3
+ * added multi-select support to tables and select lists
4
+ * bumped RAutomation dependency to include fixes for selecting
5
+ ListBox items when they are out of view
6
+
1
7
  === Version 0.0.9 / 2013-09-12
2
8
  * Fixes
3
9
  * loosened the gemspec restrictions on RAutomation
@@ -1,19 +1,36 @@
1
1
  Feature: Working with combo boxes
2
2
 
3
- Scenario: Selecting items by index
4
- When I select index "2" from the "fruits" combo box
5
- Then the "Coconut" option should be selected in the "fruits" combo box
3
+ Scenario: Selecting items by index
4
+ When I select index "2" from the "fruits" combo box
5
+ Then the "Coconut" option should be selected in the "fruits" combo box
6
6
 
7
- Scenario: Selecting items by value
8
- When I select the value "Orange" from the "fruits" combo box
9
- Then the "Orange" option should be selected in the "fruits" combo box
7
+ Scenario: Selecting items by value
8
+ When I select the value "Orange" from the "fruits" combo box
9
+ Then the "Orange" option should be selected in the "fruits" combo box
10
10
 
11
- Scenario: Getting the available options
12
- When I look at the options for the "fruits" combo box"
13
- Then I should see the following options:
14
- | Option |
15
- | Apple |
16
- | Caimito |
17
- | Coconut |
18
- | Orange |
19
- | Passion Fruit |
11
+ Scenario: Selecting multiple items
12
+ Given we toggle the multi-select button
13
+ When I select indexes "0, 1, 2" from the "fruits_list" combo box
14
+ Then the "Apple, Orange, Mango" options should be selected in the "fruits_list" combo box
15
+
16
+ Scenario: Clearing items by index
17
+ Given we toggle the multi-select button
18
+ When I select indexes "0, 1, 2" from the "fruits_list" combo box
19
+ But I clear the item at index "1" from the "fruits_list" combo box
20
+ Then the "Apple, Mango" options should be selected in the "fruits_list" combo box
21
+
22
+ Scenario: Clearing items by value
23
+ Given we toggle the multi-select button
24
+ When I select indexes "0, 1, 2" from the "fruits_list" combo box
25
+ But I clear item "Mango" from the "fruits_list" combo box
26
+ Then the "Apple, Orange" options should be selected in the "fruits_list" combo box
27
+
28
+ Scenario: Getting the available options
29
+ When I look at the options for the "fruits" combo box"
30
+ Then I should see the following options:
31
+ | Option |
32
+ | Apple |
33
+ | Caimito |
34
+ | Coconut |
35
+ | Orange |
36
+ | Passion Fruit |
@@ -1,13 +1,25 @@
1
- When /^I select index "(.*?)" from the "(.*?)" combo box$/ do |index, name|
2
- on(MainScreen).send "#{name.to_field}=", index.to_i
1
+ When /^I select index(es)? "(.*?)" from the "(.*?)" combo box$/ do |_, indexes, name|
2
+ on(MainScreen) do |screen|
3
+ indexes.split(', ').map(&:to_i).each do |index|
4
+ screen.send "select_#{name.to_field}", index
5
+ end
6
+ end
3
7
  end
4
8
 
5
9
  When /^I select the value "(.*?)" from the "(.*?)" combo box$/ do |index, name|
6
10
  on(MainScreen).send "#{name.to_field}=", index
7
11
  end
8
12
 
9
- Then /^the "(.*?)" option should be selected in the "(.*?)" combo box$/ do |value, name|
10
- on(MainScreen).send("#{name.to_field}").should eq(value)
13
+ When(/^I clear the item at index "([^"]*)" from the "([^"]*)" combo box$/) do |which, name|
14
+ on(MainScreen).send("clear_#{name.to_field}", which.to_i)
15
+ end
16
+
17
+ When(/^I clear item "([^"]*)" from the "([^"]*)" combo box$/) do |which, name|
18
+ on(MainScreen).send("clear_#{name.to_field}", which)
19
+ end
20
+
21
+ Then /^the "(.*?)" option(s)? should be selected in the "(.*?)" combo box$/ do |value, has_multiple, name|
22
+ on(MainScreen).send("#{name.to_field}_selections").should eq(value.split(', '))
11
23
  end
12
24
 
13
25
  When /^I look at the options for the "(.*?)" combo box"$/ do |name|
@@ -18,3 +30,7 @@ Then /^I should see the following options:$/ do |table|
18
30
  expected_options = table.hashes.map {|row| row["Option"] }
19
31
  @options.should eq(expected_options)
20
32
  end
33
+
34
+ Given(/^we toggle the multi-select button$/) do
35
+ on(MainScreen).toggle_multi
36
+ end
@@ -17,8 +17,33 @@ When /^we select the table row with the value "([^"]*)"$/ do |row_value|
17
17
  on(DataEntryForm).people = row_value
18
18
  end
19
19
 
20
- When(/^we select the table row with the following information:$/) do |table|
21
- on(DataEntryForm).select_people table.hashes.first
20
+ When(/^we add rows "([^"]*)" to the selection$/) do |which_rows|
21
+ on(DataEntryForm) do |screen|
22
+ which_rows.split(', ').map(&:to_i).each do |row|
23
+ screen.people = row
24
+ end
25
+ end
26
+ end
27
+
28
+ When(/^we clear rows "([^"]*)" from the selection$/) do |which_rows|
29
+ on(DataEntryForm) do |screen|
30
+ which_rows.split(', ').map(&:to_i).each do |row|
31
+ screen.clear_people(row)
32
+ end
33
+ end
34
+ end
35
+
36
+ Then(/^rows "([^"]*)" should all (not )?be selected$/) do |which_rows, to_not_be|
37
+ should_or_should_not = (to_not_be && :should_not) || :should
38
+ on(DataEntryForm) do |screen|
39
+ which_rows.split(', ').map(&:to_i).each do |row|
40
+ screen.people[row].send(should_or_should_not, be_selected)
41
+ end
42
+ end
43
+ end
44
+
45
+ When(/^we (select|clear) the table row with the following information:$/) do |select_or_clear, table|
46
+ on(DataEntryForm).send("#{select_or_clear}_people", table.hashes.first)
22
47
  end
23
48
 
24
49
  Then(/^we can find the row with the following information:$/) do |table|
@@ -33,8 +58,9 @@ When /^we select the "(.*?)"th table row$/ do |index|
33
58
  on(DataEntryForm).people[index.to_i].select
34
59
  end
35
60
 
36
- Then /^the row with index "(.*?)" should be selected$/ do |which_row|
37
- on(DataEntryForm).people[which_row.to_i].should be_selected
61
+ Then /^the row with index "(.*?)" should (not )?be selected$/ do |which_row, to_not_be|
62
+ should_or_should_not = (to_not_be && :should_not) || :should
63
+ on(DataEntryForm).people[which_row.to_i].send(should_or_should_not, be_selected)
38
64
  end
39
65
 
40
66
  Then /^the row with index "(.*?)" should look like the following:$/ do |which_row, table|
Binary file
@@ -8,7 +8,11 @@ class MainScreen
8
8
  button(:about, :value => "About")
9
9
  control(:about_control, :value => 'About')
10
10
  button(:data_grid, :value => "Data Grid View")
11
+
12
+ button(:toggle_multi, :value => 'Toggle Multi-Select')
11
13
  combo_box(:fruits, :id => "FruitsComboBox")
14
+ select_list(:fruits_list, :id => 'FruitListBox')
15
+
12
16
  checkbox(:first_checkbox, :id => "checkBox")
13
17
  radio(:first_radio, :id => "radioButton1")
14
18
  label(:label_control, :id => "label1")
@@ -22,11 +22,29 @@ Feature: Working with tables
22
22
  | name | date_of_birth | state |
23
23
  | John Doe | 12/15/1967 | FL |
24
24
 
25
-
26
25
  Scenario: Selecting a row from a child item
27
26
  When we select the "1"th table row
28
27
  Then the row with index "1" should be selected
29
28
 
29
+ Scenario: Adding rows to the selection
30
+ Given there are a lot of records in a table
31
+ When we add rows "1, 3, 5" to the selection
32
+ Then rows "1, 3, 5" should all be selected
33
+
34
+ Scenario: Clearing rows from a selection
35
+ Given there are a lot of records in a table
36
+ When we add rows "2, 3, 4, 5" to the selection
37
+ But we clear rows "2, 4" from the selection
38
+ Then rows "3, 5" should all be selected
39
+ And rows "2, 4" should all not be selected
40
+
41
+ Scenario: Clearing a row by matching cell information
42
+ Given we add rows "0, 1" to the selection
43
+ When we clear the table row with the following information:
44
+ | name | date_of_birth |
45
+ | Anna Doe | 3/4/1975 |
46
+ Then the row with index "1" should not be selected
47
+
30
48
  Scenario: Rows have cells
31
49
  Then the row with index "0" should look like the following:
32
50
  | Name | Date of Birth | State |
@@ -7,18 +7,31 @@ module Mohawk
7
7
  @view = adapter.window.select_list(locator)
8
8
  end
9
9
 
10
- def value
11
- @view.value
10
+ def set(value)
11
+ find(value).select
12
12
  end
13
13
 
14
- def set(value)
15
- @view.select value if value.instance_of? Fixnum
16
- @view.set value if value.instance_of? String
14
+ def clear(value)
15
+ find(value).clear
16
+ end
17
+
18
+ def method_missing(meth, *args, &block)
19
+ return super unless @view.respond_to?(meth)
20
+ @view.send(meth, *args, &block)
17
21
  end
18
22
 
19
23
  def options
20
24
  @view.options.map &:text
21
25
  end
26
+
27
+ def find(what)
28
+ case what
29
+ when Fixnum
30
+ @view.options[what]
31
+ when String
32
+ @view.option(text: what)
33
+ end
34
+ end
22
35
  end
23
36
  end
24
37
  end
@@ -10,16 +10,22 @@ module Mohawk
10
10
  end
11
11
 
12
12
  def select(which_item)
13
- case which_item
14
- when Hash
15
- select_by_hash(which_item)
16
- else
17
- select_by_value(which_item)
18
- end
13
+ find_row_with(which_item).select
14
+ end
15
+
16
+ def clear(which_item)
17
+ find_row_with(which_item).clear
19
18
  end
20
19
 
21
20
  def find_row_with(row_info)
22
- found_row = find { |r| r.all_match? row_info }
21
+ found_row = case row_info
22
+ when Hash
23
+ find_by_hash(row_info)
24
+ when Fixnum
25
+ find_by_index(row_info)
26
+ when String
27
+ find_by_value(row_info)
28
+ end
23
29
  raise "A row with #{row_info} was not found" unless found_row
24
30
  found_row
25
31
  end
@@ -39,14 +45,16 @@ module Mohawk
39
45
  end
40
46
 
41
47
  private
42
- def select_by_value(which_item)
43
- view.select which_item
48
+ def find_by_index(which_item)
49
+ self[which_item]
44
50
  end
45
51
 
46
- def select_by_hash(which_item)
47
- found_row = find_row_with(which_item)
48
- found_row.select
49
- found_row
52
+ def find_by_value(which_item)
53
+ view.row(text: which_item)
54
+ end
55
+
56
+ def find_by_hash(row_info)
57
+ find { |r| r.all_match? row_info }
50
58
  end
51
59
  end
52
60
  end
@@ -11,11 +11,17 @@ module Mohawk
11
11
  end
12
12
 
13
13
  def selected?
14
- @table.view.selected? row.row
14
+ row.selected?
15
15
  end
16
16
 
17
17
  def select
18
- @table.view.select row.row
18
+ row.select
19
+ self
20
+ end
21
+
22
+ def clear
23
+ row.clear
24
+ self
19
25
  end
20
26
 
21
27
  def cells
@@ -24,8 +24,8 @@ module Mohawk
24
24
  end
25
25
 
26
26
  def select(which_item)
27
- @view.select which_item if which_item.is_a? Integer
28
- @view.set which_item if which_item.is_a? String
27
+ @view.options[which_item].select if which_item.is_a? Integer
28
+ @view.option(text: which_item).select if which_item.is_a? String
29
29
  end
30
30
  end
31
31
  end
@@ -89,7 +89,7 @@ module Mohawk
89
89
  #
90
90
  # @example
91
91
  # combo_box(:status, :id => 'statusComboBox')
92
- # # will generate 'status', 'status=' and 'status_options' methods
92
+ # # will generate 'status', 'status_selections', 'status=', 'select_status','clear_status' and 'status_options' methods
93
93
  #
94
94
  # @param [String] the name used for the generated methods
95
95
  # @param [Hash] locator for how the combo box is found
@@ -103,9 +103,18 @@ module Mohawk
103
103
  define_method("#{name}") do
104
104
  adapter.combo(locator).value
105
105
  end
106
+ define_method("clear_#{name}") do |item|
107
+ adapter.combo(locator).clear item
108
+ end
109
+ define_method("#{name}_selections") do
110
+ adapter.combo(locator).values
111
+ end
112
+
106
113
  define_method("#{name}=") do |item|
107
114
  adapter.combo(locator).set item
108
115
  end
116
+ alias_method "select_#{name}", "#{name}="
117
+
109
118
  define_method("#{name}_options") do
110
119
  adapter.combo(locator).options
111
120
  end
@@ -223,9 +232,9 @@ module Mohawk
223
232
  #
224
233
  # @example
225
234
  # table(:some_table, :id => "tableId")
226
- # # will generate 'some_table', 'some_table=', 'some_table_headers', 'select_some_table',
235
+ # # will generate 'some_table', 'some_table=', 'some_table_headers', 'select_some_table', 'clear_some_table',
227
236
  # # find_some_table and 'some_table_view' methods to get an Enumerable of table rows,
228
- # # select a table item, return all of the headers and get the raw view
237
+ # # select a table item, clear a table item, return all of the headers and get the raw view
229
238
  #
230
239
  # @param [String] the name used for the generated methods
231
240
  # @param [Hash] locator for how the label is found
@@ -247,6 +256,9 @@ module Mohawk
247
256
  define_method("find_#{name}") do |hash_info|
248
257
  adapter.table(locator).find_row_with hash_info
249
258
  end
259
+ define_method("clear_#{name}") do |hash_info|
260
+ adapter.table(locator).clear hash_info
261
+ end
250
262
  define_method("#{name}_headers") do
251
263
  adapter.table(locator).headers
252
264
  end
@@ -1,3 +1,3 @@
1
1
  module Mohawk
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
data/mohawk.gemspec CHANGED
@@ -18,7 +18,7 @@ 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.12.0'
21
+ gem.add_dependency 'rautomation', '~> 0.13'
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'
@@ -26,9 +26,11 @@ describe Mohawk::Accessors::Combo do
26
26
  let(:screen) { ComboBoxScreen.new }
27
27
  let(:window) { double("RAutomation Window") }
28
28
  let(:combo_box_field) { double("ComboBox Field") }
29
+ let(:options) { double("ComboBox::Options").as_null_object }
29
30
 
30
31
  before(:each) do
31
32
  RAutomation::Window.stub(:new).and_return(window)
33
+ combo_box_field.stub(:options).and_return(options)
32
34
  end
33
35
 
34
36
  context "accessing combo box controls" do
@@ -42,16 +44,48 @@ describe Mohawk::Accessors::Combo do
42
44
  screen.nacho_combos.should eq("Selected Item")
43
45
  end
44
46
 
47
+ it 'knows the currently selected items' do
48
+ combo_box_field.should_receive(:values).and_return(['first', 'second'])
49
+ screen.nacho_combos_selections.should eq(['first', 'second'])
50
+ end
51
+
45
52
  it "selects items by index" do
46
- combo_box_field.should_receive(:select).with(3)
53
+ options.should_receive(:[]).with(3).and_return(double.as_null_object)
47
54
  screen.nacho_combos = 3
48
55
  end
49
56
 
50
57
  it "selects items by value" do
51
- combo_box_field.should_receive(:set).with("Desired Value")
58
+ option = double('combo option')
59
+ combo_box_field.should_receive(:option).with(text: "Desired Value").and_return(option)
60
+ option.should_receive(:select)
61
+
52
62
  screen.nacho_combos = "Desired Value"
53
63
  end
54
64
 
65
+ it 'select is an alias for equals' do
66
+ option = double('combo option')
67
+ combo_box_field.should_receive(:option).with(text: 'Desired Value').and_return(option)
68
+ option.should_receive(:select)
69
+
70
+ screen.select_nacho_combos 'Desired Value'
71
+ end
72
+
73
+ it 'clears items by index' do
74
+ option = double('combo option')
75
+ options.should_receive(:[]).with(3).and_return(option)
76
+ option.should_receive(:clear)
77
+
78
+ screen.clear_nacho_combos 3
79
+ end
80
+
81
+ it 'clears items by value' do
82
+ option = double('combo option')
83
+ combo_box_field.should_receive(:option).with(text: 'Desired Value').and_return(option)
84
+ option.should_receive(:clear)
85
+
86
+ screen.clear_nacho_combos 'Desired Value'
87
+ end
88
+
55
89
  it "is aware of the available options" do
56
90
  options = [Option.new("first"), Option.new("second"), Option.new("third")]
57
91
  combo_box_field.should_receive(:options).and_return(options)
@@ -29,64 +29,120 @@ describe Mohawk::Accessors::Table do
29
29
  end
30
30
 
31
31
  it 'can select a row by index' do
32
- table.should_receive(:select).with(1)
32
+ stubber = TableStubber.stub(table)
33
+ .with_headers('Name')
34
+ .and_row('First Person')
35
+ .and_row('Secont Person')
36
+
37
+ stubber.rows[1].should_receive(:select)
33
38
  screen.top = 1
34
39
  end
35
40
 
36
41
  it 'can select a row by value' do
37
- table.should_receive(:select).with 'John Elway'
42
+ row = double('row')
43
+ table.should_receive(:row).with(text: 'John Elway').and_return(row)
44
+ row.should_receive(:select)
45
+
38
46
  screen.top = 'John Elway'
39
47
  end
40
48
 
41
- it 'can find a row by hash' do
42
- TableStubber.stub(table)
49
+ it 'can clear a row by index' do
50
+ stubber = TableStubber.stub(table)
51
+ .with_headers('Name').and_row('Whomever')
52
+
53
+ stubber.rows[0].should_receive(:clear)
54
+ screen.clear_top(0)
55
+ end
56
+
57
+ 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)
61
+
62
+ screen.clear_top('John Elway')
63
+ end
64
+
65
+ context 'finding rows by Hash' do
66
+ it 'can find a row by hash' do
67
+ TableStubber.stub(table)
43
68
  .with_headers('Favorite Color', 'Favorite Number', 'Name')
44
69
  .and_row('Blue', '7', 'Levi')
45
70
  .and_row('Purple', '9', 'Larry')
46
71
 
47
- found_row = screen.find_top :favorite_number => 9
48
- found_row.favorite_color.should eq('Purple')
49
- found_row.favorite_number.should eq('9')
50
- found_row.name.should eq('Larry')
51
- end
72
+ found_row = screen.find_top :favorite_number => 9
73
+ found_row.favorite_color.should eq('Purple')
74
+ found_row.favorite_number.should eq('9')
75
+ found_row.name.should eq('Larry')
76
+ end
52
77
 
53
- context 'selecting a row by hash' do
54
- it 'selects the row if all values match' do
78
+ it 'matches all values' do
79
+ stubber = TableStubber.stub(table)
80
+ .with_headers('Column One', 'Column Two', 'Column Three')
81
+ .and_row('first', 'something', 'foo')
82
+ .and_row('second', 'another', 'bar')
83
+
84
+ screen.find_top(:column_one => 'second', :column_three => 'bar').row.should eq(stubber.rows[1])
85
+ end
86
+
87
+ it 'can handle non-string values' do
88
+ stubber = TableStubber.stub(table)
89
+ .with_headers('name', 'age')
90
+ .and_row('Levi', '33')
91
+
92
+ screen.find_top(:age => 33).row.should eq(stubber.rows.first)
93
+ end
94
+
95
+ it 'raises if no row is found' do
55
96
  TableStubber.stub(table)
56
- .with_headers('Column One', 'Column Two', 'Column Three')
57
- .and_row('first', 'something', 'foo')
58
- .and_row('second', 'another', 'bar')
97
+ .with_headers('Column One', 'Column Two', 'Column Three')
98
+ .and_row('first', 'something', 'foo')
59
99
 
60
- table.should_receive(:select).with(1)
61
- screen.select_top :column_one => 'second', :column_three => 'bar'
100
+ expect { screen.find_top :column_one => 'not found' }.to raise_error "A row with {:column_one=>\"not found\"} was not found"
62
101
  end
102
+ end
63
103
 
104
+ context 'selecting a row by hash' do
64
105
  it 'returns the row that it selected' do
65
- TableStubber.stub(table)
106
+ stubber = TableStubber.stub(table)
66
107
  .with_headers('name', 'age')
67
108
  .and_row('Levi', '33')
68
109
 
69
- table.should_receive(:select).with(0)
110
+ stubber.rows[0].should_receive(:select)
70
111
  screen.select_top(:age => 33).name.should eq('Levi')
71
112
  end
72
113
 
73
- it 'can handle non-string values' do
74
- TableStubber.stub(table)
114
+ it 'uses the find_row semantics' do
115
+ stubber = TableStubber.stub(table)
75
116
  .with_headers('name', 'age')
76
117
  .and_row('Levi', '33')
77
118
 
78
- table.should_receive(:select).with(0)
119
+ Mohawk::Accessors::Table.any_instance.should_receive(:find_row_with).with(:age => 33).and_call_original
120
+
121
+ stubber.rows[0].should_receive(:select)
79
122
  screen.select_top :age => 33
80
123
  end
124
+ end
81
125
 
82
- it 'raises if no row is found' do
83
- TableStubber.stub(table)
84
- .with_headers('Column One', 'Column Two', 'Column Three')
85
- .and_row('first', 'something', 'foo')
126
+ context 'clearing a row by hash' do
127
+ it 'returns the row that it cleared' do
128
+ stubber = TableStubber.stub(table)
129
+ .with_headers('name', 'age')
130
+ .and_row('Levi', '33')
86
131
 
87
- lambda { screen.select_top :column_one => 'not found' }.should raise_error "A row with {:column_one=>\"not found\"} was not found"
132
+ stubber.rows[0].should_receive(:clear)
133
+ screen.clear_top(:age => 33).name.should eq('Levi')
88
134
  end
89
135
 
136
+ it 'uses the find_row semantics' do
137
+ stubber = TableStubber.stub(table)
138
+ .with_headers('name', 'age')
139
+ .and_row('Levi', '33')
140
+
141
+ Mohawk::Accessors::Table.any_instance.should_receive(:find_row_with).with(:age => 33).and_call_original
142
+
143
+ stubber.rows[0].should_receive(:clear)
144
+ screen.clear_top :age => 33
145
+ end
90
146
  end
91
147
 
92
148
  it 'has rows' do
@@ -108,8 +164,9 @@ describe Mohawk::Accessors::Table do
108
164
  end
109
165
 
110
166
  describe Mohawk::Accessors::TableRow do
167
+ let(:table_stubber) { TableStubber.stub(table) }
111
168
  before(:each) do
112
- TableStubber.stub(table).with_headers('column').and_row('first row')
169
+ table_stubber.with_headers('column').and_row('first row')
113
170
  end
114
171
 
115
172
  it 'can get an individual row' do
@@ -117,12 +174,12 @@ describe Mohawk::Accessors::Table do
117
174
  end
118
175
 
119
176
  it 'knows if it is selected' do
120
- table.should_receive(:selected?).with(0).and_return(true)
177
+ table_stubber.rows[0].should_receive(:selected?).and_return(true)
121
178
  screen.top[0].should be_selected
122
179
  end
123
180
 
124
181
  it 'can be selected' do
125
- table.should_receive(:select).with(0)
182
+ table_stubber.rows[0].should_receive(:select)
126
183
  screen.top[0].select
127
184
  end
128
185
 
@@ -24,9 +24,12 @@ describe Mohawk::Accessors::TreeView do
24
24
  let(:screen) { TreeViewScreen.new }
25
25
  let(:window) { double("RAutomation Window") }
26
26
  let(:tree_field) { double("TreeView Field") }
27
+ let(:options) { double("TreeView Options") }
28
+ let(:option) { double("TreeView Option") }
27
29
 
28
30
  before(:each) do
29
31
  RAutomation::Window.stub(:new).and_return(window)
32
+ tree_field.stub(:options).and_return(options)
30
33
  end
31
34
 
32
35
  context "working with TreeView controls" do
@@ -40,12 +43,16 @@ describe Mohawk::Accessors::TreeView do
40
43
  end
41
44
 
42
45
  it "can select items by index" do
43
- tree_field.should_receive(:select).with(7)
46
+ options.should_receive(:[]).with(7).and_return(option)
47
+ option.should_receive(:select)
48
+
44
49
  screen.oak = 7
45
50
  end
46
51
 
47
52
  it "can select items by their value" do
48
- tree_field.should_receive(:set).with("item value")
53
+ tree_field.should_receive(:option).with(text: 'item value').and_return(option)
54
+ option.should_receive(:select)
55
+
49
56
  screen.oak = "item value"
50
57
  end
51
58
 
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
 
4
4
  require 'rspec'
5
+ require 'rspec/mocks'
5
6
  require 'ffi_stub'
6
7
  require 'mohawk'
7
8
  require 'coveralls'
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.0.9
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,24 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-12 00:00:00.000000000 Z
12
+ date: 2013-10-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rautomation
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.12.0
21
+ version: '0.13'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ! '>='
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 0.12.0
29
+ version: '0.13'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: require_all
32
32
  requirement: !ruby/object:Gem::Requirement