mohawk 0.0.5 → 0.0.6

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.0.6 / 2013-07-25
2
+ * Enhancements
3
+ * can find a table row based on a hash
4
+
1
5
  === Version 0.0.5 / 2013-07-23
2
6
  * Enhancements
3
7
  * can tell a screen to only consider child controls when searching (can
@@ -21,6 +21,14 @@ When(/^we select the table row with the following information:$/) do |table|
21
21
  on(DataEntryForm).select_people table.hashes.first
22
22
  end
23
23
 
24
+ Then(/^we can find the row with the following information:$/) do |table|
25
+ expected_info = table.hashes.first
26
+ actual_info = on(DataEntryForm).find_people expected_info
27
+ expected_info.each do |key, value|
28
+ actual_info.send(key).should eq(value)
29
+ end
30
+ end
31
+
24
32
  When /^we select the "(.*?)"th table row$/ do |index|
25
33
  on(DataEntryForm).people[index.to_i].select
26
34
  end
@@ -55,4 +63,3 @@ end
55
63
  Then(/^accessing the values in row "([^"]*)" should be snappy$/) do |which_row|
56
64
  Timeout.timeout(5.0) { on(DataEntryForm).people[which_row.to_i].cells.should_not be_empty }
57
65
  end
58
-
@@ -17,6 +17,12 @@ Feature: Working with tables
17
17
  | Anna Doe | 3/4/1975 |
18
18
  Then the row with index "1" should be selected
19
19
 
20
+ Scenario: Finding a row
21
+ Then we can find the row with the following information:
22
+ | name | date_of_birth | state |
23
+ | John Doe | 12/15/1967 | FL |
24
+
25
+
20
26
  Scenario: Selecting a row from a child item
21
27
  When we select the "1"th table row
22
28
  Then the row with index "1" should be selected
@@ -12,7 +12,7 @@ module Mohawk
12
12
  def select(which_item)
13
13
  case which_item
14
14
  when Hash
15
- find_row_with(which_item).select
15
+ select_by_hash(which_item)
16
16
  else
17
17
  select_by_value(which_item)
18
18
  end
@@ -42,6 +42,12 @@ module Mohawk
42
42
  def select_by_value(which_item)
43
43
  view.select which_item
44
44
  end
45
+
46
+ def select_by_hash(which_item)
47
+ found_row = find_row_with(which_item)
48
+ found_row.select
49
+ found_row
50
+ end
45
51
  end
46
52
  end
47
53
  end
@@ -223,8 +223,8 @@ module Mohawk
223
223
  #
224
224
  # @example
225
225
  # table(:some_table, :id => "tableId")
226
- # # will generate 'some_table', 'some_table=', 'some_table_headers', 'select_some_table'
227
- # # and 'some_table_view' methods to get an Enumerable of table rows,
226
+ # # will generate 'some_table', 'some_table=', 'some_table_headers', 'select_some_table',
227
+ # # find_some_table and 'some_table_view' methods to get an Enumerable of table rows,
228
228
  # # select a table item, return all of the headers and get the raw view
229
229
  #
230
230
  # @param [String] the name used for the generated methods
@@ -244,6 +244,9 @@ module Mohawk
244
244
  define_method("select_#{name}") do |hash_info|
245
245
  adapter.table(locator).select hash_info
246
246
  end
247
+ define_method("find_#{name}") do |hash_info|
248
+ adapter.table(locator).find_row_with hash_info
249
+ end
247
250
  define_method("#{name}_headers") do
248
251
  adapter.table(locator).headers
249
252
  end
@@ -1,3 +1,3 @@
1
1
  module Mohawk
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -38,6 +38,18 @@ describe Mohawk::Accessors::Table do
38
38
  screen.top = 'John Elway'
39
39
  end
40
40
 
41
+ it 'can find a row by hash' do
42
+ TableStubber.stub(table)
43
+ .with_headers('Favorite Color', 'Favorite Number', 'Name')
44
+ .and_row('Blue', '7', 'Levi')
45
+ .and_row('Purple', '9', 'Larry')
46
+
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
52
+
41
53
  context 'selecting a row by hash' do
42
54
  it 'selects the row if all values match' do
43
55
  TableStubber.stub(table)
@@ -49,6 +61,15 @@ describe Mohawk::Accessors::Table do
49
61
  screen.select_top :column_one => 'second', :column_three => 'bar'
50
62
  end
51
63
 
64
+ it 'returns the row that it selected' do
65
+ TableStubber.stub(table)
66
+ .with_headers('name', 'age')
67
+ .and_row('Levi', '33')
68
+
69
+ table.should_receive(:select).with(0)
70
+ screen.select_top(:age => 33).name.should eq('Levi')
71
+ end
72
+
52
73
  it 'can handle non-string values' do
53
74
  TableStubber.stub(table)
54
75
  .with_headers('name', 'age')
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.5
4
+ version: 0.0.6
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-07-23 00:00:00.000000000 Z
12
+ date: 2013-07-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rautomation