Remove warnings [#372 state:resolved].

On why this is important:
http://eigenclass.org/hiki/ruby-warnings-SEX-and-stds
This commit is contained in:
Damian Janowski 2010-04-12 22:21:59 -03:00
parent fd944cccb5
commit 19fc2ccb89
5 changed files with 6 additions and 22 deletions

View File

@ -8,8 +8,8 @@ module Webrat #:nodoc:
def mime_type(type) def mime_type(type)
return type if type.nil? || type.to_s.include?("/") return type if type.nil? || type.to_s.include?("/")
type = ".#{type}" unless type.to_s[0] == ?. type = ".#{type}" unless type.to_s[0] == ?.
MIME_TYPES.fetch(type) { |type| MIME_TYPES.fetch(type) { |invalid_type|
raise ArgumentError.new("Invalid Mime type: #{type}") raise ArgumentError.new("Invalid Mime type: #{invalid_type}")
} }
end end

View File

@ -28,6 +28,7 @@ module Webrat
attr_reader :session attr_reader :session
def initialize(session, &block) #:nodoc: def initialize(session, &block) #:nodoc:
@selector, @dom = nil
@session = session @session = session
instance_eval(&block) if block_given? instance_eval(&block) if block_given?

View File

@ -75,6 +75,7 @@ For example:
@data = {} @data = {}
@default_headers = {} @default_headers = {}
@custom_headers = {} @custom_headers = {}
@current_url = nil
reset reset
end end
@ -155,7 +156,7 @@ For example:
end end
def redirect? #:nodoc: def redirect? #:nodoc:
response_code != 304 && (response_code / 100).to_i == 3 [301, 302, 303, 307].include?(response_code)
end end
def internal_redirect? def internal_redirect?

View File

@ -15,7 +15,7 @@ module Webrat #:nodoc:
end end
def response_code def response_code
@response_code || 200 @response_code ||= 200
end end
def get(url, data, headers = nil) def get(url, data, headers = nil)

View File

@ -106,24 +106,6 @@ describe Webrat::Session do
webrat_session = Webrat::Session.new webrat_session = Webrat::Session.new
end end
it "should return true if the last response was a redirect and Fixnum#/ returns a Rational" do
# This happens if the ruby-units gem has been required
Fixnum.class_eval do
alias_method :original_divide, "/".to_sym
def /(other)
Rational(self, other)
end
end
webrat_session.stub!(:response_code => 301)
webrat_session.redirect?.should be_true
Fixnum.class_eval do
alias_method "/".to_sym, :original_divide
end
end
it "should return true if the last response was a redirect" do it "should return true if the last response was a redirect" do
webrat_session.stub!(:response_code => 301) webrat_session.stub!(:response_code => 301)
webrat_session.redirect?.should be_true webrat_session.redirect?.should be_true