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