Merge branch 'master' of git://github.com/brynary/webrat

This commit is contained in:
Thomas Jack 2009-05-13 14:34:16 -05:00
commit db9c5bdc77
23 changed files with 161 additions and 233 deletions

2
.gitignore vendored
View File

@ -12,4 +12,4 @@ log
results results
test_apps test_apps
*.tmproj *.tmproj
webrat.log *.log

View File

@ -1,4 +1,4 @@
== brynary/master (in git) == 0.4.5 / ?
* Major enhancements * Major enhancements
@ -9,16 +9,15 @@
* Added support for field_labeled_locators ending in non word characters * Added support for field_labeled_locators ending in non word characters
lh 148 (Zach Dennis) lh 148 (Zach Dennis)
* Filled in tests on click link lh 195 (diabolo) * Filled in tests on click link lh 195 (diabolo)
* Canonicalize all URLs (Shalon Wood)
== 0.4.4 / 2009-04-06 == 0.4.4 / 2009-04-06
* Major enhancements * Major enhancements
* Make selenium process management code more robust and informative * Make selenium process management code more robust and informative
* Minor enhancements * Minor enhancements
* Add support for Rails javascript post links (Mark Menard) * Add support for Rails javascript post links (Mark Menard)
* Upgrade selenium-client dependency to 1.2.14, and update for new waiting * Upgrade selenium-client dependency to 1.2.14, and update for new waiting
API (Balint Erdi) API (Balint Erdi)
@ -29,7 +28,7 @@
* Don't create a new instance of WWW::Mechanize for each request * Don't create a new instance of WWW::Mechanize for each request
(Mark Menard) (Mark Menard)
* Select fields with duplicate selected options sent an incorrect value (Noah Davis) * Select fields with duplicate selected options sent an incorrect value (Noah Davis)
== 0.4.3 / 2009-03-17 == 0.4.3 / 2009-03-17
* Minor enhancements * Minor enhancements
@ -39,7 +38,7 @@
* Initial Merb and Sinatra compatibility for Selenium mode (Corey Donohoe) * Initial Merb and Sinatra compatibility for Selenium mode (Corey Donohoe)
* When faced with a label with no for attribute, that contains a hidden field * When faced with a label with no for attribute, that contains a hidden field
and another field, as can be the case in Rails 2.3's checkbox view, and another field, as can be the case in Rails 2.3's checkbox view,
webrat now locates the non-hidden field. (Luke Melia) webrat now locates the non-hidden field. (Luke Melia)
* Add application_framework config for Selenium mode to determine how to * Add application_framework config for Selenium mode to determine how to
start and stop the app server (Corey Donohoe) start and stop the app server (Corey Donohoe)
@ -55,7 +54,7 @@
attributes in a hash and :count and :content options. See attributes in a hash and :count and :content options. See
have_selector_spec.rb for more. have_selector_spec.rb for more.
* Add the same functionality mentioned above to have_xpath * Add the same functionality mentioned above to have_xpath
* Minor enhancements * Minor enhancements
* Squeeze extra whitespace out of failures messages from contain * Squeeze extra whitespace out of failures messages from contain
@ -82,7 +81,7 @@
redirected to (Adam Greene) redirected to (Adam Greene)
* Recognize input tags with type button (Lena Herrmann) * Recognize input tags with type button (Lena Herrmann)
* Add uncheck method to Selenium mode (Lee Bankewitz) * Add uncheck method to Selenium mode (Lee Bankewitz)
* Bug fixes * Bug fixes
* Make requests to a Rails app using a full URL instead of a relative path. This change * Make requests to a Rails app using a full URL instead of a relative path. This change
@ -93,7 +92,7 @@
to behave correctly (Noah Davis) to behave correctly (Noah Davis)
* Switch to using selenium.click instead of .check when checking a checkbox * Switch to using selenium.click instead of .check when checking a checkbox
(Noah Davis) (Noah Davis)
* Create tmp/pids directory if directory does not exist. (Amos King and Mike Gaffney) * Create tmp/pids directory if directory does not exist. (Amos King and Mike Gaffney)
* Setup deprecated writers for the selenium_environment= and selenium_port= config * Setup deprecated writers for the selenium_environment= and selenium_port= config
* Ensure the previous pages params aren't passed through redirect (Daniel Lucraft and * Ensure the previous pages params aren't passed through redirect (Daniel Lucraft and
Bryan Helmkamp) Bryan Helmkamp)
@ -169,7 +168,7 @@
* Added save_and_open_screengrab for Selenium mode (Luke Melia) * Added save_and_open_screengrab for Selenium mode (Luke Melia)
* Bug fixes * Bug fixes
* field_labeled should disregard labels without matching fields (Kyle Hargraves) * field_labeled should disregard labels without matching fields (Kyle Hargraves)
* Fixed bug where Scope was creating a new DOM rather than re-using the existing DOM. * Fixed bug where Scope was creating a new DOM rather than re-using the existing DOM.
[#105] (Zach Dennis) [#105] (Zach Dennis)

View File

@ -8,7 +8,7 @@ module Webrat
end end
def click(method = nil, options = {}) def click(method = nil, options = {})
@session.request_page(href, :get, {}) @session.request_page(absolute_href, :get, {})
end end
protected protected
@ -16,5 +16,16 @@ module Webrat
def href def href
Webrat::XML.attribute(@element, "href") Webrat::XML.attribute(@element, "href")
end end
def absolute_href
if href =~ /^\?/
"#{@session.current_url}#{href}"
elsif href !~ %r{^https?://[\w|.]+(/.*)} && (href !~ /^\//)
"#{@session.current_url}/#{href}"
else
href
end
end
end end
end end

View File

@ -16,9 +16,9 @@ module Webrat
options[:javascript] = true if options[:javascript].nil? options[:javascript] = true if options[:javascript].nil?
if options[:javascript] if options[:javascript]
@session.request_page(href, method, data) @session.request_page(absolute_href, method, data)
else else
@session.request_page(href, :get, {}) @session.request_page(absolute_href, :get, {})
end end
end end
@ -40,6 +40,16 @@ module Webrat
Webrat::XML.attribute(@element, "href") Webrat::XML.attribute(@element, "href")
end end
def absolute_href
if href =~ /^\?/
"#{@session.current_url}#{href}"
elsif href !~ %r{^https?://} && (href !~ /^\//)
"#{@session.current_url}/#{href}"
else
href
end
end
def authenticity_token def authenticity_token
return unless onclick && onclick.include?("s.setAttribute('name', 'authenticity_token');") && return unless onclick && onclick.include?("s.setAttribute('name', 'authenticity_token');") &&
onclick =~ /s\.setAttribute\('value', '([a-f0-9]{40})'\);/ onclick =~ /s\.setAttribute\('value', '([a-f0-9]{40})'\);/

View File

@ -97,32 +97,10 @@ For example:
@default_headers.dup.merge(@custom_headers.dup) @default_headers.dup.merge(@custom_headers.dup)
end end
def canonicalize_url(href_url)
@current_url ||= "http://www.example.com/" # @current_url can't be blank, or things break
# Case one: relative url
if href_url !~ %r{^https?://} && (href_url !~ /^\//)
# If the relative url starts with # or ?, we need append it as is _if_ there are three slashes in the current url;
# otherwise, ensure there's a slash between it and the current
# url
if (href_url =~ /^\?/ or href_url =~ /^#/) && current_url.scan('/').length > 2
"#{current_url}#{href_url}"
else
"#{current_url.chomp('/')}/#{href_url}"
end
# Case two: absolute url without host
elsif href_url =~ /^\//
"http://#{current_host}#{href_url}"
# Case three: absolute url with scheme and host.
else
href_url
end
end
def request_page(url, http_method, data) #:nodoc: def request_page(url, http_method, data) #:nodoc:
h = headers h = headers
h['HTTP_REFERER'] = @current_url if @current_url h['HTTP_REFERER'] = @current_url if @current_url
url = canonicalize_url(url)
debug_log "REQUESTING PAGE: #{http_method.to_s.upcase} #{url} with #{data.inspect} and HTTP headers #{h.inspect}" debug_log "REQUESTING PAGE: #{http_method.to_s.upcase} #{url} with #{data.inspect} and HTTP headers #{h.inspect}"
process_request(http_method, url, data, h) process_request(http_method, url, data, h)
@ -289,7 +267,7 @@ For example:
end end
def response_location def response_location
canonicalize_url(response.headers["Location"]) response.headers["Location"]
end end
def current_host def current_host

View File

@ -16,13 +16,13 @@ namespace :test_unit do
desc "runs the test::unit based tests in webrat mode" desc "runs the test::unit based tests in webrat mode"
task :rails do task :rails do
ENV['WEBRAT_INTEGRATION_MODE'] = 'rails' ENV['WEBRAT_INTEGRATION_MODE'] = 'rails'
Rake::Task['test:integration'].execute nil Rake::Task['test:integration'].execute
end end
desc "runs the test::unit based tests in selenium mode" desc "runs the test::unit based tests in selenium mode"
task :selenium do task :selenium do
ENV['WEBRAT_INTEGRATION_MODE'] = 'selenium' ENV['WEBRAT_INTEGRATION_MODE'] = 'selenium'
Rake::Task['test:integration'].execute nil Rake::Task['test:integration'].execute
end end
desc "run both selenium and rails mode Test::Unit suites" desc "run both selenium and rails mode Test::Unit suites"

View File

@ -118,7 +118,7 @@ describe Webrat::Session do
webrat_session.request_page("/oldurl", :get, {}) webrat_session.request_page("/oldurl", :get, {})
webrat_session.current_url.should == "http://www.example.com/oldurl" webrat_session.current_url.should == "/oldurl"
end end
end end
@ -195,73 +195,4 @@ describe Webrat::Session do
end end
describe "#canonicalize_url"do
it "should turn 'http://www.example.com/' into 'http://www.example.com/'" do
webrat_session.stub!(:current_url => "http://www.example.com")
webrat_session.canonicalize_url("http://www.example.com/").should == "http://www.example.com/"
end
it "should turn '/login' into 'http://www.example.com/login' if current_url is 'http://www.example.com/'" do
webrat_session.stub!(:current_url => "http://www.example.com/")
webrat_session.canonicalize_url("/login").should == "http://www.example.com/login"
end
it "should turn '/login' into 'http://www.example.com/login' if current_url is 'http://www.example.com'" do
webrat_session.stub!(:current_url => "http://www.example.com")
webrat_session.canonicalize_url("/login").should == "http://www.example.com/login"
end
it "should turn 'login' into 'http://www.example.com/login' if current_url is 'http://www.example.com'" do
webrat_session.stub!(:current_url => "http://www.example.com")
webrat_session.canonicalize_url("login").should == "http://www.example.com/login"
end
it "should turn 'login' into 'http://www.example.com/login' if current_url is 'http://www.example.com/'" do
webrat_session.stub!(:current_url => "http://www.example.com/")
webrat_session.canonicalize_url("login").should == "http://www.example.com/login"
end
it "should turn '?login' into 'http://www.example.com/?login' if current_url is 'http://www.example.com'" do
webrat_session.stub!(:current_url => "http://www.example.com")
webrat_session.canonicalize_url("?login").should == "http://www.example.com/?login"
end
it "should turn '?login' into 'http://www.example.com/?login' if current_url is 'http://www.example.com/'" do
webrat_session.stub!(:current_url => "http://www.example.com/")
webrat_session.canonicalize_url("?login").should == "http://www.example.com/?login"
end
it "should turn '?login' into 'http://www.example.com/page?login' if current_url is 'http://www.example.com/page'" do
webrat_session.stub!(:current_url => "http://www.example.com/page")
webrat_session.canonicalize_url("?login").should == "http://www.example.com/page?login"
end
it "should turn '?login' into 'http://www.example.com/page/?login' if current_url is 'http://www.example.com/page/'" do
webrat_session.stub!(:current_url => "http://www.example.com/page/")
webrat_session.canonicalize_url("?login").should == "http://www.example.com/page/?login"
end
it "should turn '#anchor' into 'http://www.example.com/#anchor' if current_url is 'http://www.example.com'" do
webrat_session.stub!(:current_url => "http://www.example.com")
webrat_session.canonicalize_url("#anchor").should == "http://www.example.com/#anchor"
end
it "should turn '#anchor' into 'http://www.example.com/#anchor' if current_url is 'http://www.example.com/'" do
webrat_session.stub!(:current_url => "http://www.example.com/")
webrat_session.canonicalize_url("#anchor").should == "http://www.example.com/#anchor"
end
it "should turn '#anchor' into 'http://www.example.com/page#anchor' if current_url is 'http://www.example.com/page'" do
webrat_session.stub!(:current_url => "http://www.example.com/page")
webrat_session.canonicalize_url("#anchor").should == "http://www.example.com/page#anchor"
end
it "should turn '#anchor' into 'http://www.example.com/page/#anchor' if current_url is 'http://www.example.com/page/'" do
webrat_session.stub!(:current_url => "http://www.example.com/page/")
webrat_session.canonicalize_url("#anchor").should == "http://www.example.com/page/#anchor"
end
end
end end

View File

@ -27,7 +27,7 @@ describe "attach_file" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/widgets", { "widget" => { "file" => "" } }) webrat_session.should_receive(:post).with("/widgets", { "widget" => { "file" => "" } })
click_button click_button
end end
@ -41,7 +41,7 @@ describe "attach_file" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/widgets", { "widget" => { "file" => @uploaded_file } }) webrat_session.should_receive(:post).with("/widgets", { "widget" => { "file" => @uploaded_file } })
attach_file "Document", @filename attach_file "Document", @filename
click_button click_button
end end
@ -58,7 +58,7 @@ describe "attach_file" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/widgets", { "widget" => { "files" => [@uploaded_file, @uploaded_file] } }) webrat_session.should_receive(:post).with("/widgets", { "widget" => { "files" => [@uploaded_file, @uploaded_file] } })
attach_file "Document", @filename attach_file "Document", @filename
attach_file "Spreadsheet", @filename attach_file "Spreadsheet", @filename
click_button click_button

View File

@ -96,8 +96,7 @@ describe Webrat::RailsSession do
response = mock("response", :body => body, :headers => {}, :code => 200) response = mock("response", :body => body, :headers => {}, :code => 200)
@integration_session.stub!(:response => response) @integration_session.stub!(:response => response)
@integration_session.stub!(:https!) @integration_session.should_receive(:get).with("/page2", {}, nil)
@integration_session.should_receive(:get).with("http://www.example.com/page2", {}, nil)
rails_session = Webrat::RailsSession.new(@integration_session) rails_session = Webrat::RailsSession.new(@integration_session)

View File

@ -6,7 +6,7 @@ describe "Basic Auth HTTP headers" do
end end
it "should be present in visit" do it "should be present in visit" do
webrat_session.should_receive(:get).with("http://www.example.com/", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ=\n"}) webrat_session.should_receive(:get).with("/", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ=\n"})
visit("/") visit("/")
end end
@ -18,7 +18,7 @@ describe "Basic Auth HTTP headers" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/form1", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ=\n"}) webrat_session.should_receive(:post).with("/form1", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ=\n"})
click_button click_button
end end
end end

View File

@ -36,7 +36,7 @@ describe "check" do
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"tos" => "1"}) webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
check "TOS" check "TOS"
click_button click_button
end end
@ -51,7 +51,7 @@ describe "check" do
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "remember_me" => "on") webrat_session.should_receive(:post).with("/login", "remember_me" => "on")
check "remember_me" check "remember_me"
click_button click_button
end end
@ -79,7 +79,7 @@ describe "check" do
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "remember_me" => "yes") webrat_session.should_receive(:post).with("/login", "remember_me" => "yes")
check "remember_me" check "remember_me"
click_button click_button
end end
@ -132,7 +132,7 @@ describe "uncheck" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"tos" => "0"}) webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "0"})
check "TOS" check "TOS"
uncheck "TOS" uncheck "TOS"
click_button click_button
@ -147,7 +147,7 @@ describe "uncheck" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", {}) webrat_session.should_receive(:post).with("/login", {})
uncheck "remember_me" uncheck "remember_me"
click_button click_button
end end
@ -164,7 +164,7 @@ describe "uncheck" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", {"options" => ["1", "2"]}) webrat_session.should_receive(:post).with("/login", {"options" => ["1", "2"]})
check 'Option 1' check 'Option 1'
check 'Option 2' check 'Option 2'
click_button click_button
@ -183,7 +183,7 @@ describe "uncheck" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"tos" => "0"}) webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "0"})
uncheck "TOS" uncheck "TOS"
click_button click_button
end end

View File

@ -36,7 +36,7 @@ describe "choose" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"gender" => "M"}) webrat_session.should_receive(:get).with("/login", "user" => {"gender" => "M"})
choose "Male" choose "Male"
click_button click_button
end end
@ -53,7 +53,7 @@ describe "choose" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"gender" => "M"}) webrat_session.should_receive(:get).with("/login", "user" => {"gender" => "M"})
choose "Female" choose "Female"
choose "Male" choose "Male"
click_button click_button
@ -81,7 +81,7 @@ describe "choose" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "first_option" => "on") webrat_session.should_receive(:post).with("/login", "first_option" => "on")
choose "first_option" choose "first_option"
click_button click_button
end end
@ -95,7 +95,7 @@ describe "choose" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "first_option" => "on") webrat_session.should_receive(:post).with("/login", "first_option" => "on")
click_button click_button
end end
@ -111,7 +111,7 @@ describe "choose" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "user" => {"gender" => "M"}) webrat_session.should_receive(:post).with("/login", "user" => {"gender" => "M"})
choose "Male" choose "Male"
click_button click_button
end end

View File

@ -9,7 +9,7 @@ describe "click_area" do
</map> </map>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page", {}) webrat_session.should_receive(:get).with("/page", {})
click_area "Berlin" click_area "Berlin"
end end
@ -62,13 +62,13 @@ describe "click_area" do
</map> </map>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page", {}) webrat_session.should_receive(:get).with("/page", {})
click_area "berlin" click_area "berlin"
end end
it "should follow relative links" do it "should follow relative links" do
webrat_session.stub!(:current_url => "http://www.example.com/page") webrat_session.stub!(:current_url => "/page")
with_html <<-HTML with_html <<-HTML
<html> <html>
<map name="map_de" id="map_de"> <map name="map_de" id="map_de">
@ -76,7 +76,7 @@ describe "click_area" do
</map> </map>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page/sub", {}) webrat_session.should_receive(:get).with("/page/sub", {})
click_area "Berlin" click_area "Berlin"
end end
@ -100,7 +100,7 @@ describe "click_area" do
</map> </map>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page?foo=bar", {}) webrat_session.should_receive(:get).with("/page?foo=bar", {})
click_area "Berlin" click_area "Berlin"
end end
end end

View File

@ -86,7 +86,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/form1", {}) webrat_session.should_receive(:get).with("/form1", {})
click_button click_button
end end
@ -113,7 +113,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/form2", {}) webrat_session.should_receive(:get).with("/form2", {})
click_button "Form2" click_button "Form2"
end end
@ -125,7 +125,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", {}) webrat_session.should_receive(:get).with("/login", {})
click_button click_button
end end
@ -150,7 +150,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "login" => "Login") webrat_session.should_receive(:post).with("/login", "login" => "Login")
click_button("Login") click_button("Login")
end end
@ -163,7 +163,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", {}) webrat_session.should_receive(:post).with("/login", {})
click_button("Login") click_button("Login")
end end
@ -176,7 +176,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"password" => "mypass"}) webrat_session.should_receive(:get).with("/login", "user" => {"password" => "mypass"})
click_button click_button
end end
@ -189,7 +189,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"email" => "test@example.com"}) webrat_session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"})
click_button click_button
end end
@ -202,7 +202,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"email" => "test@example.com"}) webrat_session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"})
click_button click_button
end end
@ -219,7 +219,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", {}) webrat_session.should_receive(:get).with("/login", {})
click_button click_button
end end
@ -232,7 +232,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"tos" => "1"}) webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
click_button click_button
end end
@ -248,7 +248,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"gender" => "F"}) webrat_session.should_receive(:get).with("/login", "user" => {"gender" => "F"})
click_button click_button
end end
@ -262,7 +262,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"tos" => "0"}) webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "0"})
click_button click_button
end end
@ -276,7 +276,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"tos" => "1"}) webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
click_button click_button
end end
@ -298,7 +298,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", webrat_session.should_receive(:post).with("/login",
"options" => ["burger", "fries", "soda", "soda", "dessert"], "options" => ["burger", "fries", "soda", "soda", "dessert"],
"response" => { "choices" => [{"selected" => "one"}, {"selected" => "two"}, {"selected" => "two"}]}) "response" => { "choices" => [{"selected" => "one"}, {"selected" => "two"}, {"selected" => "two"}]})
click_button click_button
@ -313,7 +313,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", {}) webrat_session.should_receive(:get).with("/login", {})
click_button click_button
end end
@ -326,7 +326,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/posts", "post" => {"body" => "Post body here!"}) webrat_session.should_receive(:post).with("/posts", "post" => {"body" => "Post body here!"})
click_button click_button
end end
@ -340,7 +340,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/posts", "post" => {"body" => "Peanut butter & jelly"}) webrat_session.should_receive(:post).with("/posts", "post" => {"body" => "Peanut butter & jelly"})
click_button click_button
end end
end end
@ -357,7 +357,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "month" => "2") webrat_session.should_receive(:get).with("/login", "month" => "2")
click_button click_button
end end
@ -373,7 +373,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "month" => "February") webrat_session.should_receive(:get).with("/login", "month" => "February")
click_button click_button
end end
@ -389,7 +389,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "month" => "1") webrat_session.should_receive(:get).with("/login", "month" => "1")
click_button click_button
end end
@ -403,7 +403,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "contestant" => {"scores" => {'1' => '2', '3' => '4'}}) webrat_session.should_receive(:post).with("/login", "contestant" => {"scores" => {'1' => '2', '3' => '4'}})
click_button click_button
end end
@ -416,7 +416,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"email" => ""}) webrat_session.should_receive(:get).with("/login", "user" => {"email" => ""})
click_button click_button
end end
@ -429,7 +429,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"email" => ""}) webrat_session.should_receive(:get).with("/login", "user" => {"email" => ""})
click_button click_button
end end
@ -490,7 +490,7 @@ describe "click_button" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/login", "user" => {"email" => ""}) webrat_session.should_receive(:get).with("/login", "user" => {"email" => ""})
click_button "Login" click_button "Login"
end end
end end

View File

@ -7,7 +7,7 @@ describe "click_link" do
<a href="/page">Save &amp; go back</a> <a href="/page">Save &amp; go back</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page", {}) webrat_session.should_receive(:get).with("/page", {})
click_link "Save & go back" click_link "Save & go back"
end end
@ -17,7 +17,7 @@ describe "click_link" do
<a href="/page">Link text</a> <a href="/page">Link text</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page", {}) webrat_session.should_receive(:get).with("/page", {})
click_link "Link text" click_link "Link text"
end end
@ -27,7 +27,7 @@ describe "click_link" do
<a href="/page">Link text</a> <a href="/page">Link text</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page", {}) webrat_session.should_receive(:get).with("/page", {})
click_link "Link text", :method => :get click_link "Link text", :method => :get
end end
@ -37,7 +37,7 @@ describe "click_link" do
<a href="/page">Link text</a> <a href="/page">Link text</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page", {}) webrat_session.should_receive(:get).with("/page", {})
click_link "ink tex", :method => :get click_link "ink tex", :method => :get
end end
@ -47,7 +47,7 @@ describe "click_link" do
<a href="/page">Link text</a> <a href="/page">Link text</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:delete).with("http://www.example.com/page", {}) webrat_session.should_receive(:delete).with("/page", {})
click_link "Link text", :method => :delete click_link "Link text", :method => :delete
end end
@ -58,7 +58,7 @@ describe "click_link" do
<a href="/page">Link text</a> <a href="/page">Link text</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/page", {}) webrat_session.should_receive(:post).with("/page", {})
click_link "Link text", :method => :post click_link "Link text", :method => :post
end end
@ -68,7 +68,7 @@ describe "click_link" do
<a href="/page">Link text</a> <a href="/page">Link text</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:put).with("http://www.example.com/page", {}) webrat_session.should_receive(:put).with("/page", {})
click_link "Link text", :method => :put click_link "Link text", :method => :put
end end
@ -78,7 +78,7 @@ describe "click_link" do
<a href="/page">Link text</a> <a href="/page">Link text</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page", {}) webrat_session.should_receive(:get).with("/page", {})
click_link /link [a-z]/i click_link /link [a-z]/i
end end
@ -88,7 +88,7 @@ describe "click_link" do
<a id="link_text_link" href="/page">Link text</a> <a id="link_text_link" href="/page">Link text</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page", {}) webrat_session.should_receive(:get).with("/page", {})
click_link "link_text_link" click_link "link_text_link"
end end
@ -98,7 +98,7 @@ describe "click_link" do
<a id="link_text_link" href="/page">Link text</a> <a id="link_text_link" href="/page">Link text</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page", {}) webrat_session.should_receive(:get).with("/page", {})
click_link /_text_/ click_link /_text_/
end end
@ -108,7 +108,7 @@ describe "click_link" do
<a title="piddle" href="/page">Link text</a> <a title="piddle" href="/page">Link text</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page", {}) webrat_session.should_receive(:get).with("/page", {})
click_link 'piddle' click_link 'piddle'
end end
@ -118,7 +118,7 @@ describe "click_link" do
<a title="piddlediddle" href="/page">Link text</a> <a title="piddlediddle" href="/page">Link text</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page", {}) webrat_session.should_receive(:get).with("/page", {})
click_link /iddle/ click_link /iddle/
end end
@ -140,7 +140,7 @@ describe "click_link" do
return false;">Posts</a> return false;">Posts</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/posts", "authenticity_token" => "aa79cb354597a60a3786e7e291ed4f74d77d3a62") webrat_session.should_receive(:post).with("/posts", "authenticity_token" => "aa79cb354597a60a3786e7e291ed4f74d77d3a62")
click_link "Posts" click_link "Posts"
end end
@ -161,7 +161,7 @@ describe "click_link" do
return false;">Delete</a> return false;">Delete</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:delete).with("http://www.example.com/posts/1", {}) webrat_session.should_receive(:delete).with("/posts/1", {})
click_link "Delete" click_link "Delete"
end end
@ -177,7 +177,7 @@ describe "click_link" do
return false;">Posts</a> return false;">Posts</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/posts", {}) webrat_session.should_receive(:post).with("/posts", {})
click_link "Posts" click_link "Posts"
end end
@ -193,7 +193,7 @@ describe "click_link" do
return false;">Posts</a> return false;">Posts</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/posts", {}) webrat_session.should_receive(:get).with("/posts", {})
click_link "Posts", :javascript => false click_link "Posts", :javascript => false
end end
@ -214,7 +214,7 @@ describe "click_link" do
return false;">Post</a></h2> return false;">Post</a></h2>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/posts", {}) webrat_session.should_receive(:post).with("/posts", {})
click_link "Post" click_link "Post"
end end
@ -235,7 +235,7 @@ describe "click_link" do
return false;">Put</a></h2> return false;">Put</a></h2>
</html> </html>
HTML HTML
webrat_session.should_receive(:put).with("http://www.example.com/posts", {}) webrat_session.should_receive(:put).with("/posts", {})
click_link "Put" click_link "Put"
end end
@ -302,7 +302,7 @@ describe "click_link" do
<a href="/page">Link text</a> <a href="/page">Link text</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page", {}) webrat_session.should_receive(:get).with("/page", {})
click_link "LINK TEXT" click_link "LINK TEXT"
end end
@ -312,7 +312,7 @@ describe "click_link" do
<a href="/page">This is some cool link text, isn't it?</a> <a href="/page">This is some cool link text, isn't it?</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page", {}) webrat_session.should_receive(:get).with("/page", {})
click_link "Link text" click_link "Link text"
end end
@ -322,7 +322,7 @@ describe "click_link" do
<a href="/page"><span>Link text</span></a> <a href="/page"><span>Link text</span></a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page", {}) webrat_session.should_receive(:get).with("/page", {})
click_link "Link text" click_link "Link text"
end end
@ -333,7 +333,7 @@ describe "click_link" do
<a href="/page2">Link text</a> <a href="/page2">Link text</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page1", {}) webrat_session.should_receive(:get).with("/page1", {})
click_link "Link text" click_link "Link text"
end end
@ -345,7 +345,7 @@ describe "click_link" do
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page2", {}) webrat_session.should_receive(:get).with("/page2", {})
click_link "Link" click_link "Link"
end end
@ -356,7 +356,7 @@ describe "click_link" do
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page1", {}) webrat_session.should_receive(:get).with("/page1", {})
click_link "This is a link" click_link "This is a link"
end end
@ -369,7 +369,7 @@ describe "click_link" do
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page2", {}) webrat_session.should_receive(:get).with("/page2", {})
click_link "Location" click_link "Location"
end end
end end
@ -384,7 +384,7 @@ describe "click_link" do
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page2", {}) webrat_session.should_receive(:get).with("/page2", {})
click_link_within "#container", "Link" click_link_within "#container", "Link"
end end
@ -400,18 +400,18 @@ describe "click_link" do
end end
it "should follow relative links" do it "should follow relative links" do
webrat_session.stub!(:current_url => "http://www.example.com/page") webrat_session.stub!(:current_url => "/page")
with_html <<-HTML with_html <<-HTML
<html> <html>
<a href="sub">Jump to sub page</a> <a href="sub">Jump to sub page</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page/sub", {}) webrat_session.should_receive(:get).with("/page/sub", {})
click_link "Jump to sub page" click_link "Jump to sub page"
end end
it "should follow fully qualified local links" do it "should follow fully qualified local links" do
webrat_session.stub!(:current_url => "http://www.example.com/page") webrat_session.stub!(:current_url => "/page")
with_html <<-HTML with_html <<-HTML
<html> <html>
<a href="http://subdomain.example.com/page/sub">Jump to sub page</a> <a href="http://subdomain.example.com/page/sub">Jump to sub page</a>
@ -432,13 +432,13 @@ describe "click_link" do
end end
it "should follow query parameters" do it "should follow query parameters" do
webrat_session.stub!(:current_url => "http://www.example.com/page") webrat_session.stub!(:current_url => "/page")
with_html <<-HTML with_html <<-HTML
<html> <html>
<a href="?foo=bar">Jump to foo bar</a> <a href="?foo=bar">Jump to foo bar</a>
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page?foo=bar", {}) webrat_session.should_receive(:get).with("/page?foo=bar", {})
click_link "Jump to foo bar" click_link "Jump to foo bar"
end end

View File

@ -11,7 +11,7 @@ describe "fill_in" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "user" => {"text" => "filling text area"}) webrat_session.should_receive(:post).with("/login", "user" => {"text" => "filling text area"})
fill_in "User Text", :with => "filling text area" fill_in "User Text", :with => "filling text area"
click_button click_button
end end
@ -25,7 +25,7 @@ describe "fill_in" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "user" => {"text" => "pass"}) webrat_session.should_receive(:post).with("/login", "user" => {"text" => "pass"})
fill_in "user_text", :with => "pass" fill_in "user_text", :with => "pass"
click_button click_button
end end
@ -65,7 +65,7 @@ describe "fill_in" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "user" => {"email" => "foo@example.com"}) webrat_session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
fill_in "user[email]", :with => "foo@example.com" fill_in "user[email]", :with => "foo@example.com"
click_button click_button
end end
@ -83,7 +83,7 @@ describe "fill_in" do
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "user" => {"mail1" => "", "mail2" => "value"}) webrat_session.should_receive(:post).with("/login", "user" => {"mail1" => "", "mail2" => "value"})
fill_in "Some", :with => "value" fill_in "Some", :with => "value"
click_button click_button
end end
@ -101,7 +101,7 @@ describe "fill_in" do
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "user" => {"mail1" => "value", "mail2" => ""}) webrat_session.should_receive(:post).with("/login", "user" => {"mail1" => "value", "mail2" => ""})
fill_in "Some mail", :with => "value" fill_in "Some mail", :with => "value"
click_button click_button
end end
@ -144,7 +144,7 @@ describe "fill_in" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "user" => {"email" => "foo@example.com"}) webrat_session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
fill_in "Email", :with => "foo@example.com" fill_in "Email", :with => "foo@example.com"
click_button click_button
end end
@ -158,7 +158,7 @@ describe "fill_in" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "user" => {"email" => "foo@example.com"}) webrat_session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
fill_in "user[email]", :with => "foo@example.com" fill_in "user[email]", :with => "foo@example.com"
click_button click_button
end end
@ -172,7 +172,7 @@ describe "fill_in" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "user" => {"email" => "foo@example.com"}) webrat_session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
fill_in "user[email]", :with => "foo@example.com" fill_in "user[email]", :with => "foo@example.com"
click_button click_button
end end
@ -187,7 +187,7 @@ describe "fill_in" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "user" => {"email" => "foo@example.com"}) webrat_session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
fill_in :email, :with => "foo@example.com" fill_in :email, :with => "foo@example.com"
click_button click_button
end end
@ -202,7 +202,7 @@ describe "fill_in" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/users", "user" => {"phone" => "+1 22 33"}) webrat_session.should_receive(:post).with("/users", "user" => {"phone" => "+1 22 33"})
fill_in 'Phone', :with => "+1 22 33" fill_in 'Phone', :with => "+1 22 33"
click_button click_button
end end

View File

@ -2,9 +2,9 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
describe "reloads" do describe "reloads" do
it "should reload the page with http referer" do it "should reload the page with http referer" do
webrat_session.should_receive(:get).with("http://www.example.com/", {}) webrat_session.should_receive(:get).with("/", {})
webrat_session.should_receive(:get).with("/", {}, {"HTTP_REFERER"=>"/"})
visit("/") visit("/")
webrat_session.should_receive(:get).with("http://www.example.com/", {}, {"HTTP_REFERER"=>"http://www.example.com/"})
reload reload
end end
end end

View File

@ -19,7 +19,7 @@ describe "select_date" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/appointments", webrat_session.should_receive(:post).with("/appointments",
"appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"}) "appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"})
select_date "December 25, 2003", :from => "Date" select_date "December 25, 2003", :from => "Date"
click_button click_button
@ -43,7 +43,7 @@ describe "select_date" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/appointments", webrat_session.should_receive(:post).with("/appointments",
"appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"}) "appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"})
select_date Date.parse("December 25, 2003"), :from => "date" select_date Date.parse("December 25, 2003"), :from => "date"
click_button click_button
@ -66,7 +66,7 @@ describe "select_date" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/appointments", webrat_session.should_receive(:post).with("/appointments",
"appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"}) "appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"})
select_date "December 25, 2003" select_date "December 25, 2003"
click_button click_button
@ -90,7 +90,7 @@ describe "select_date" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/appointments", webrat_session.should_receive(:post).with("/appointments",
"appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"}) "appointment" => {"date(1i)" => '2003', "date(2i)" => "12", "date(3i)" => "25"})
select_date Date.parse("December 25, 2003"), :from => "date ?" select_date Date.parse("December 25, 2003"), :from => "date ?"
click_button click_button

View File

@ -25,7 +25,7 @@ describe "select_datetime" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/appointments", webrat_session.should_receive(:post).with("/appointments",
"appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"}) "appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"})
select_datetime "December 25, 2003 9:30", :from => "Time" select_datetime "December 25, 2003 9:30", :from => "Time"
click_button click_button
@ -55,7 +55,7 @@ describe "select_datetime" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/appointments", webrat_session.should_receive(:post).with("/appointments",
"appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"}) "appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"})
select_datetime Time.parse("December 25, 2003 9:30"), :from => "Time" select_datetime Time.parse("December 25, 2003 9:30"), :from => "Time"
click_button click_button
@ -85,7 +85,7 @@ describe "select_datetime" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/appointments", webrat_session.should_receive(:post).with("/appointments",
"appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"}) "appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"})
select_datetime "December 25, 2003 9:30", :from => "Time ?" select_datetime "December 25, 2003 9:30", :from => "Time ?"
click_button click_button
@ -115,7 +115,7 @@ describe "select_datetime" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/appointments", webrat_session.should_receive(:post).with("/appointments",
"appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"}) "appointment" => {"time(1i)" => '2003', "time(2i)" => "12", "time(3i)" => "25", "time(4i)" => "09", "time(5i)" => "30"})
select_datetime "December 25, 2003 9:30" select_datetime "December 25, 2003 9:30"
click_button click_button

View File

@ -62,7 +62,7 @@ describe "select" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "month" => "1") webrat_session.should_receive(:post).with("/login", "month" => "1")
select "January", :from => "month" select "January", :from => "month"
click_button click_button
end end
@ -76,7 +76,7 @@ describe "select" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "encoded" => "A & B") webrat_session.should_receive(:post).with("/login", "encoded" => "A & B")
select "Encoded", :from => "encoded" select "Encoded", :from => "encoded"
click_button click_button
end end
@ -90,7 +90,7 @@ describe "select" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", 'month' => '') webrat_session.should_receive(:post).with("/login", 'month' => '')
click_button click_button
end end
@ -103,7 +103,7 @@ describe "select" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "month" => "1") webrat_session.should_receive(:post).with("/login", "month" => "1")
select "January" select "January"
click_button click_button
end end
@ -118,7 +118,7 @@ describe "select" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "start_month" => "s1", "end_month" => "e1") webrat_session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
select "January", :from => "end_month" select "January", :from => "end_month"
click_button click_button
end end
@ -135,7 +135,7 @@ describe "select" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "start_month" => "s1", "end_month" => "e1") webrat_session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
select "January", :from => "End Month" select "January", :from => "End Month"
click_button click_button
end end
@ -149,7 +149,7 @@ describe "select" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "month" => "January") webrat_session.should_receive(:post).with("/login", "month" => "January")
select "January", :from => "month" select "January", :from => "month"
click_button click_button
end end
@ -163,7 +163,7 @@ describe "select" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "month" => "January") webrat_session.should_receive(:post).with("/login", "month" => "January")
select /jan/i select /jan/i
click_button click_button
end end
@ -195,7 +195,7 @@ describe "select" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "start_month" => "s1", "end_month" => "e1") webrat_session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
select /jan/i, :from => "End Month" select /jan/i, :from => "End Month"
click_button click_button
end end
@ -210,7 +210,7 @@ describe "select" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "month" => "Peanut butter & jelly") webrat_session.should_receive(:post).with("/login", "month" => "Peanut butter & jelly")
click_button click_button
end end
end end
@ -242,7 +242,7 @@ describe "select" do
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/login", "clothes" => "pants") webrat_session.should_receive(:post).with("/login", "clothes" => "pants")
click_button click_button
end end

View File

@ -16,7 +16,7 @@ describe "select_time" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/appointments", webrat_session.should_receive(:post).with("/appointments",
"appointment" => {"time(4i)" => "09", "time(5i)" => "30"}) "appointment" => {"time(4i)" => "09", "time(5i)" => "30"})
select_time "9:30AM", :from => "Time" select_time "9:30AM", :from => "Time"
click_button click_button
@ -37,7 +37,7 @@ describe "select_time" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/appointments", webrat_session.should_receive(:post).with("/appointments",
"appointment" => {"time(4i)" => "09", "time(5i)" => "30"}) "appointment" => {"time(4i)" => "09", "time(5i)" => "30"})
select_time Time.parse("9:30AM"), :from => "Time" select_time Time.parse("9:30AM"), :from => "Time"
click_button click_button
@ -58,7 +58,7 @@ describe "select_time" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/appointments", webrat_session.should_receive(:post).with("/appointments",
"appointment" => {"time(4i)" => "09", "time(5i)" => "30"}) "appointment" => {"time(4i)" => "09", "time(5i)" => "30"})
select_time "9:30AM", :from => "Time #" select_time "9:30AM", :from => "Time #"
click_button click_button
@ -78,7 +78,7 @@ describe "select_time" do
</form> </form>
</html> </html>
HTML HTML
webrat_session.should_receive(:post).with("http://www.example.com/appointments", webrat_session.should_receive(:post).with("/appointments",
"appointment" => {"time(4i)" => "09", "time(5i)" => "30"}) "appointment" => {"time(4i)" => "09", "time(5i)" => "30"})
select_time "9:30" select_time "9:30"
click_button click_button

View File

@ -10,7 +10,7 @@ describe "visit" do
end end
it "should use get" do it "should use get" do
webrat_session.should_receive(:get).with("http://www.example.com/", {}) webrat_session.should_receive(:get).with("/", {})
visit("/") visit("/")
end end
@ -36,7 +36,7 @@ describe "visit" do
visit("/oldurl") visit("/oldurl")
current_url.should == "http://www.example.com/oldurl" current_url.should == "/oldurl"
end end
end end
@ -51,7 +51,7 @@ describe "visit with referer" do
end end
it "should use get with referer header" do it "should use get with referer header" do
webrat_session.should_receive(:get).with("http://www.example.com/", {}, {"HTTP_REFERER" => "/old_url"}) webrat_session.should_receive(:get).with("/", {}, {"HTTP_REFERER" => "/old_url"})
visit("/") visit("/")
end end

View File

@ -13,7 +13,7 @@ describe "within" do
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page2", {}) webrat_session.should_receive(:get).with("/page2", {})
within "#container" do within "#container" do
within "div" do within "div" do
click_link "Link" click_link "Link"
@ -31,7 +31,7 @@ describe "within" do
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/page2", {}) webrat_session.should_receive(:get).with("/page2", {})
within "#container" do within "#container" do
click_link "Link" click_link "Link"
end end
@ -51,7 +51,7 @@ describe "within" do
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/form2", "email" => "test@example.com") webrat_session.should_receive(:get).with("/form2", "email" => "test@example.com")
within "#form2" do within "#form2" do
fill_in "Email", :with => "test@example.com" fill_in "Email", :with => "test@example.com"
click_button click_button
@ -70,7 +70,7 @@ describe "within" do
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/form2", "email" => "test@example.com") webrat_session.should_receive(:get).with("/form2", "email" => "test@example.com")
within ".important" do within ".important" do
fill_in "Email", :with => "test@example.com" fill_in "Email", :with => "test@example.com"
end end
@ -92,7 +92,7 @@ describe "within" do
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/form2", "email" => "test@example.com") webrat_session.should_receive(:get).with("/form2", "email" => "test@example.com")
within "form[@action='/form2']" do within "form[@action='/form2']" do
fill_in "Email", :with => "test@example.com" fill_in "Email", :with => "test@example.com"
click_button "Add" click_button "Add"
@ -117,7 +117,7 @@ describe "within" do
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/form2", "email2" => "test@example.com") webrat_session.should_receive(:get).with("/form2", "email2" => "test@example.com")
within "form[@action='/form2']" do within "form[@action='/form2']" do
fill_in "Email", :with => "test@example.com" fill_in "Email", :with => "test@example.com"
click_button "Add" click_button "Add"
@ -138,7 +138,7 @@ describe "within" do
</html> </html>
HTML HTML
webrat_session.should_receive(:get).with("http://www.example.com/form2", "email" => "test@example.com") webrat_session.should_receive(:get).with("/form2", "email" => "test@example.com")
within "#form2" do within "#form2" do
fill_in "Email", :with => "test@example.com" fill_in "Email", :with => "test@example.com"
click_button "Add" click_button "Add"