From f8af783185313faf6cda7fa16e63675e354c4df1 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Sun, 14 Jun 2009 22:03:49 -0400 Subject: [PATCH] Add spec for needing to ensure Fixnum#/ return an integer in redirect checking --- spec/private/core/session_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/private/core/session_spec.rb b/spec/private/core/session_spec.rb index f53af09..39f4a1c 100644 --- a/spec/private/core/session_spec.rb +++ b/spec/private/core/session_spec.rb @@ -106,6 +106,24 @@ describe Webrat::Session do webrat_session = Webrat::Session.new 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 webrat_session.stub!(:response_code => 301) webrat_session.redirect?.should be_true