diabolo-webrat 0.4.4.1 → 0.4.4.2
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/History.txt +7 -0
- data/lib/webrat/core/configuration.rb +4 -0
- data/lib/webrat/core/elements/field.rb +2 -0
- data/lib/webrat/core/matchers/have_xpath.rb +2 -2
- data/lib/webrat/core/methods.rb +2 -4
- data/lib/webrat/core/session.rb +1 -0
- data/lib/webrat/selenium/location_strategy_javascript/button.js +14 -7
- data/lib/webrat/selenium/location_strategy_javascript/label.js +1 -2
- data/lib/webrat/selenium/location_strategy_javascript/webratlink.js +4 -1
- data/lib/webrat/selenium/selenium_rc_server.rb +3 -1
- data/lib/webrat/selenium/selenium_session.rb +1 -1
- data/lib/webrat/selenium/silence_stream.rb +12 -8
- data/lib/webrat/selenium.rb +1 -7
- data/spec/integration/rails/app/controllers/buttons_controller.rb +7 -0
- data/spec/integration/rails/app/controllers/fields_controller.rb +4 -0
- data/spec/integration/rails/app/controllers/links_controller.rb +7 -0
- data/spec/integration/rails/app/controllers/webrat_controller.rb +9 -9
- data/spec/integration/rails/app/helpers/buttons_helper.rb +2 -0
- data/spec/integration/rails/app/helpers/fields_helper.rb +2 -0
- data/spec/integration/rails/app/helpers/links_helper.rb +2 -0
- data/spec/integration/rails/config/routes.rb +3 -0
- data/spec/integration/rails/test/integration/button_click_test.rb +80 -0
- data/spec/integration/rails/test/integration/fill_in_test.rb +24 -0
- data/spec/integration/rails/test/integration/link_click_test.rb +21 -0
- data/spec/integration/rails/test/integration/webrat_test.rb +12 -18
- data/spec/private/core/configuration_spec.rb +9 -0
- data/spec/private/core/field_spec.rb +16 -0
- data/spec/public/matchers/have_selector_spec.rb +9 -2
- data/spec/public/matchers/have_xpath_spec.rb +13 -0
- metadata +11 -2
data/History.txt
CHANGED
|
@@ -11,6 +11,13 @@
|
|
|
11
11
|
* Filled in tests on click link lh 195 (diabolo)
|
|
12
12
|
* Added current_url to selenium session lh 215 (Luke Amdor)
|
|
13
13
|
* Added silence spec to selenium lh 238 (Martin Gamsjaeger aka snusnu)
|
|
14
|
+
* Added ability to configure the browser startup timeout for selenium lh 242 (Mike Gaffney, Mark Dodwell)
|
|
15
|
+
* Added delegation for field_named lh194 (pivotal labs)
|
|
16
|
+
* Added fix to keep from escaping field values in mechanize mode lh256 (jish)
|
|
17
|
+
* Adding fixes for click button/link and made the integration specs pass for the same in selenium lh254 (Ldiehl, Matthias Marschall)
|
|
18
|
+
* Adding clicking link by id in selenium mode lh221 (larrytheliquid)
|
|
19
|
+
* Adding fix for have_selector and have_xpath in descendent blocks lh234 (Thomas Jack)
|
|
20
|
+
* Adding fix for fields with labels with special characters (Thomas Jack, Mike Gaffney, Bryan Hemlkamp)
|
|
14
21
|
|
|
15
22
|
== 0.4.4 / 2009-04-06
|
|
16
23
|
|
|
@@ -53,6 +53,9 @@ module Webrat
|
|
|
53
53
|
|
|
54
54
|
# Set the key that Selenium uses to determine the browser running. Default *firefox
|
|
55
55
|
attr_accessor :selenium_browser_key
|
|
56
|
+
|
|
57
|
+
# Set the timeout for waiting for the browser process to start
|
|
58
|
+
attr_accessor :selenium_browser_startup_timeout
|
|
56
59
|
|
|
57
60
|
# How many redirects to the same URL should be halted as an infinite redirect
|
|
58
61
|
# loop? Defaults to 10
|
|
@@ -68,6 +71,7 @@ module Webrat
|
|
|
68
71
|
self.selenium_server_port = 4444
|
|
69
72
|
self.infinite_redirect_limit = 10
|
|
70
73
|
self.selenium_browser_key = '*firefox'
|
|
74
|
+
self.selenium_browser_startup_timeout = 5
|
|
71
75
|
end
|
|
72
76
|
|
|
73
77
|
def parse_with_nokogiri? #:nodoc:
|
|
@@ -32,7 +32,7 @@ module Webrat
|
|
|
32
32
|
|
|
33
33
|
def rexml_matches(stringlike)
|
|
34
34
|
if REXML::Node === stringlike || Array === stringlike
|
|
35
|
-
@query = query.map { |q| q.gsub(%r'
|
|
35
|
+
@query = query.map { |q| q.gsub(%r'^//', './/') }
|
|
36
36
|
else
|
|
37
37
|
@query = query
|
|
38
38
|
end
|
|
@@ -52,7 +52,7 @@ module Webrat
|
|
|
52
52
|
|
|
53
53
|
def nokogiri_matches(stringlike)
|
|
54
54
|
if Nokogiri::XML::NodeSet === stringlike
|
|
55
|
-
@query = query.gsub(%r'
|
|
55
|
+
@query = query.gsub(%r'^//', './/')
|
|
56
56
|
else
|
|
57
57
|
@query = query
|
|
58
58
|
end
|
data/lib/webrat/core/methods.rb
CHANGED
data/lib/webrat/core/session.rb
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
if (locator == '*') {
|
|
2
2
|
return selenium.browserbot.locationStrategies['xpath'].call(this, "//input[@type='submit']", inDocument, inWindow)
|
|
3
3
|
}
|
|
4
|
+
var buttons = inDocument.getElementsByTagName('button');
|
|
4
5
|
var inputs = inDocument.getElementsByTagName('input');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
var result = $A(inputs).concat($A(buttons)).find(function(candidate){
|
|
7
|
+
var type = candidate.getAttribute('type');
|
|
8
|
+
if (type == 'submit' || type == 'image' || type == 'button') {
|
|
9
|
+
var matches_id = PatternMatcher.matches(locator, candidate.id);
|
|
10
|
+
var matches_value = PatternMatcher.matches(locator, candidate.value);
|
|
11
|
+
var matches_html = PatternMatcher.matches(locator, candidate.innerHTML);
|
|
12
|
+
var matches_alt = PatternMatcher.matches(locator, candidate.alt);
|
|
13
|
+
if (matches_id || matches_value || matches_html || matches_alt) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
12
18
|
});
|
|
19
|
+
return result;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
var allLabels = inDocument.getElementsByTagName("label");
|
|
2
2
|
var candidateLabels = $A(allLabels).select(function(candidateLabel){
|
|
3
|
-
var regExp = new RegExp('^' + locator + '\\b', 'i');
|
|
4
3
|
var labelText = getText(candidateLabel).strip();
|
|
5
|
-
return
|
|
4
|
+
return labelText.toLowerCase() == locator.toLowerCase();
|
|
6
5
|
});
|
|
7
6
|
if (candidateLabels.length == 0) {
|
|
8
7
|
return null;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
var links = inDocument.getElementsByTagName('a');
|
|
2
2
|
var candidateLinks = $A(links).select(function(candidateLink) {
|
|
3
|
-
|
|
3
|
+
var textMatched = PatternMatcher.matches(locator, getText(candidateLink));
|
|
4
|
+
var idMatched = PatternMatcher.matches(locator, candidateLink.id);
|
|
5
|
+
var titleMatched = PatternMatcher.matches(locator, candidateLink.title);
|
|
6
|
+
return textMatched || idMatched || titleMatched;
|
|
4
7
|
});
|
|
5
8
|
if (candidateLinks.length == 0) {
|
|
6
9
|
return null;
|
|
@@ -32,7 +32,9 @@ module Webrat
|
|
|
32
32
|
def remote_control
|
|
33
33
|
return @remote_control if @remote_control
|
|
34
34
|
|
|
35
|
-
@remote_control = ::Selenium::RemoteControl::RemoteControl.new("0.0.0.0",
|
|
35
|
+
@remote_control = ::Selenium::RemoteControl::RemoteControl.new("0.0.0.0",
|
|
36
|
+
Webrat.configuration.selenium_server_port,
|
|
37
|
+
Webrat.configuration.selenium_browser_startup_timeout)
|
|
36
38
|
@remote_control.jar_file = jar_path
|
|
37
39
|
|
|
38
40
|
return @remote_control
|
|
@@ -41,7 +41,7 @@ module Webrat
|
|
|
41
41
|
webrat_deprecate :visits, :visit
|
|
42
42
|
|
|
43
43
|
def fill_in(field_identifier, options)
|
|
44
|
-
locator = "webrat=#{
|
|
44
|
+
locator = "webrat=#{field_identifier}"
|
|
45
45
|
selenium.wait_for_element locator, :timeout_in_seconds => 5
|
|
46
46
|
selenium.type(locator, "#{options[:with]}")
|
|
47
47
|
end
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
module Webrat
|
|
2
2
|
module Selenium
|
|
3
3
|
module SilenceStream
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
stream
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
# active_support already defines silence_stream, no need to do that again if it's already present.
|
|
5
|
+
# http://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/kernel/reporting.rb
|
|
6
|
+
unless Kernel.respond_to?(:silence_stream)
|
|
7
|
+
def silence_stream(stream)
|
|
8
|
+
old_stream = stream.dup
|
|
9
|
+
stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
|
|
10
|
+
stream.sync = true
|
|
11
|
+
yield
|
|
12
|
+
ensure
|
|
13
|
+
stream.reopen(old_stream)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
12
16
|
end
|
|
13
17
|
end
|
|
14
18
|
end
|
data/lib/webrat/selenium.rb
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
require "webrat"
|
|
2
2
|
gem "selenium-client", ">=1.2.14"
|
|
3
3
|
require "selenium/client"
|
|
4
|
-
|
|
5
|
-
# active_support already defines silence_stream, no need to do that again if it's already present.
|
|
6
|
-
# http://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/kernel/reporting.rb
|
|
7
|
-
unless Kernel.respond_to?(:silence_stream)
|
|
8
|
-
require "webrat/selenium/silence_stream"
|
|
9
|
-
end
|
|
10
|
-
|
|
4
|
+
require "webrat/selenium/silence_stream"
|
|
11
5
|
require "webrat/selenium/selenium_session"
|
|
12
6
|
require "webrat/selenium/matchers"
|
|
13
7
|
require "webrat/core_extensions/tcp_socket"
|
|
@@ -5,35 +5,35 @@ class FakeModel
|
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
class WebratController < ApplicationController
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
def form
|
|
10
10
|
end
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
def submit
|
|
13
13
|
render :text => "OK <a href='/' id='link_id'>Test Link Text</a>"
|
|
14
14
|
end
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
def internal_redirect
|
|
17
17
|
redirect_to submit_path
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
def infinite_redirect
|
|
21
21
|
redirect_to infinite_redirect_path
|
|
22
22
|
end
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
def external_redirect
|
|
25
25
|
redirect_to "http://google.com"
|
|
26
26
|
end
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
def before_redirect_form
|
|
29
29
|
end
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
def redirect_to_show_params
|
|
32
32
|
redirect_to show_params_path(:custom_param => "123")
|
|
33
33
|
end
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
def show_params
|
|
36
36
|
render :text => params.to_json
|
|
37
37
|
end
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
end
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
ActionController::Routing::Routes.draw do |map|
|
|
2
|
+
map.resource 'links', :only => [:show]
|
|
3
|
+
map.resource 'buttons', :only => [:show, :create]
|
|
4
|
+
map.resource 'fields', :only => [:show]
|
|
2
5
|
map.with_options :controller => "webrat" do |webrat|
|
|
3
6
|
webrat.submit "/submit", :action => "submit"
|
|
4
7
|
webrat.internal_redirect "/internal_redirect", :action => "internal_redirect"
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class ButtonClickTest < ActionController::IntegrationTest
|
|
4
|
+
# <button type="button" ...>
|
|
5
|
+
test "should click button with type button by id" do
|
|
6
|
+
visit buttons_path
|
|
7
|
+
click_button "button_button_id"
|
|
8
|
+
end
|
|
9
|
+
test "should click button with type button by value" do
|
|
10
|
+
visit buttons_path
|
|
11
|
+
click_button "button_button_value"
|
|
12
|
+
end
|
|
13
|
+
test "should click button with type button by html" do
|
|
14
|
+
visit buttons_path
|
|
15
|
+
click_button "button_button_text"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# <button type="submit" ...>
|
|
19
|
+
test "should click button with type submit by id" do
|
|
20
|
+
visit buttons_path
|
|
21
|
+
click_button "button_submit_id"
|
|
22
|
+
end
|
|
23
|
+
test "should click button with type submit by value" do
|
|
24
|
+
visit buttons_path
|
|
25
|
+
click_button "button_submit_value"
|
|
26
|
+
end
|
|
27
|
+
test "should click button with type submit by html" do
|
|
28
|
+
visit buttons_path
|
|
29
|
+
click_button "button_submit_text"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# <button type="image" ...>
|
|
33
|
+
test "should click button with type image by id" do
|
|
34
|
+
visit buttons_path
|
|
35
|
+
click_button "button_image_id"
|
|
36
|
+
end
|
|
37
|
+
test "should click button with type image by value" do
|
|
38
|
+
visit buttons_path
|
|
39
|
+
click_button "button_image_value"
|
|
40
|
+
end
|
|
41
|
+
test "should click button with type image by html" do
|
|
42
|
+
visit buttons_path
|
|
43
|
+
click_button "button_image_text"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# <input type="button" ...>
|
|
47
|
+
test "should click image with type button by id" do
|
|
48
|
+
visit buttons_path
|
|
49
|
+
click_button "input_button_id"
|
|
50
|
+
end
|
|
51
|
+
test "should click input with type button by value" do
|
|
52
|
+
visit buttons_path
|
|
53
|
+
click_button "input_button_value"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# <input type="submit" ...>
|
|
57
|
+
test "should click input with type submit by id" do
|
|
58
|
+
visit buttons_path
|
|
59
|
+
click_button "input_submit_id"
|
|
60
|
+
end
|
|
61
|
+
test "should click input with type submit by value" do
|
|
62
|
+
visit buttons_path
|
|
63
|
+
click_button "input_submit_value"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# <input type="image" ...>
|
|
67
|
+
test "should click input with type image by id" do
|
|
68
|
+
visit buttons_path
|
|
69
|
+
click_button "input_image_id"
|
|
70
|
+
end
|
|
71
|
+
test "should click input with type image by value" do
|
|
72
|
+
visit buttons_path
|
|
73
|
+
click_button "input_image_value"
|
|
74
|
+
end
|
|
75
|
+
test "should click input with type image by alt" do
|
|
76
|
+
visit buttons_path
|
|
77
|
+
click_button "input_image_alt"
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class FillInTest < ActionController::IntegrationTest
|
|
4
|
+
test "should fill in text field by name" do
|
|
5
|
+
visit fields_path
|
|
6
|
+
fill_in "field_by_name", :with => "value"
|
|
7
|
+
end
|
|
8
|
+
test "should fill in text field by name, rails naming lh257" do
|
|
9
|
+
visit fields_path
|
|
10
|
+
fill_in "rails[naming]", :with => "value"
|
|
11
|
+
end
|
|
12
|
+
test "should fill in text field by id" do
|
|
13
|
+
visit fields_path
|
|
14
|
+
fill_in "field_by_id", :with => "value"
|
|
15
|
+
end
|
|
16
|
+
test "should fill in text field by label via id" do
|
|
17
|
+
visit fields_path
|
|
18
|
+
fill_in "FieldByLabelId", :with => "value"
|
|
19
|
+
end
|
|
20
|
+
test "should fill in text field by label with special characters" do
|
|
21
|
+
visit fields_path
|
|
22
|
+
fill_in "[Field]:", :with => "value"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class LinkClickTest < ActionController::IntegrationTest
|
|
4
|
+
test "should click link by text" do
|
|
5
|
+
visit links_path
|
|
6
|
+
click_link "LinkByText"
|
|
7
|
+
assert_contain("Link:LinkByText")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
test "should click link by id" do
|
|
11
|
+
visit links_path
|
|
12
|
+
click_link "link_by_id"
|
|
13
|
+
assert_contain("Link:link_by_id")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
test "should click link by title" do
|
|
17
|
+
visit links_path
|
|
18
|
+
click_link "LinkByTitle"
|
|
19
|
+
assert_contain("Link:LinkByTitle")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -2,9 +2,12 @@ require 'test_helper'
|
|
|
2
2
|
|
|
3
3
|
class WebratTest < ActionController::IntegrationTest
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
#Firefox raises a security concern under Selenium
|
|
6
|
+
unless ENV['WEBRAT_INTEGRATION_MODE'] == 'selenium'
|
|
7
|
+
test "should visit fully qualified urls" do
|
|
8
|
+
visit root_url(:host => "chunkybacon.example.com")
|
|
9
|
+
assert_equal "chunkybacon", request.subdomains.first
|
|
10
|
+
end
|
|
8
11
|
end
|
|
9
12
|
|
|
10
13
|
test "should visit pages" do
|
|
@@ -46,18 +49,6 @@ class WebratTest < ActionController::IntegrationTest
|
|
|
46
49
|
assert response.redirect?
|
|
47
50
|
end
|
|
48
51
|
|
|
49
|
-
test "should click link by text" do
|
|
50
|
-
visit internal_redirect_path
|
|
51
|
-
click_link "Test Link Text"
|
|
52
|
-
assert_contain("Webrat Form")
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
test "should click link by id" do
|
|
56
|
-
visit internal_redirect_path
|
|
57
|
-
click_link "link_id"
|
|
58
|
-
assert_contain("Webrat Form")
|
|
59
|
-
end
|
|
60
|
-
|
|
61
52
|
test "should be able to assert xpath" do
|
|
62
53
|
visit root_path
|
|
63
54
|
assert_have_xpath "//h1"
|
|
@@ -68,9 +59,12 @@ class WebratTest < ActionController::IntegrationTest
|
|
|
68
59
|
assert_have_selector "h1"
|
|
69
60
|
end
|
|
70
61
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
62
|
+
# Firefox detects and prevents infinite redirects under Selenium
|
|
63
|
+
unless ENV['WEBRAT_INTEGRATION_MODE'] == 'selenium'
|
|
64
|
+
test "should detect infinite redirects" do
|
|
65
|
+
assert_raises Webrat::InfiniteRedirectError do
|
|
66
|
+
visit infinite_redirect_path
|
|
67
|
+
end
|
|
74
68
|
end
|
|
75
69
|
end
|
|
76
70
|
|
|
@@ -92,6 +92,15 @@ describe Webrat::Configuration do
|
|
|
92
92
|
it 'should default selenium browser key to *firefox' do
|
|
93
93
|
@config.selenium_browser_key.should == '*firefox'
|
|
94
94
|
end
|
|
95
|
+
|
|
96
|
+
it 'should default selenium browser startup timeout to 5 seconds' do
|
|
97
|
+
@config.selenium_browser_startup_timeout.should == 5
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it 'should allow overriding of the browser startup timeout' do
|
|
101
|
+
@config.selenium_browser_startup_timeout = 10
|
|
102
|
+
@config.selenium_browser_startup_timeout.should == 10
|
|
103
|
+
end
|
|
95
104
|
end
|
|
96
105
|
|
|
97
106
|
end
|
|
@@ -66,4 +66,20 @@ module Webrat
|
|
|
66
66
|
radio_button.should_not be_checked
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
|
+
|
|
70
|
+
describe TextField do
|
|
71
|
+
it 'should not escape values in mechanize mode' do
|
|
72
|
+
Webrat.configuration.mode = :mechanize
|
|
73
|
+
|
|
74
|
+
html = <<-HTML
|
|
75
|
+
<html>
|
|
76
|
+
<input type="text" name="email" value="user@example.com" />
|
|
77
|
+
</html>
|
|
78
|
+
HTML
|
|
79
|
+
|
|
80
|
+
element = Webrat::XML.css_search(Webrat::XML.document(html), 'input').first
|
|
81
|
+
text_field = TextField.new(nil, element)
|
|
82
|
+
text_field.to_param.should == { 'email' => 'user@example.com' }
|
|
83
|
+
end
|
|
84
|
+
end
|
|
69
85
|
end
|
|
@@ -13,6 +13,7 @@ describe "have_selector" do
|
|
|
13
13
|
<ul>
|
|
14
14
|
<li>First</li>
|
|
15
15
|
<li>Second</li>
|
|
16
|
+
<li><a href="http://example.org/">Third</a></li>
|
|
16
17
|
</ul>
|
|
17
18
|
</div>
|
|
18
19
|
HTML
|
|
@@ -52,12 +53,12 @@ describe "have_selector" do
|
|
|
52
53
|
|
|
53
54
|
describe "specifying counts" do
|
|
54
55
|
it "should be able to specify the number of occurences of the tag" do
|
|
55
|
-
@body.should have_selector("li", :count =>
|
|
56
|
+
@body.should have_selector("li", :count => 3)
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
it "should not match if the count is wrong" do
|
|
59
60
|
lambda {
|
|
60
|
-
@body.should have_selector("li", :count =>
|
|
61
|
+
@body.should have_selector("li", :count => 4)
|
|
61
62
|
}.should raise_error(Spec::Expectations::ExpectationNotMetError)
|
|
62
63
|
end
|
|
63
64
|
end
|
|
@@ -97,6 +98,12 @@ describe "have_selector" do
|
|
|
97
98
|
n.should have_selector("li", :content => "Second")
|
|
98
99
|
end
|
|
99
100
|
end
|
|
101
|
+
|
|
102
|
+
it "should work with descendants of the matched elements" do
|
|
103
|
+
@body.should have_selector("ul") do |n|
|
|
104
|
+
n.should have_selector("a", :content => "Third")
|
|
105
|
+
end
|
|
106
|
+
end
|
|
100
107
|
end
|
|
101
108
|
|
|
102
109
|
describe "Test::Unit assertions" do
|
|
@@ -13,6 +13,7 @@ describe "have_xpath" do
|
|
|
13
13
|
<ul>
|
|
14
14
|
<li>First</li>
|
|
15
15
|
<li>Second</li>
|
|
16
|
+
<li><a href="http://example.org">Third</a></li>
|
|
16
17
|
</ul>
|
|
17
18
|
</div>
|
|
18
19
|
HTML
|
|
@@ -88,6 +89,18 @@ describe "have_xpath" do
|
|
|
88
89
|
}.should raise_error(Spec::Expectations::ExpectationNotMetError)
|
|
89
90
|
end
|
|
90
91
|
|
|
92
|
+
it "should match descendants of the matched elements in the block" do
|
|
93
|
+
@body.should have_xpath("//ul") do |node|
|
|
94
|
+
node.should have_xpath("//a[@href='http://example.org']")
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "should allow descendant selectors in the block" do
|
|
99
|
+
@body.should have_xpath("//div[@id='main']") do |node|
|
|
100
|
+
node.should have_xpath("//ul//a")
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
91
104
|
describe 'asserts for xpath' do
|
|
92
105
|
include Test::Unit::Assertions
|
|
93
106
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: diabolo-webrat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.4.
|
|
4
|
+
version: 0.4.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bryan Helmkamp
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-06-03 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -157,7 +157,13 @@ test_files:
|
|
|
157
157
|
- spec/integration/rack/test/test_helper.rb
|
|
158
158
|
- spec/integration/rack/test/webrat_rack_test.rb
|
|
159
159
|
- spec/integration/rails/app/controllers/application.rb
|
|
160
|
+
- spec/integration/rails/app/controllers/buttons_controller.rb
|
|
161
|
+
- spec/integration/rails/app/controllers/fields_controller.rb
|
|
162
|
+
- spec/integration/rails/app/controllers/links_controller.rb
|
|
160
163
|
- spec/integration/rails/app/controllers/webrat_controller.rb
|
|
164
|
+
- spec/integration/rails/app/helpers/buttons_helper.rb
|
|
165
|
+
- spec/integration/rails/app/helpers/fields_helper.rb
|
|
166
|
+
- spec/integration/rails/app/helpers/links_helper.rb
|
|
161
167
|
- spec/integration/rails/config/boot.rb
|
|
162
168
|
- spec/integration/rails/config/environment.rb
|
|
163
169
|
- spec/integration/rails/config/environments/development.rb
|
|
@@ -167,6 +173,9 @@ test_files:
|
|
|
167
173
|
- spec/integration/rails/config/initializers/mime_types.rb
|
|
168
174
|
- spec/integration/rails/config/initializers/new_rails_defaults.rb
|
|
169
175
|
- spec/integration/rails/config/routes.rb
|
|
176
|
+
- spec/integration/rails/test/integration/button_click_test.rb
|
|
177
|
+
- spec/integration/rails/test/integration/fill_in_test.rb
|
|
178
|
+
- spec/integration/rails/test/integration/link_click_test.rb
|
|
170
179
|
- spec/integration/rails/test/integration/webrat_test.rb
|
|
171
180
|
- spec/integration/rails/test/test_helper.rb
|
|
172
181
|
- spec/integration/sinatra/classic_app.rb
|