Cleaning up rdoc to only show public APIs
This commit is contained in:
parent
6fb79dcb72
commit
2d867451ca
12
Rakefile
12
Rakefile
|
@ -1,5 +1,6 @@
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
require "rake/gempackagetask"
|
require "rake/gempackagetask"
|
||||||
|
require 'rake/rdoctask'
|
||||||
require "rake/clean"
|
require "rake/clean"
|
||||||
require 'spec'
|
require 'spec'
|
||||||
require 'spec/rake/spectask'
|
require 'spec/rake/spectask'
|
||||||
|
@ -75,3 +76,14 @@ task :install_gem => [:clean, :package] do
|
||||||
gem = Dir['pkg/*.gem'].first
|
gem = Dir['pkg/*.gem'].first
|
||||||
sh "sudo gem install --local #{gem}"
|
sh "sudo gem install --local #{gem}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Rake::RDocTask.new(:docs) do |rd|
|
||||||
|
rd.main = "README.txt"
|
||||||
|
rd.rdoc_dir = 'doc'
|
||||||
|
files = spec.files.grep(/^(lib|bin|ext)|txt$/)
|
||||||
|
files -= ["TODO.txt"]
|
||||||
|
files -= files.grep(/\.js$/)
|
||||||
|
rd.rdoc_files = files.uniq
|
||||||
|
title = "webrat-#{Webrat::VERSION} Documentation"
|
||||||
|
rd.options << "-t #{title}"
|
||||||
|
end
|
|
@ -5,7 +5,7 @@ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.i
|
||||||
module Webrat
|
module Webrat
|
||||||
VERSION = '0.3.0'
|
VERSION = '0.3.0'
|
||||||
|
|
||||||
def self.root
|
def self.root #:nodoc:
|
||||||
defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root
|
defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module Webrat
|
module Webrat
|
||||||
class Area
|
class Area #:nodoc:
|
||||||
|
|
||||||
def initialize(session, element)
|
def initialize(session, element)
|
||||||
@session = session
|
@session = session
|
||||||
|
|
|
@ -3,7 +3,7 @@ require "webrat/core_extensions/blank"
|
||||||
require "webrat/core_extensions/nil_to_param"
|
require "webrat/core_extensions/nil_to_param"
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
class Field
|
class Field #:nodoc:
|
||||||
|
|
||||||
def self.class_for_element(element)
|
def self.class_for_element(element)
|
||||||
if element.name == "input"
|
if element.name == "input"
|
||||||
|
@ -138,7 +138,7 @@ module Webrat
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class ButtonField < Field
|
class ButtonField < Field #:nodoc:
|
||||||
|
|
||||||
def matches_text?(text)
|
def matches_text?(text)
|
||||||
@element.inner_html =~ /#{Regexp.escape(text.to_s)}/i
|
@element.inner_html =~ /#{Regexp.escape(text.to_s)}/i
|
||||||
|
@ -165,7 +165,7 @@ module Webrat
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class HiddenField < Field
|
class HiddenField < Field #:nodoc:
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
if collection_name?
|
if collection_name?
|
||||||
|
@ -189,7 +189,7 @@ module Webrat
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class CheckboxField < Field
|
class CheckboxField < Field #:nodoc:
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
return nil if @value.nil?
|
return nil if @value.nil?
|
||||||
|
@ -222,10 +222,10 @@ module Webrat
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class PasswordField < Field
|
class PasswordField < Field #:nodoc:
|
||||||
end
|
end
|
||||||
|
|
||||||
class RadioField < Field
|
class RadioField < Field #:nodoc:
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
return nil if @value.nil?
|
return nil if @value.nil?
|
||||||
|
@ -257,7 +257,7 @@ module Webrat
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class TextareaField < Field
|
class TextareaField < Field #:nodoc:
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ module Webrat
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class FileField < Field
|
class FileField < Field #:nodoc:
|
||||||
|
|
||||||
attr_accessor :content_type
|
attr_accessor :content_type
|
||||||
|
|
||||||
|
@ -296,13 +296,13 @@ module Webrat
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class TextField < Field
|
class TextField < Field #:nodoc:
|
||||||
end
|
end
|
||||||
|
|
||||||
class ResetField < Field
|
class ResetField < Field #:nodoc:
|
||||||
end
|
end
|
||||||
|
|
||||||
class SelectField < Field
|
class SelectField < Field #:nodoc:
|
||||||
|
|
||||||
def find_option(text)
|
def find_option(text)
|
||||||
options.detect { |o| o.matches_text?(text) }
|
options.detect { |o| o.matches_text?(text) }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module Flunk
|
module Flunk
|
||||||
|
|
||||||
def flunk(message)
|
def flunk(message) #:nodoc:
|
||||||
raise message
|
raise message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "webrat/core/field"
|
||||||
require "webrat/core_extensions/blank"
|
require "webrat/core_extensions/blank"
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
class Form
|
class Form #:nodoc:
|
||||||
attr_reader :element
|
attr_reader :element
|
||||||
|
|
||||||
def initialize(session, element)
|
def initialize(session, element)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module Webrat
|
module Webrat
|
||||||
class Label
|
class Label #:nodoc:
|
||||||
|
|
||||||
def initialize(field, element)
|
def initialize(field, element)
|
||||||
@field = field
|
@field = field
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require "webrat/core_extensions/blank"
|
require "webrat/core_extensions/blank"
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
class Link
|
class Link #:nodoc:
|
||||||
|
|
||||||
def initialize(session, element)
|
def initialize(session, element)
|
||||||
@session = session
|
@session = session
|
||||||
|
|
|
@ -26,25 +26,25 @@ module Webrat
|
||||||
flunk("Could not find field with id #{id.inspect}")
|
flunk("Could not find field with id #{id.inspect}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_field_labeled(label, *field_types)
|
def find_field_labeled(label, *field_types) #:nodoc:
|
||||||
forms.detect_mapped do |form|
|
forms.detect_mapped do |form|
|
||||||
form.field_labeled(label, *field_types)
|
form.field_labeled(label, *field_types)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_field_named(name, *field_types)
|
def find_field_named(name, *field_types) #:nodoc:
|
||||||
forms.detect_mapped do |form|
|
forms.detect_mapped do |form|
|
||||||
form.field_named(name, *field_types)
|
form.field_named(name, *field_types)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_field_with_id(id, *field_types)
|
def find_field_with_id(id, *field_types) #:nodoc:
|
||||||
forms.detect_mapped do |form|
|
forms.detect_mapped do |form|
|
||||||
form.field_with_id(id, *field_types)
|
form.field_with_id(id, *field_types)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_select_option(option_text, id_or_name_or_label)
|
def find_select_option(option_text, id_or_name_or_label) #:nodoc:
|
||||||
if id_or_name_or_label
|
if id_or_name_or_label
|
||||||
field = field(id_or_name_or_label, SelectField)
|
field = field(id_or_name_or_label, SelectField)
|
||||||
return field.find_option(option_text)
|
return field.find_option(option_text)
|
||||||
|
@ -59,7 +59,7 @@ module Webrat
|
||||||
flunk("Could not find option #{option_text.inspect}")
|
flunk("Could not find option #{option_text.inspect}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_button(value)
|
def find_button(value) #:nodoc:
|
||||||
button = forms.detect_mapped do |form|
|
button = forms.detect_mapped do |form|
|
||||||
form.find_button(value)
|
form.find_button(value)
|
||||||
end
|
end
|
||||||
|
@ -71,12 +71,12 @@ module Webrat
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_area(area_name)
|
def find_area(area_name) #:nodoc:
|
||||||
areas.detect { |area| area.matches_text?(area_name) } ||
|
areas.detect { |area| area.matches_text?(area_name) } ||
|
||||||
flunk("Could not find area with name #{area_name}")
|
flunk("Could not find area with name #{area_name}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_link(text)
|
def find_link(text) #:nodoc:
|
||||||
matching_links = links.select do |possible_link|
|
matching_links = links.select do |possible_link|
|
||||||
possible_link.matches_text?(text)
|
possible_link.matches_text?(text)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module Webrat
|
module Webrat
|
||||||
module Logging
|
module Logging #:nodoc:
|
||||||
|
|
||||||
def warn_log(message) # :nodoc:
|
def warn_log(message) # :nodoc:
|
||||||
return unless logger
|
return unless logger
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Webrat
|
module Webrat
|
||||||
module Matchers
|
module Matchers
|
||||||
|
|
||||||
class HasContent
|
class HasContent #:nodoc:
|
||||||
def initialize(content)
|
def initialize(content)
|
||||||
@content = content
|
@content = content
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Webrat
|
module Webrat
|
||||||
module Matchers
|
module Matchers
|
||||||
|
|
||||||
class HaveSelector < HaveXpath
|
class HaveSelector < HaveXpath #:nodoc:
|
||||||
|
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# String:: The failure message.
|
# String:: The failure message.
|
||||||
|
|
|
@ -2,7 +2,7 @@ module Webrat
|
||||||
|
|
||||||
module HaveTagMatcher
|
module HaveTagMatcher
|
||||||
|
|
||||||
class HaveTag < ::Webrat::Matchers::HaveSelector
|
class HaveTag < ::Webrat::Matchers::HaveSelector #:nodoc:
|
||||||
|
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# String:: The failure message.
|
# String:: The failure message.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Webrat
|
module Webrat
|
||||||
module Matchers
|
module Matchers
|
||||||
|
|
||||||
class HaveXpath
|
class HaveXpath #:nodoc:
|
||||||
def initialize(expected, &block)
|
def initialize(expected, &block)
|
||||||
@expected = expected
|
@expected = expected
|
||||||
@block = block
|
@block = block
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module Webrat
|
module Webrat
|
||||||
module Methods
|
module Methods #:nodoc:
|
||||||
|
|
||||||
def self.delegate_to_session(*meths)
|
def self.delegate_to_session(*meths)
|
||||||
meths.each do |meth|
|
meths.each do |meth|
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "webrat/core_extensions/meta_class"
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
|
|
||||||
def self.nokogiri_document(stringlike)
|
def self.nokogiri_document(stringlike) #:nodoc:
|
||||||
return stringlike.dom if stringlike.respond_to?(:dom)
|
return stringlike.dom if stringlike.respond_to?(:dom)
|
||||||
|
|
||||||
if stringlike === Nokogiri::HTML::Document || stringlike === Nokogiri::XML::NodeSet
|
if stringlike === Nokogiri::HTML::Document || stringlike === Nokogiri::XML::NodeSet
|
||||||
|
@ -16,7 +16,7 @@ module Webrat
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.define_dom_method(object, dom)
|
def self.define_dom_method(object, dom) #:nodoc:
|
||||||
object.meta_class.send(:define_method, :dom) do
|
object.meta_class.send(:define_method, :dom) do
|
||||||
dom
|
dom
|
||||||
end
|
end
|
||||||
|
@ -29,11 +29,11 @@ module Nokogiri
|
||||||
module CSS
|
module CSS
|
||||||
class XPathVisitor
|
class XPathVisitor
|
||||||
|
|
||||||
def visit_pseudo_class_text(node)
|
def visit_pseudo_class_text(node) #:nodoc:
|
||||||
"@type='text'"
|
"@type='text'"
|
||||||
end
|
end
|
||||||
|
|
||||||
def visit_pseudo_class_password(node)
|
def visit_pseudo_class_password(node) #:nodoc:
|
||||||
"@type='password'"
|
"@type='password'"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,21 +8,21 @@ module Webrat
|
||||||
include Flunk
|
include Flunk
|
||||||
include Locators
|
include Locators
|
||||||
|
|
||||||
def self.from_page(session, response, response_body)
|
def self.from_page(session, response, response_body) #:nodoc:
|
||||||
new(session) do
|
new(session) do
|
||||||
@response = response
|
@response = response
|
||||||
@response_body = response_body
|
@response_body = response_body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_scope(session, scope, selector)
|
def self.from_scope(session, scope, selector) #:nodoc:
|
||||||
new(session) do
|
new(session) do
|
||||||
@scope = scope
|
@scope = scope
|
||||||
@selector = selector
|
@selector = selector
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(session, &block)
|
def initialize(session, &block) #:nodoc:
|
||||||
@session = session
|
@session = session
|
||||||
instance_eval(&block) if block_given?
|
instance_eval(&block) if block_given?
|
||||||
end
|
end
|
||||||
|
@ -100,11 +100,11 @@ module Webrat
|
||||||
# Example:
|
# Example:
|
||||||
# attaches_file "Resume", "/path/to/the/resume.txt"
|
# attaches_file "Resume", "/path/to/the/resume.txt"
|
||||||
# attaches_file "Photo", "/path/to/the/image.png", "image/png"
|
# attaches_file "Photo", "/path/to/the/image.png", "image/png"
|
||||||
def attaches_file(field_locator, path, content_type = nil)
|
def attach_file(field_locator, path, content_type = nil)
|
||||||
locate_field(field_locator, FileField).set(path, content_type)
|
locate_field(field_locator, FileField).set(path, content_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :attach_file, :attaches_file
|
alias_method :attaches_file, :attach_file
|
||||||
|
|
||||||
def click_area(area_name)
|
def click_area(area_name)
|
||||||
find_area(area_name).click
|
find_area(area_name).click
|
||||||
|
@ -165,18 +165,18 @@ module Webrat
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def page_dom
|
def page_dom #:nodoc:
|
||||||
return @response.dom if @response.respond_to?(:dom)
|
return @response.dom if @response.respond_to?(:dom)
|
||||||
dom = Webrat.nokogiri_document(@response_body)
|
dom = Webrat.nokogiri_document(@response_body)
|
||||||
Webrat.define_dom_method(@response, dom)
|
Webrat.define_dom_method(@response, dom)
|
||||||
return dom
|
return dom
|
||||||
end
|
end
|
||||||
|
|
||||||
def scoped_dom
|
def scoped_dom #:nodoc:
|
||||||
Webrat.nokogiri_document(@scope.dom.search(@selector).first.to_html)
|
Webrat.nokogiri_document(@scope.dom.search(@selector).first.to_html)
|
||||||
end
|
end
|
||||||
|
|
||||||
def locate_field(field_locator, *field_types)
|
def locate_field(field_locator, *field_types) #:nodoc:
|
||||||
if field_locator.is_a?(Field)
|
if field_locator.is_a?(Field)
|
||||||
field_locator
|
field_locator
|
||||||
else
|
else
|
||||||
|
@ -184,19 +184,19 @@ module Webrat
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def areas
|
def areas #:nodoc:
|
||||||
dom.search("area").map do |element|
|
dom.search("area").map do |element|
|
||||||
Area.new(@session, element)
|
Area.new(@session, element)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def links
|
def links #:nodoc:
|
||||||
dom.search("a[@href]").map do |link_element|
|
dom.search("a[@href]").map do |link_element|
|
||||||
Link.new(@session, link_element)
|
Link.new(@session, link_element)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def forms
|
def forms #:nodoc:
|
||||||
return @forms if @forms
|
return @forms if @forms
|
||||||
|
|
||||||
@forms = dom.search("form").map do |form_element|
|
@forms = dom.search("form").map do |form_element|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module Webrat
|
module Webrat
|
||||||
class SelectOption
|
class SelectOption #:nodoc:
|
||||||
|
|
||||||
def initialize(select, element)
|
def initialize(select, element)
|
||||||
@select = select
|
@select = select
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Webrat
|
||||||
|
|
||||||
attr_reader :current_url
|
attr_reader :current_url
|
||||||
|
|
||||||
def initialize
|
def initialize #:nodoc:
|
||||||
@http_method = :get
|
@http_method = :get
|
||||||
@data = {}
|
@data = {}
|
||||||
@default_headers = {}
|
@default_headers = {}
|
||||||
|
@ -35,12 +35,12 @@ module Webrat
|
||||||
open_in_browser(filename)
|
open_in_browser(filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_dom
|
def current_dom #:nodoc:
|
||||||
current_scope.dom
|
current_scope.dom
|
||||||
end
|
end
|
||||||
|
|
||||||
# For backwards compatibility -- removing in 1.0
|
# For backwards compatibility -- removing in 1.0
|
||||||
def current_page
|
def current_page #:nodoc:
|
||||||
page = OpenStruct.new
|
page = OpenStruct.new
|
||||||
page.url = @current_url
|
page.url = @current_url
|
||||||
page.http_method = @http_method
|
page.http_method = @http_method
|
||||||
|
@ -48,11 +48,11 @@ module Webrat
|
||||||
page
|
page
|
||||||
end
|
end
|
||||||
|
|
||||||
def doc_root
|
def doc_root #:nodoc:
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def saved_page_dir
|
def saved_page_dir #:nodoc:
|
||||||
File.expand_path(".")
|
File.expand_path(".")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -69,11 +69,11 @@ module Webrat
|
||||||
header('HTTP_AUTHORIZATION', "Basic #{encoded_login}")
|
header('HTTP_AUTHORIZATION', "Basic #{encoded_login}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def headers
|
def headers #:nodoc:
|
||||||
@default_headers.dup.merge(@custom_headers.dup)
|
@default_headers.dup.merge(@custom_headers.dup)
|
||||||
end
|
end
|
||||||
|
|
||||||
def request_page(url, http_method, data)
|
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
|
||||||
|
|
||||||
|
@ -96,15 +96,15 @@ module Webrat
|
||||||
return response
|
return response
|
||||||
end
|
end
|
||||||
|
|
||||||
def success_code?
|
def success_code? #:nodoc:
|
||||||
(200..499).include?(response_code)
|
(200..499).include?(response_code)
|
||||||
end
|
end
|
||||||
|
|
||||||
def exception_caught?
|
def exception_caught? #:nodoc:
|
||||||
response_body =~ /Exception caught/
|
response_body =~ /Exception caught/
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_scope
|
def current_scope #:nodoc:
|
||||||
scopes.last || page_scope
|
scopes.last || page_scope
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -150,25 +150,25 @@ module Webrat
|
||||||
|
|
||||||
alias_method :visits, :visit
|
alias_method :visits, :visit
|
||||||
|
|
||||||
def open_in_browser(path) # :nodoc
|
def open_in_browser(path) #:nodoc
|
||||||
`open #{path}`
|
`open #{path}`
|
||||||
end
|
end
|
||||||
|
|
||||||
def rewrite_css_and_image_references(response_html) # :nodoc
|
def rewrite_css_and_image_references(response_html) #:nodoc
|
||||||
return response_html unless doc_root
|
return response_html unless doc_root
|
||||||
response_html.gsub(/"\/(stylesheets|images)/, doc_root + '/\1')
|
response_html.gsub(/"\/(stylesheets|images)/, doc_root + '/\1')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Subclasses can override this to show error messages without html
|
# Subclasses can override this to show error messages without html
|
||||||
def formatted_error
|
def formatted_error #:nodoc:
|
||||||
response_body
|
response_body
|
||||||
end
|
end
|
||||||
|
|
||||||
def scopes
|
def scopes #:nodoc:
|
||||||
@_scopes ||= []
|
@_scopes ||= []
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_scope
|
def page_scope #:nodoc:
|
||||||
@_page_scope ||= Scope.from_page(self, response, response_body)
|
@_page_scope ||= Scope.from_page(self, response, response_body)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Object
|
class Object #:nodoc:
|
||||||
# An object is blank if it's false, empty, or a whitespace string.
|
# An object is blank if it's false, empty, or a whitespace string.
|
||||||
# For example, "", " ", +nil+, [], and {} are blank.
|
# For example, "", " ", +nil+, [], and {} are blank.
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Module
|
class Module #:nodoc:
|
||||||
def deprecate(old_method_name, new_method_name)
|
def deprecate(old_method_name, new_method_name)
|
||||||
define_method old_method_name do |*args|
|
define_method old_method_name do |*args|
|
||||||
warn "#{old_method_name} is deprecated. Use #{new_method_name} instead."
|
warn "#{old_method_name} is deprecated. Use #{new_method_name} instead."
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Array
|
class Array #:nodoc:
|
||||||
|
|
||||||
def detect_mapped
|
def detect_mapped
|
||||||
each do |element|
|
each do |element|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# This class has dubious semantics and we only have it so that
|
# This class has dubious semantics and we only have it so that
|
||||||
# people can write params[:key] instead of params['key']
|
# people can write params[:key] instead of params['key']
|
||||||
# and they get the same value for both keys.
|
# and they get the same value for both keys.
|
||||||
class HashWithIndifferentAccess < Hash
|
class HashWithIndifferentAccess < Hash #:nodoc:
|
||||||
def initialize(constructor = {})
|
def initialize(constructor = {})
|
||||||
if constructor.is_a?(Hash)
|
if constructor.is_a?(Hash)
|
||||||
super()
|
super()
|
||||||
|
@ -122,7 +122,7 @@ class HashWithIndifferentAccess < Hash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Hash
|
class Hash #:nodoc:
|
||||||
def with_indifferent_access
|
def with_indifferent_access
|
||||||
hash = HashWithIndifferentAccess.new(self)
|
hash = HashWithIndifferentAccess.new(self)
|
||||||
hash.default = self.default
|
hash.default = self.default
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class ::Object
|
class ::Object #:nodoc:
|
||||||
def meta_class
|
def meta_class
|
||||||
class << self; self end
|
class << self; self end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class NilClass
|
class NilClass #:nodoc:
|
||||||
def to_param
|
def to_param
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require "mechanize"
|
require "mechanize"
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
class MechanizeSession < Session
|
class MechanizeSession < Session #:nodoc:
|
||||||
|
|
||||||
def initialize(mechanize = WWW::Mechanize.new)
|
def initialize(mechanize = WWW::Mechanize.new)
|
||||||
super()
|
super()
|
||||||
|
|
|
@ -8,7 +8,7 @@ require "merb-core"
|
||||||
HashWithIndifferentAccess = Mash
|
HashWithIndifferentAccess = Mash
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
class MerbSession < Session
|
class MerbSession < Session #:nodoc:
|
||||||
include Merb::Test::MakeRequest
|
include Merb::Test::MakeRequest
|
||||||
|
|
||||||
attr_accessor :response
|
attr_accessor :response
|
||||||
|
@ -54,7 +54,7 @@ end
|
||||||
|
|
||||||
module Merb
|
module Merb
|
||||||
module Test
|
module Test
|
||||||
module RequestHelper
|
module RequestHelper #:nodoc:
|
||||||
def request(uri, env = {})
|
def request(uri, env = {})
|
||||||
@session ||= Webrat::MerbSession.new
|
@session ||= Webrat::MerbSession.new
|
||||||
@session.response = @session.request(uri, env)
|
@session.response = @session.request(uri, env)
|
||||||
|
@ -67,7 +67,7 @@ module Merb
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Merb::Test::RspecStory
|
class Merb::Test::RspecStory #:nodoc:
|
||||||
def browser
|
def browser
|
||||||
@browser ||= Webrat::MerbSession.new
|
@browser ||= Webrat::MerbSession.new
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'webrat'
|
require 'webrat'
|
||||||
|
|
||||||
class CGIMethods
|
class CGIMethods #:nodoc:
|
||||||
def self.parse_query_parameters(params)
|
def self.parse_query_parameters(params)
|
||||||
hash = {}
|
hash = {}
|
||||||
params.split('&').each do |p|
|
params.split('&').each do |p|
|
||||||
|
@ -12,7 +12,7 @@ class CGIMethods
|
||||||
end
|
end
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
class RackSession < Session
|
class RackSession < Session #:nodoc:
|
||||||
def response_body
|
def response_body
|
||||||
@response.body
|
@response.body
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require "webrat"
|
require "webrat"
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
class RailsSession < Session
|
class RailsSession < Session #:nodoc:
|
||||||
|
|
||||||
def initialize(integration_session)
|
def initialize(integration_session)
|
||||||
super()
|
super()
|
||||||
|
@ -42,12 +42,12 @@ module Webrat
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def do_request(http_method, url, data, headers)
|
def do_request(http_method, url, data, headers) #:nodoc:
|
||||||
update_protocol(url)
|
update_protocol(url)
|
||||||
@integration_session.request_via_redirect(http_method, remove_protocol(url), data, headers)
|
@integration_session.request_via_redirect(http_method, remove_protocol(url), data, headers)
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_protocol(href)
|
def remove_protocol(href) #:nodoc:
|
||||||
if href =~ %r{^https?://www.example.com(/.*)}
|
if href =~ %r{^https?://www.example.com(/.*)}
|
||||||
$LAST_MATCH_INFO.captures.first
|
$LAST_MATCH_INFO.captures.first
|
||||||
else
|
else
|
||||||
|
@ -55,7 +55,7 @@ module Webrat
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_protocol(href)
|
def update_protocol(href) #:nodoc:
|
||||||
if href =~ /^https:/
|
if href =~ /^https:/
|
||||||
@integration_session.https!(true)
|
@integration_session.https!(true)
|
||||||
elsif href =~ /^http:/
|
elsif href =~ /^http:/
|
||||||
|
@ -63,7 +63,7 @@ module Webrat
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def response
|
def response #:nodoc:
|
||||||
@integration_session.response
|
@integration_session.response
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ end
|
||||||
|
|
||||||
module ActionController
|
module ActionController
|
||||||
module Integration
|
module Integration
|
||||||
class Session
|
class Session #:nodoc:
|
||||||
|
|
||||||
unless instance_methods.include?("put_via_redirect")
|
unless instance_methods.include?("put_via_redirect")
|
||||||
require "webrat/rails/redirect_actions"
|
require "webrat/rails/redirect_actions"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# For Rails before http://dev.rubyonrails.org/ticket/10497 was committed
|
# For Rails before http://dev.rubyonrails.org/ticket/10497 was committed
|
||||||
module Webrat
|
module Webrat
|
||||||
module RedirectActions
|
module RedirectActions #:nodoc:
|
||||||
|
|
||||||
def put_via_redirect(path, parameters = {}, headers = {})
|
def put_via_redirect(path, parameters = {}, headers = {})
|
||||||
put path, parameters, headers
|
put path, parameters, headers
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Webrat
|
module Webrat
|
||||||
class SeleniumSession
|
class SeleniumSession
|
||||||
|
|
||||||
def initialize(selenium_driver)
|
def initialize(selenium_driver) #:nodoc:
|
||||||
@selenium = selenium_driver
|
@selenium = selenium_driver
|
||||||
extend_selenium
|
extend_selenium
|
||||||
define_location_strategies
|
define_location_strategies
|
||||||
|
@ -20,7 +20,7 @@ module Webrat
|
||||||
|
|
||||||
alias_method :fills_in, :fill_in
|
alias_method :fills_in, :fill_in
|
||||||
|
|
||||||
def response_body
|
def response_body #:nodoc:
|
||||||
@selenium.get_html_source
|
@selenium.get_html_source
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -102,17 +102,17 @@ module Webrat
|
||||||
|
|
||||||
alias_method :checks, :check
|
alias_method :checks, :check
|
||||||
|
|
||||||
def is_ordered(*args)
|
def is_ordered(*args) #:nodoc:
|
||||||
@selenium.is_ordered(*args)
|
@selenium.is_ordered(*args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def dragdrop(*args)
|
def dragdrop(*args) #:nodoc:
|
||||||
@selenium.dragdrop(*args)
|
@selenium.dragdrop(*args)
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def adjust_if_regexp(text_or_regexp)
|
def adjust_if_regexp(text_or_regexp) #:nodoc:
|
||||||
if text_or_regexp.is_a?(Regexp)
|
if text_or_regexp.is_a?(Regexp)
|
||||||
"evalregex:#{text_or_regexp.inspect}"
|
"evalregex:#{text_or_regexp.inspect}"
|
||||||
else
|
else
|
||||||
|
@ -120,13 +120,13 @@ module Webrat
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def extend_selenium
|
def extend_selenium #:nodoc:
|
||||||
extensions_file = File.join(File.dirname(__FILE__), "selenium_extensions.js")
|
extensions_file = File.join(File.dirname(__FILE__), "selenium_extensions.js")
|
||||||
extenions_js = File.read(extensions_file)
|
extenions_js = File.read(extensions_file)
|
||||||
@selenium.get_eval(extenions_js)
|
@selenium.get_eval(extenions_js)
|
||||||
end
|
end
|
||||||
|
|
||||||
def define_location_strategies
|
def define_location_strategies #:nodoc:
|
||||||
Dir[File.join(File.dirname(__FILE__), "location_strategy_javascript", "*.js")].sort.each do |file|
|
Dir[File.join(File.dirname(__FILE__), "location_strategy_javascript", "*.js")].sort.each do |file|
|
||||||
strategy_js = File.read(file)
|
strategy_js = File.read(file)
|
||||||
strategy_name = File.basename(file, '.js')
|
strategy_name = File.basename(file, '.js')
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'sinatra'
|
||||||
require 'sinatra/test/methods'
|
require 'sinatra/test/methods'
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
class SinatraSession < RackSession
|
class SinatraSession < RackSession #:nodoc:
|
||||||
include Sinatra::Test::Methods
|
include Sinatra::Test::Methods
|
||||||
|
|
||||||
%w(get head post put delete).each do |verb|
|
%w(get head post put delete).each do |verb|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
require File.expand_path(File.dirname(__FILE__) + '/helper')
|
||||||
|
|
||||||
describe "attaches_file" do
|
describe "attach_file" do
|
||||||
before do
|
before do
|
||||||
@session = Webrat::TestSession.new
|
@session = Webrat::TestSession.new
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ describe "attaches_file" do
|
||||||
<form method="post" action="/widgets">
|
<form method="post" action="/widgets">
|
||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
lambda { @session.attaches_file("Doc", "/some/path") }.should raise_error
|
lambda { @session.attach_file("Doc", "/some/path") }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should submit empty strings for blank file fields" do
|
it "should submit empty strings for blank file fields" do
|
||||||
|
@ -37,7 +37,7 @@ describe "attaches_file" do
|
||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/widgets", { "widget" => { "file" => @uploaded_file } })
|
@session.should_receive(:post).with("/widgets", { "widget" => { "file" => @uploaded_file } })
|
||||||
@session.attaches_file "Document", @filename
|
@session.attach_file "Document", @filename
|
||||||
@session.click_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ describe "attaches_file" do
|
||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
@session.should_receive(:post).with("/widgets", { "widget" => { "files" => [@uploaded_file, @uploaded_file] } })
|
@session.should_receive(:post).with("/widgets", { "widget" => { "files" => [@uploaded_file, @uploaded_file] } })
|
||||||
@session.attaches_file "Document", @filename
|
@session.attach_file "Document", @filename
|
||||||
@session.attaches_file "Spreadsheet", @filename
|
@session.attach_file "Spreadsheet", @filename
|
||||||
@session.click_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ describe "attaches_file" do
|
||||||
</form>
|
</form>
|
||||||
EOS
|
EOS
|
||||||
ActionController::TestUploadedFile.should_receive(:new).with(@filename, "image/png").any_number_of_times
|
ActionController::TestUploadedFile.should_receive(:new).with(@filename, "image/png").any_number_of_times
|
||||||
@session.attaches_file "Picture", @filename, "image/png"
|
@session.attach_file "Picture", @filename, "image/png"
|
||||||
@session.click_button
|
@session.click_button
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue