From 2d166ae2b83d9482af3d54bac855b69233ad00f8 Mon Sep 17 00:00:00 2001 From: Derek Kastner Date: Tue, 21 Oct 2008 21:33:49 -0400 Subject: [PATCH] fixed Webrat::MechanizeSession - calling visit on a newly created session was failing. Default headers were not set and Webrat::Session#request_page would fail when Webrat::Session#headers was called - dup was being called on the nil headers --- lib/webrat/mechanize/mechanize_session.rb | 1 + spec/webrat/mechanize/mechanize_session_spec.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 spec/webrat/mechanize/mechanize_session_spec.rb diff --git a/lib/webrat/mechanize/mechanize_session.rb b/lib/webrat/mechanize/mechanize_session.rb index 2f48c17..7a817c4 100644 --- a/lib/webrat/mechanize/mechanize_session.rb +++ b/lib/webrat/mechanize/mechanize_session.rb @@ -2,6 +2,7 @@ module Webrat class MechanizeSession < Session def initialize(mechanize = WWW::Mechanize.new) + super() @mechanize = mechanize end diff --git a/spec/webrat/mechanize/mechanize_session_spec.rb b/spec/webrat/mechanize/mechanize_session_spec.rb new file mode 100644 index 0000000..f69dad2 --- /dev/null +++ b/spec/webrat/mechanize/mechanize_session_spec.rb @@ -0,0 +1,13 @@ +require File.expand_path(File.dirname(__FILE__) + "/../../../lib/webrat/mechanize") + +describe Webrat::MechanizeSession do + before(:each) do + @mech = Webrat::MechanizeSession.new + end + + describe "headers method" do + it "should return empty headers for a newly initialized session" do + @mech.headers.should == {} + end + end +end \ No newline at end of file