diabolo-webrat 0.4.4.2 → 0.5.1
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/.document +4 -0
- data/.gitignore +15 -0
- data/History.txt +60 -9
- data/Rakefile +90 -75
- data/VERSION +1 -0
- data/lib/webrat.rb +8 -23
- data/lib/webrat/{mechanize.rb → adapters/mechanize.rb} +6 -2
- data/lib/webrat/adapters/merb.rb +11 -0
- data/lib/webrat/adapters/rack.rb +25 -0
- data/lib/webrat/{rails.rb → adapters/rails.rb} +9 -18
- data/lib/webrat/adapters/sinatra.rb +9 -0
- data/lib/webrat/core.rb +0 -1
- data/lib/webrat/core/configuration.rb +7 -17
- data/lib/webrat/core/elements/area.rb +2 -2
- data/lib/webrat/core/elements/element.rb +3 -3
- data/lib/webrat/core/elements/field.rb +33 -30
- data/lib/webrat/core/elements/form.rb +4 -4
- data/lib/webrat/core/elements/label.rb +4 -4
- data/lib/webrat/core/elements/link.rb +7 -6
- data/lib/webrat/core/elements/select_option.rb +2 -2
- data/lib/webrat/core/locators.rb +1 -1
- data/lib/webrat/core/locators/area_locator.rb +3 -3
- data/lib/webrat/core/locators/button_locator.rb +6 -6
- data/lib/webrat/core/locators/field_by_id_locator.rb +3 -3
- data/lib/webrat/core/locators/field_labeled_locator.rb +2 -2
- data/lib/webrat/core/locators/field_named_locator.rb +3 -3
- data/lib/webrat/core/locators/form_locator.rb +1 -1
- data/lib/webrat/core/locators/label_locator.rb +2 -2
- data/lib/webrat/core/locators/link_locator.rb +20 -12
- data/lib/webrat/core/locators/select_option_locator.rb +5 -5
- data/lib/webrat/core/logging.rb +1 -1
- data/lib/webrat/core/matchers/have_content.rb +2 -7
- data/lib/webrat/core/matchers/have_xpath.rb +2 -27
- data/lib/webrat/core/methods.rb +4 -4
- data/lib/webrat/core/mime.rb +11 -22
- data/lib/webrat/core/save_and_open_page.rb +5 -7
- data/lib/webrat/core/scope.rb +2 -2
- data/lib/webrat/core/session.rb +30 -14
- data/lib/webrat/core/xml.rb +41 -84
- data/lib/webrat/integrations/merb.rb +10 -0
- data/lib/webrat/integrations/rails.rb +9 -0
- data/lib/webrat/integrations/rspec-rails.rb +10 -0
- data/lib/webrat/integrations/selenium.rb +11 -0
- data/lib/webrat/rspec-rails.rb +2 -13
- data/lib/webrat/selenium.rb +0 -11
- data/lib/webrat/selenium/application_server_factory.rb +40 -0
- data/lib/webrat/selenium/application_servers.rb +5 -0
- data/lib/webrat/selenium/application_servers/base.rb +46 -0
- data/lib/webrat/selenium/application_servers/external.rb +26 -0
- data/lib/webrat/selenium/application_servers/merb.rb +50 -0
- data/lib/webrat/selenium/application_servers/rails.rb +44 -0
- data/lib/webrat/selenium/application_servers/sinatra.rb +37 -0
- data/lib/webrat/selenium/location_strategy_javascript/label.js +2 -1
- data/lib/webrat/selenium/selenium_rc_server.rb +7 -5
- data/lib/webrat/selenium/selenium_session.rb +20 -7
- data/lib/webrat/selenium/silence_stream.rb +1 -1
- data/spec/fakes/{test_session.rb → test_adapter.rb} +6 -3
- data/spec/integration/mechanize/Rakefile +7 -0
- data/spec/integration/mechanize/config.ru +2 -0
- data/spec/integration/mechanize/sample_app.rb +20 -0
- data/spec/integration/mechanize/spec/mechanize_spec.rb +22 -0
- data/spec/integration/mechanize/spec/spec_helper.rb +27 -0
- data/spec/integration/merb/.gitignore +21 -0
- data/spec/integration/merb/Rakefile +35 -0
- data/spec/integration/merb/app/controllers/testing.rb +9 -0
- data/spec/integration/merb/app/views/exceptions/not_acceptable.html.erb +63 -0
- data/spec/integration/merb/app/views/exceptions/not_found.html.erb +47 -0
- data/spec/integration/merb/app/views/layout/application.html.erb +12 -0
- data/spec/integration/merb/app/views/testing/show_form.html.erb +27 -0
- data/spec/integration/merb/app/views/testing/upload.html.erb +9 -0
- data/spec/integration/merb/config/router.rb +1 -0
- data/spec/integration/merb/spec/spec.opts +1 -0
- data/spec/integration/merb/spec/spec_helper.rb +2 -0
- data/spec/integration/merb/spec/webrat_spec.rb +7 -0
- data/spec/integration/merb/tasks/merb.thor/main.thor +150 -0
- data/spec/integration/rack/Rakefile +5 -0
- data/spec/integration/rack/app.rb +89 -0
- data/spec/integration/rack/test/helper.rb +21 -0
- data/spec/integration/rack/test/webrat_rack_test.rb +57 -51
- data/spec/integration/rails/.gitignore +3 -0
- data/spec/integration/rails/Rakefile +30 -0
- data/spec/integration/rails/app/controllers/webrat_controller.rb +13 -9
- data/spec/integration/rails/app/views/buttons/show.html.erb +11 -0
- data/spec/integration/rails/app/views/fields/show.html.erb +9 -0
- data/spec/integration/rails/app/views/links/show.html.erb +5 -0
- data/spec/integration/rails/app/views/webrat/before_redirect_form.html.erb +4 -0
- data/spec/integration/rails/app/views/webrat/buttons.html.erb +11 -0
- data/spec/integration/rails/app/views/webrat/form.html.erb +28 -0
- data/spec/integration/rails/config/locales/en.yml +5 -0
- data/spec/integration/rails/config/routes.rb +1 -0
- data/spec/integration/rails/public/404.html +30 -0
- data/spec/integration/rails/public/422.html +30 -0
- data/spec/integration/rails/public/500.html +33 -0
- data/spec/integration/rails/script/about +4 -0
- data/spec/integration/rails/script/console +3 -0
- data/spec/integration/rails/script/dbconsole +3 -0
- data/spec/integration/rails/script/destroy +3 -0
- data/spec/integration/rails/script/generate +3 -0
- data/spec/integration/rails/script/performance/benchmarker +3 -0
- data/spec/integration/rails/script/performance/profiler +3 -0
- data/spec/integration/rails/script/performance/request +3 -0
- data/spec/integration/rails/script/plugin +3 -0
- data/spec/integration/rails/script/process/inspector +3 -0
- data/spec/integration/rails/script/process/reaper +3 -0
- data/spec/integration/rails/script/process/spawner +3 -0
- data/spec/integration/rails/script/runner +3 -0
- data/spec/integration/rails/script/server +3 -0
- data/spec/integration/rails/test/integration/button_click_test.rb +2 -2
- data/spec/integration/rails/test/integration/link_click_test.rb +7 -1
- data/spec/integration/rails/test/integration/webrat_test.rb +22 -0
- data/spec/integration/rails/test/test_helper.rb +6 -5
- data/spec/integration/sinatra/Rakefile +5 -0
- data/spec/integration/sinatra/test/test_helper.rb +3 -2
- data/spec/private/core/configuration_spec.rb +8 -27
- data/spec/private/core/field_spec.rb +7 -7
- data/spec/private/core/link_spec.rb +1 -1
- data/spec/private/core/session_spec.rb +23 -21
- data/spec/private/mechanize/{mechanize_session_spec.rb → mechanize_adapter_spec.rb} +4 -12
- data/spec/private/nokogiri_spec.rb +2 -2
- data/spec/private/rails/{rails_session_spec.rb → rails_adapter_spec.rb} +16 -16
- data/spec/private/selenium/application_servers/rails_spec.rb +26 -0
- data/spec/public/matchers/contain_spec.rb +4 -4
- data/spec/public/matchers/have_selector_spec.rb +2 -2
- data/spec/public/matchers/have_xpath_spec.rb +3 -3
- data/spec/public/save_and_open_spec.rb +25 -6
- data/spec/public/selenium/application_server_factory_spec.rb +49 -0
- data/spec/public/selenium/application_servers/external_spec.rb +12 -0
- data/spec/public/selenium/selenium_session_spec.rb +37 -0
- data/spec/rcov.opts +1 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +5 -1
- data/vendor/selenium-server.jar +0 -0
- data/webrat.gemspec +348 -0
- metadata +176 -23
- data/lib/webrat/core/xml/hpricot.rb +0 -19
- data/lib/webrat/core/xml/nokogiri.rb +0 -76
- data/lib/webrat/core/xml/rexml.rb +0 -24
- data/lib/webrat/merb_session.rb +0 -65
- data/lib/webrat/rack.rb +0 -24
- data/lib/webrat/rack_test.rb +0 -32
- data/lib/webrat/selenium/application_server.rb +0 -73
- data/lib/webrat/selenium/merb_application_server.rb +0 -48
- data/lib/webrat/selenium/rails_application_server.rb +0 -42
- data/lib/webrat/selenium/sinatra_application_server.rb +0 -35
- data/lib/webrat/sinatra.rb +0 -44
- data/spec/integration/rack/rack_app.rb +0 -16
- data/spec/integration/rack/test/test_helper.rb +0 -20
- data/spec/private/merb/merb_session_spec.rb +0 -42
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
require "rubygems"
|
|
2
2
|
require "test/unit"
|
|
3
|
-
require "redgreen"
|
|
3
|
+
# require "redgreen"
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../../../../lib"
|
|
6
|
+
require "webrat"
|
|
6
7
|
|
|
7
8
|
Webrat.configure do |config|
|
|
8
9
|
config.mode = :sinatra
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
2
2
|
|
|
3
3
|
describe Webrat::Configuration do
|
|
4
|
-
predicate_matchers[:parse_with_nokogiri] = :parse_with_nokogiri?
|
|
5
|
-
predicate_matchers[:open_error_files] = :open_error_files?
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Spec::Matchers.define :open_error_files do
|
|
6
|
+
match do |config|
|
|
7
|
+
config.open_error_files?
|
|
8
|
+
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
it "should
|
|
12
|
-
|
|
13
|
-
config.should parse_with_nokogiri
|
|
11
|
+
it "should have a mode" do
|
|
12
|
+
Webrat.configuration.should respond_to(:mode)
|
|
14
13
|
end
|
|
15
14
|
|
|
16
15
|
it "should open error files by default" do
|
|
@@ -46,24 +45,6 @@ describe Webrat::Configuration do
|
|
|
46
45
|
config.selenium_server_port.should == 1234
|
|
47
46
|
end
|
|
48
47
|
|
|
49
|
-
[:rails,
|
|
50
|
-
:selenium,
|
|
51
|
-
:rack,
|
|
52
|
-
:sinatra,
|
|
53
|
-
:mechanize].each do |mode|
|
|
54
|
-
it "should require correct lib when in #{mode} mode" do
|
|
55
|
-
config = Webrat::Configuration.new
|
|
56
|
-
config.should_receive(:require).with("webrat/#{mode}")
|
|
57
|
-
config.mode = mode
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it "should require merb_session when in merb mode" do
|
|
62
|
-
config = Webrat::Configuration.new
|
|
63
|
-
config.should_receive(:require).with("webrat/merb_session")
|
|
64
|
-
config.mode = :merb
|
|
65
|
-
end
|
|
66
|
-
|
|
67
48
|
describe "Selenium" do
|
|
68
49
|
before :each do
|
|
69
50
|
@config = Webrat::Configuration.new
|
|
@@ -92,11 +73,11 @@ describe Webrat::Configuration do
|
|
|
92
73
|
it 'should default selenium browser key to *firefox' do
|
|
93
74
|
@config.selenium_browser_key.should == '*firefox'
|
|
94
75
|
end
|
|
95
|
-
|
|
76
|
+
|
|
96
77
|
it 'should default selenium browser startup timeout to 5 seconds' do
|
|
97
78
|
@config.selenium_browser_startup_timeout.should == 5
|
|
98
79
|
end
|
|
99
|
-
|
|
80
|
+
|
|
100
81
|
it 'should allow overriding of the browser startup timeout' do
|
|
101
82
|
@config.selenium_browser_startup_timeout = 10
|
|
102
83
|
@config.selenium_browser_startup_timeout.should == 10
|
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
|
|
2
2
|
|
|
3
3
|
module Webrat
|
|
4
4
|
describe Field do
|
|
5
|
-
unless
|
|
5
|
+
unless RUBY_PLATFORM =~ /java/
|
|
6
6
|
it "should have nice inspect output" do
|
|
7
7
|
html = <<-HTML
|
|
8
8
|
<html>
|
|
@@ -10,7 +10,7 @@ module Webrat
|
|
|
10
10
|
</html>
|
|
11
11
|
HTML
|
|
12
12
|
|
|
13
|
-
element = Webrat::XML.
|
|
13
|
+
element = Webrat::XML.document(html).css("input").first
|
|
14
14
|
checkbox = CheckboxField.new(nil, element)
|
|
15
15
|
checkbox.inspect.should =~ /#<Webrat::CheckboxField @element=<input type=['"]checkbox['"] checked(=['"]checked['"])?\/?>>/
|
|
16
16
|
end
|
|
@@ -25,7 +25,7 @@ module Webrat
|
|
|
25
25
|
</html>
|
|
26
26
|
HTML
|
|
27
27
|
|
|
28
|
-
element = Webrat::XML.
|
|
28
|
+
element = Webrat::XML.document(html).css("input").first
|
|
29
29
|
checkbox = CheckboxField.new(nil, element)
|
|
30
30
|
checkbox.should be_checked
|
|
31
31
|
end
|
|
@@ -37,7 +37,7 @@ module Webrat
|
|
|
37
37
|
</html>
|
|
38
38
|
HTML
|
|
39
39
|
|
|
40
|
-
element = Webrat::XML.
|
|
40
|
+
element = Webrat::XML.document(html).css("input").first
|
|
41
41
|
checkbox = CheckboxField.new(nil, element)
|
|
42
42
|
checkbox.should_not be_checked
|
|
43
43
|
end
|
|
@@ -51,7 +51,7 @@ module Webrat
|
|
|
51
51
|
</html>
|
|
52
52
|
HTML
|
|
53
53
|
|
|
54
|
-
element = Webrat::XML.
|
|
54
|
+
element = Webrat::XML.document(html).css("input").first
|
|
55
55
|
radio_button = RadioField.new(nil, element)
|
|
56
56
|
radio_button.should be_checked
|
|
57
57
|
end
|
|
@@ -61,7 +61,7 @@ module Webrat
|
|
|
61
61
|
<html><input type='radio' /></html>
|
|
62
62
|
HTML
|
|
63
63
|
|
|
64
|
-
element = Webrat::XML.
|
|
64
|
+
element = Webrat::XML.document(html).css("input").first
|
|
65
65
|
radio_button = RadioField.new(nil, element)
|
|
66
66
|
radio_button.should_not be_checked
|
|
67
67
|
end
|
|
@@ -77,7 +77,7 @@ module Webrat
|
|
|
77
77
|
</html>
|
|
78
78
|
HTML
|
|
79
79
|
|
|
80
|
-
element = Webrat::XML.
|
|
80
|
+
element = Webrat::XML.document(html).css('input').first
|
|
81
81
|
text_field = TextField.new(nil, element)
|
|
82
82
|
text_field.to_param.should == { 'email' => 'user@example.com' }
|
|
83
83
|
end
|
|
@@ -21,27 +21,6 @@ describe Webrat::Session do
|
|
|
21
21
|
session.should respond_to(:current_dom)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
it "should open the page in the browser in MacOSX" do
|
|
25
|
-
session = Webrat::Session.new
|
|
26
|
-
session.stub!(:ruby_platform => 'darwin')
|
|
27
|
-
session.should_receive(:`).with("open path")
|
|
28
|
-
session.open_in_browser("path")
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "should open the page in the browser in cygwin" do
|
|
32
|
-
session = Webrat::Session.new
|
|
33
|
-
session.stub!(:ruby_platform => 'i386-cygwin')
|
|
34
|
-
session.should_receive(:`).with("rundll32 url.dll,FileProtocolHandler path\\to\\file")
|
|
35
|
-
session.open_in_browser("path/to/file")
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "should open the page in the browser in Win32" do
|
|
39
|
-
session = Webrat::Session.new
|
|
40
|
-
session.stub!(:ruby_platform => 'win32')
|
|
41
|
-
session.should_receive(:`).with("rundll32 url.dll,FileProtocolHandler path\\to\\file")
|
|
42
|
-
session.open_in_browser("path/to/file")
|
|
43
|
-
end
|
|
44
|
-
|
|
45
24
|
it "should provide a current_page for backwards compatibility" do
|
|
46
25
|
session = Webrat::Session.new
|
|
47
26
|
current_page = session.current_page
|
|
@@ -83,6 +62,11 @@ describe Webrat::Session do
|
|
|
83
62
|
it "should raise an error if a symbol Mime type is passed that does not exist" do
|
|
84
63
|
lambda { webrat_session.http_accept(:oogabooga) }.should raise_error(ArgumentError)
|
|
85
64
|
end
|
|
65
|
+
|
|
66
|
+
it "should recognize a couple of webrat-specific formats" do
|
|
67
|
+
webrat_session.http_accept(:multipart_form).should == "multipart/form-data"
|
|
68
|
+
webrat_session.http_accept(:url_encoded_form).should == "application/x-www-form-urlencoded"
|
|
69
|
+
end
|
|
86
70
|
end
|
|
87
71
|
|
|
88
72
|
describe "#request_page" do
|
|
@@ -127,6 +111,24 @@ describe Webrat::Session do
|
|
|
127
111
|
webrat_session = Webrat::Session.new
|
|
128
112
|
end
|
|
129
113
|
|
|
114
|
+
it "should return true if the last response was a redirect and Fixnum#/ returns a Rational" do
|
|
115
|
+
# This happens if the ruby-units gem has been required
|
|
116
|
+
Fixnum.class_eval do
|
|
117
|
+
alias_method :original_divide, "/".to_sym
|
|
118
|
+
|
|
119
|
+
def /(other)
|
|
120
|
+
Rational(self, other)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
webrat_session.stub!(:response_code => 301)
|
|
125
|
+
webrat_session.redirect?.should be_true
|
|
126
|
+
|
|
127
|
+
Fixnum.class_eval do
|
|
128
|
+
alias_method "/".to_sym, :original_divide
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
130
132
|
it "should return true if the last response was a redirect" do
|
|
131
133
|
webrat_session.stub!(:response_code => 301)
|
|
132
134
|
webrat_session.redirect?.should be_true
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
describe Webrat::MechanizeSession do
|
|
3
|
+
describe Webrat::MechanizeAdapter do
|
|
6
4
|
before :each do
|
|
7
5
|
Webrat.configuration.mode = :mechanize
|
|
8
6
|
end
|
|
9
7
|
|
|
10
8
|
before(:each) do
|
|
11
|
-
@mech = Webrat::
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
describe "headers method" do
|
|
15
|
-
it "should return empty headers for a newly initialized session" do
|
|
16
|
-
@mech.headers.should == {}
|
|
17
|
-
end
|
|
9
|
+
@mech = Webrat::MechanizeAdapter.new
|
|
18
10
|
end
|
|
19
11
|
|
|
20
12
|
describe "post" do
|
|
@@ -34,13 +26,13 @@ describe Webrat::MechanizeSession do
|
|
|
34
26
|
mechanize = mock(:mechanize)
|
|
35
27
|
WWW::Mechanize.stub!(:new => mechanize)
|
|
36
28
|
mechanize.should_receive(:post).with(url, flattened_data)
|
|
37
|
-
Webrat::
|
|
29
|
+
Webrat::MechanizeAdapter.new.post(url, data)
|
|
38
30
|
end
|
|
39
31
|
end
|
|
40
32
|
|
|
41
33
|
describe "#absolute_url" do
|
|
42
34
|
before(:each) do
|
|
43
|
-
@session = Webrat::
|
|
35
|
+
@session = Webrat::MechanizeAdapter.new
|
|
44
36
|
@session.stub!(:current_url).and_return(absolute_url)
|
|
45
37
|
end
|
|
46
38
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
|
2
2
|
|
|
3
|
-
if defined?(Nokogiri::XML) && Webrat.configuration.parse_with_nokogiri?
|
|
3
|
+
# if defined?(Nokogiri::XML) && Webrat.configuration.parse_with_nokogiri?
|
|
4
4
|
describe "Nokogiri Extension" do
|
|
5
5
|
include Webrat::Matchers
|
|
6
6
|
|
|
@@ -74,4 +74,4 @@ if defined?(Nokogiri::XML) && Webrat.configuration.parse_with_nokogiri?
|
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
|
-
end
|
|
77
|
+
# end
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
describe Webrat::RailsSession do
|
|
3
|
+
describe Webrat::RailsAdapter do
|
|
6
4
|
before :each do
|
|
7
5
|
Webrat.configuration.mode = :rails
|
|
8
6
|
@integration_session = mock("integration_session")
|
|
@@ -10,35 +8,35 @@ describe Webrat::RailsSession do
|
|
|
10
8
|
|
|
11
9
|
it "should delegate response_body to the session response body" do
|
|
12
10
|
@integration_session.stub!(:response => mock("response", :body => "<html>"))
|
|
13
|
-
Webrat::
|
|
11
|
+
Webrat::RailsAdapter.new(@integration_session).response_body.should == "<html>"
|
|
14
12
|
end
|
|
15
13
|
|
|
16
14
|
it "should delegate response_code to the session response code" do
|
|
17
15
|
@integration_session.stub!(:response => mock("response", :code => "42"))
|
|
18
|
-
Webrat::
|
|
16
|
+
Webrat::RailsAdapter.new(@integration_session).response_code.should == 42
|
|
19
17
|
end
|
|
20
18
|
|
|
21
19
|
it "should delegate get to the integration session" do
|
|
22
20
|
@integration_session.should_receive(:get).with("url", "data", "headers")
|
|
23
|
-
rails_session = Webrat::
|
|
21
|
+
rails_session = Webrat::RailsAdapter.new(@integration_session)
|
|
24
22
|
rails_session.get("url", "data", "headers")
|
|
25
23
|
end
|
|
26
24
|
|
|
27
25
|
it "should delegate post to the integration session" do
|
|
28
26
|
@integration_session.should_receive(:post).with("url", "data", "headers")
|
|
29
|
-
rails_session = Webrat::
|
|
27
|
+
rails_session = Webrat::RailsAdapter.new(@integration_session)
|
|
30
28
|
rails_session.post("url", "data", "headers")
|
|
31
29
|
end
|
|
32
30
|
|
|
33
31
|
it "should delegate put to the integration session" do
|
|
34
32
|
@integration_session.should_receive(:put).with("url", "data", "headers")
|
|
35
|
-
rails_session = Webrat::
|
|
33
|
+
rails_session = Webrat::RailsAdapter.new(@integration_session)
|
|
36
34
|
rails_session.put("url", "data", "headers")
|
|
37
35
|
end
|
|
38
36
|
|
|
39
37
|
it "should delegate delete to the integration session" do
|
|
40
38
|
@integration_session.should_receive(:delete).with("url", "data", "headers")
|
|
41
|
-
rails_session = Webrat::
|
|
39
|
+
rails_session = Webrat::RailsAdapter.new(@integration_session)
|
|
42
40
|
rails_session.delete("url", "data", "headers")
|
|
43
41
|
end
|
|
44
42
|
|
|
@@ -46,7 +44,7 @@ describe Webrat::RailsSession do
|
|
|
46
44
|
it "should pass the full url" do
|
|
47
45
|
@integration_session.stub!(:https!)
|
|
48
46
|
@integration_session.should_receive(:get).with("http://www.example.com/url", "data", "headers")
|
|
49
|
-
rails_session = Webrat::
|
|
47
|
+
rails_session = Webrat::RailsAdapter.new(@integration_session)
|
|
50
48
|
rails_session.get("http://www.example.com/url", "data", "headers")
|
|
51
49
|
end
|
|
52
50
|
end
|
|
@@ -55,7 +53,7 @@ describe Webrat::RailsSession do
|
|
|
55
53
|
it "should call #https! with true before the request before passing along the full url" do
|
|
56
54
|
@integration_session.should_receive(:https!).with(true)
|
|
57
55
|
@integration_session.should_receive(:get).with("https://www.example.com/url", "data", "headers")
|
|
58
|
-
rails_session = Webrat::
|
|
56
|
+
rails_session = Webrat::RailsAdapter.new(@integration_session)
|
|
59
57
|
rails_session.get("https://www.example.com/url", "data", "headers")
|
|
60
58
|
end
|
|
61
59
|
end
|
|
@@ -64,7 +62,7 @@ describe Webrat::RailsSession do
|
|
|
64
62
|
it "should call #https! with true before the request" do
|
|
65
63
|
@integration_session.stub!(:get)
|
|
66
64
|
@integration_session.should_receive(:https!).with(false)
|
|
67
|
-
rails_session = Webrat::
|
|
65
|
+
rails_session = Webrat::RailsAdapter.new(@integration_session)
|
|
68
66
|
rails_session.get("http://www.example.com/url", "data", "headers")
|
|
69
67
|
end
|
|
70
68
|
end
|
|
@@ -73,20 +71,22 @@ describe Webrat::RailsSession do
|
|
|
73
71
|
it "should strip out the anchor" do
|
|
74
72
|
@integration_session.should_receive(:https!).with(false)
|
|
75
73
|
@integration_session.should_receive(:get).with("http://www.example.com/url", "data", "headers")
|
|
76
|
-
rails_session = Webrat::
|
|
74
|
+
rails_session = Webrat::RailsAdapter.new(@integration_session)
|
|
77
75
|
rails_session.get("http://www.example.com/url#foo", "data", "headers")
|
|
78
76
|
end
|
|
79
77
|
end
|
|
80
78
|
|
|
81
79
|
it "should provide a saved_page_dir" do
|
|
82
|
-
Webrat::
|
|
80
|
+
Webrat::RailsAdapter.new(mock("integration session")).should respond_to(:saved_page_dir)
|
|
83
81
|
end
|
|
84
82
|
|
|
85
83
|
it "should provide a doc_root" do
|
|
86
|
-
Webrat::
|
|
84
|
+
Webrat::RailsAdapter.new(mock("integration session")).should respond_to(:doc_root)
|
|
87
85
|
end
|
|
88
86
|
|
|
89
87
|
it "should accept an ActiveRecord argument to #within and translate to a selector using dom_id" do
|
|
88
|
+
pending "Move this to spec/public/within_spec.rb"
|
|
89
|
+
|
|
90
90
|
body = <<-HTML
|
|
91
91
|
<a href="/page1">Edit</a>
|
|
92
92
|
<div id="new_object">
|
|
@@ -98,7 +98,7 @@ describe Webrat::RailsSession do
|
|
|
98
98
|
@integration_session.stub!(:response => response)
|
|
99
99
|
@integration_session.should_receive(:get).with("/page2", {}, nil)
|
|
100
100
|
|
|
101
|
-
rails_session = Webrat::
|
|
101
|
+
rails_session = Webrat::RailsAdapter.new(@integration_session)
|
|
102
102
|
|
|
103
103
|
object = Object.new
|
|
104
104
|
object.stub!(:id => nil)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper")
|
|
2
|
+
require "webrat/selenium/application_servers/rails"
|
|
3
|
+
|
|
4
|
+
RAILS_ROOT = "." unless defined?(RAILS_ROOT)
|
|
5
|
+
|
|
6
|
+
describe Webrat::Selenium::ApplicationServers::Rails do
|
|
7
|
+
include Webrat::Selenium::SilenceStream
|
|
8
|
+
|
|
9
|
+
before do
|
|
10
|
+
@server = Webrat::Selenium::ApplicationServers::Rails.new
|
|
11
|
+
# require "rubygems"; require "ruby-debug"; Debugger.start; debugger
|
|
12
|
+
@server.stub!(:system)
|
|
13
|
+
@server.stub!(:at_exit)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "boot" do
|
|
17
|
+
it "should wait for the server to start on 0.0.0.0" do
|
|
18
|
+
TCPSocket.should_receive(:wait_for_service_with_timeout).
|
|
19
|
+
with(hash_including(:host => "0.0.0.0"))
|
|
20
|
+
|
|
21
|
+
silence_stream(STDERR) do
|
|
22
|
+
@server.boot
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -56,13 +56,13 @@ describe "contain" do
|
|
|
56
56
|
it "should throw an exception when the body doesnt contain the text" do
|
|
57
57
|
lambda {
|
|
58
58
|
assert_contain("monkeys")
|
|
59
|
-
}.should raise_error(
|
|
59
|
+
}.should raise_error(AssertionFailedError)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
it "should throw an exception when the body doesnt contain the regexp" do
|
|
63
63
|
lambda {
|
|
64
64
|
assert_contain(/monkeys/)
|
|
65
|
-
}.should raise_error(
|
|
65
|
+
}.should raise_error(AssertionFailedError)
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
@@ -78,13 +78,13 @@ describe "contain" do
|
|
|
78
78
|
it "should throw an exception when the body does contain the text" do
|
|
79
79
|
lambda {
|
|
80
80
|
assert_not_contain("hello, world")
|
|
81
|
-
}.should raise_error(
|
|
81
|
+
}.should raise_error(AssertionFailedError)
|
|
82
82
|
end
|
|
83
83
|
|
|
84
84
|
it "should throw an exception when the body does contain the regexp" do
|
|
85
85
|
lambda {
|
|
86
86
|
assert_not_contain(/hello, world/)
|
|
87
|
-
}.should raise_error(
|
|
87
|
+
}.should raise_error(AssertionFailedError)
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
end
|
|
@@ -122,7 +122,7 @@ describe "have_selector" do
|
|
|
122
122
|
it "should throw an exception when the body doesnt have matching selection" do
|
|
123
123
|
lambda {
|
|
124
124
|
assert_have_selector("p")
|
|
125
|
-
}.should raise_error(
|
|
125
|
+
}.should raise_error(AssertionFailedError)
|
|
126
126
|
end
|
|
127
127
|
end
|
|
128
128
|
|
|
@@ -134,7 +134,7 @@ describe "have_selector" do
|
|
|
134
134
|
it "should throw an exception when the body does contain the selection" do
|
|
135
135
|
lambda {
|
|
136
136
|
assert_have_no_selector("div")
|
|
137
|
-
}.should raise_error(
|
|
137
|
+
}.should raise_error(AssertionFailedError)
|
|
138
138
|
end
|
|
139
139
|
end
|
|
140
140
|
end
|