sandwich 0.0.16 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.16
1
+ 0.0.17
@@ -1,3 +1,9 @@
1
+ When /^I follow "([^\"]*)" within the row with "([^\"]*)"$/ do |link, text|
2
+ inside("//tr[td and contains(., '#{text}')]") do
3
+ click_link(link)
4
+ end
5
+ end
6
+
1
7
  When /^I fill in the "([^"]+)" row, "([^"]+)" column in (.+?) with "([^"]+)"$/ do |row, column, path, value|
2
8
  selector = xpath(selector_for(path))
3
9
  _, column_index = page.find(:xpath, "#{selector}//tr", :text => /#{column}/).
@@ -11,6 +17,14 @@ Then /^I should see "([^"]+)" in the (\w+) data row of (.+)$/ do |value, ordinal
11
17
  page.should have_xpath("(#{xpath(selector_for(path))}//tr[td])[#{ordinal.to_i}]", :text => value)
12
18
  end
13
19
 
14
- Then /^I should see (\d+) entr(?:y|ies) in ([^\"]+)$/ do |total, path|
15
- page.should have_xpath("#{xpath(selector_for(path))}//tr[td]", :count => total.to_i)
20
+ Then /^I should see (\d+|no) entr(?:y|ies) in ([^\"]+)$/ do |total, path|
21
+ if total.to_i == 0
22
+ page.should have_no_xpath("#{xpath(selector_for(path))}//tr[td]")
23
+ else
24
+ page.should have_xpath("#{xpath(selector_for(path))}//tr[td]", :count => total.to_i)
25
+ end
26
+ end
27
+
28
+ Then /^I should see "([^\"]*)" within the row with "([^\"]*)"$/ do |expected, text|
29
+ page.should have_xpath("//tr[contains(., '#{text}')]", :text => expected)
16
30
  end
@@ -1,7 +1,7 @@
1
1
  module Sandwich
2
2
  module WithinHelper
3
- def inside(locator)
4
- locator ? within(:xpath, xpath(locator)) { yield } : yield
3
+ def inside(locator, options = {})
4
+ locator ? within(:xpath, locator) { yield } : yield
5
5
  end
6
6
  end
7
7
  end
@@ -9,7 +9,7 @@ end
9
9
  World(Sandwich::WithinHelper)
10
10
 
11
11
  When /^I follow "([^\"]*)"(?: (?:with)?in (.+))$/ do |link, container|
12
- inside(selector_for(container)) { click_link(link) }
12
+ inside(xpath(selector_for(container))) { click_link(link) }
13
13
  end
14
14
 
15
15
  Then /^I should see "([^\"]*)" (?:with)?in (.+)$/ do |text, selector|
@@ -28,6 +28,20 @@ Then /^I should see (.+)$/ do |selector|
28
28
  locate(:xpath, xpath(selector_for(selector)))
29
29
  end
30
30
 
31
+ When /^I fill in the following:$/ do |table|
32
+ table.raw.each do |(k, v)|
33
+ node = find(:xpath, Capybara::XPath.field(k))
34
+
35
+ raise Capybara::ElementNotFound, "Unable to locate '#{k}'" unless node
36
+
37
+ if (node.tag_name == 'select')
38
+ node.select(v)
39
+ else
40
+ node.set(v)
41
+ end
42
+ end
43
+ end
44
+
31
45
  When /^I fill in (.+) with the following:$/ do |selector, table|
32
46
  within(:xpath, xpath(selector_for(selector))) do
33
47
  table.raw.each do |(k, v)|
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 16
9
- version: 0.0.16
8
+ - 17
9
+ version: 0.0.17
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Leal
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-18 00:00:00 +01:00
17
+ date: 2010-05-20 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency