<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/boot_merb.rb</filename>
    </added>
    <added>
      <filename>lib/boot_rails.rb</filename>
    </added>
    <added>
      <filename>lib/merb_support/indifferent_access.rb</filename>
    </added>
    <added>
      <filename>lib/merb_support/param_parser.rb</filename>
    </added>
    <added>
      <filename>lib/merb_support/support.rb</filename>
    </added>
    <added>
      <filename>lib/merb_support/url_encoded_pair_parser.rb</filename>
    </added>
    <added>
      <filename>test/helper_merb.rb</filename>
    </added>
    <added>
      <filename>test/helper_rails.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -65,7 +65,10 @@ A test written with Webrat can handle these changes to these without any modific
 Install
 -------
 
-To install the latest release:
+* Rails &gt;= 1.2.6 or Merb edge
+* Hpricot &gt;= 0.6
+* Rails integration tests in Test::Unit _or_
+* RSpec stories (using an RSpec version &gt;= revision 2997)
 
     sudo gem install webrat
 
@@ -75,6 +78,13 @@ In your stories/helper.rb:
   
 You could also unpack the gem into vendor/plugins.
 
+To avoid losing sessions, you need this in environments/test.rb:
+
+Merb::Config.use do |c|
+  c[:session_store] = 'memory' 
+end  
+
+== HISTORY:
 Requirements
 ------------
 </diff>
      <filename>README.txt</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,8 @@
 module Webrat
-  VERSION = '0.2.1'
+  VERSION = '0.2.2'
+  def self.root
+    defined?(RAILS_ROOT) ? RAILS_ROOT : Merb.root
+  end
 end
 
 require &quot;rubygems&quot;
@@ -7,3 +10,9 @@ require &quot;active_support&quot;
 
 require File.dirname(__FILE__) + &quot;/webrat/core&quot;
 require File.dirname(__FILE__) + &quot;/webrat/rails&quot; if defined?(RAILS_ENV)
+
+if defined?(Merb)
+  require File.join(File.dirname(__FILE__), &quot;boot_merb.rb&quot;)
+else
+  require File.join(File.dirname(__FILE__), &quot;boot_rails.rb&quot;)
+end</diff>
      <filename>lib/webrat.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,18 +3,17 @@ module Webrat
     
     def self.class_for_element(element)
       if element.name == &quot;input&quot;
-        if %w[submit image].include?(element[&quot;type&quot;])
+        if %w[submit image button].include?(element[&quot;type&quot;])
           field_class = &quot;button&quot;
         else
-          field_class = element[&quot;type&quot;] || &quot;text&quot;
+          field_class = element[&quot;type&quot;] || &quot;text&quot; #default type; 'type' attribute is not mandatory
         end
       else
         field_class = element.name
       end
-      
       Webrat.const_get(&quot;#{field_class.capitalize}Field&quot;)
-    rescue NameError
-      raise &quot;Invalid field element: #{element.inspect}&quot;
+    #rescue NameError
+    #  raise &quot;Invalid field element: #{element.inspect}&quot;
     end
     
     def initialize(form, element)
@@ -108,10 +107,10 @@ module Webrat
     def param_parser
       if defined?(CGIMethods)
         CGIMethods
-      else
-        require &quot;action_controller&quot;
-        require &quot;action_controller/integration&quot;
+      elsif defined?(ActionController::AbstractRequest)
         ActionController::AbstractRequest
+      else
+        Webrat::ParamParser #used for Merb
       end
     end
     
@@ -141,6 +140,14 @@ module Webrat
     def matches_value?(value)
       @element[&quot;value&quot;] =~ /^\W*#{Regexp.escape(value.to_s)}/i || matches_text?(value) || matches_alt?(value)
     end
+    
+    def matches_id?(id)
+      @element[&quot;id&quot;] =~ /^\W*#{Regexp.escape(id.to_s)}/i
+    end
+    
+    def matches_caption?(value)
+      @element.innerHTML =~ /^\W*#{Regexp.escape(value.to_s)}/i
+    end
 
     def to_param
       return nil if @value.nil?</diff>
      <filename>lib/webrat/core/field.rb</filename>
    </modified>
    <modified>
      <diff>@@ -34,9 +34,18 @@ module Webrat
       possible_buttons = fields_by_type([ButtonField])
       
       possible_buttons.each do |possible_button|
+        return possible_button if possible_button.matches_id?(value)
+      end
+      
+      possible_buttons.each do |possible_button|
         return possible_button if possible_button.matches_value?(value)
       end
       
+      #If nothing matched on value, try by name. 
+      possible_buttons.each do |possible_button|
+        return possible_button if possible_button.matches_caption?(value)
+      end
+      
       nil
     end
 
@@ -45,7 +54,7 @@ module Webrat
       
       @fields = []
       
-      (@element / &quot;button, input, textarea, select&quot;).each do |field_element|
+      (@element / &quot;input, textarea, select, button&quot;).each do |field_element|
         @fields &lt;&lt; Field.class_for_element(field_element).new(self, field_element)
       end
       
@@ -123,7 +132,7 @@ module Webrat
     def merge_hash_values(a, b) # :nodoc:
       a.keys.each do |k|
         if b.has_key?(k)
-          case [a[k], b[k]].map(&amp;:class)
+          case [a[k].class, b[k].class]
           when [Hash, Hash]
             a[k] = merge_hash_values(a[k], b[k])
             b.delete(k)</diff>
      <filename>lib/webrat/core/form.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,12 +3,14 @@ module Webrat
     
     def debug_log(message) # :nodoc:
       return unless logger
-      logger.debug(message)
+      logger.debug message
     end
 
     def logger # :nodoc:
       if defined? RAILS_DEFAULT_LOGGER
         RAILS_DEFAULT_LOGGER
+      elsif defined? Merb
+        Merb.logger
       else
         nil
       end</diff>
      <filename>lib/webrat/core/logging.rb</filename>
    </modified>
    <modified>
      <diff>@@ -82,10 +82,22 @@ module Webrat
     # along with the form. An optional &lt;tt&gt;content_type&lt;/tt&gt; may be given.
     #
     # Example:
+&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD:lib/webrat/core/scope.rb
     #   attaches_file &quot;Resume&quot;, &quot;/path/to/the/resume.txt&quot;
     #   attaches_file &quot;Photo&quot;, &quot;/path/to/the/image.png&quot;, &quot;image/png&quot;
     def attaches_file(id_or_name_or_label, path, content_type = nil)
       find_field(id_or_name_or_label, FileField).set(path, content_type)
+=======
+    #   save_and_open
+    def save_and_open
+      return unless File.exist?(Webrat.root + &quot;/tmp&quot;)
+
+      filename = &quot;webrat-#{Time.now.to_i}.html&quot;
+      File.open(Webrat.root + &quot;/tmp/#{filename}&quot;, &quot;w&quot;) do |f|
+        f.write response.body
+      end
+      `open tmp/#{filename}`
+&gt;&gt;&gt;&gt;&gt;&gt;&gt; 300880db2f0d50a3e2d7b171eb9745cb50e1c534:lib/webrat/page.rb
     end
 
     alias_method :attach_file, :attaches_file</diff>
      <filename>lib/webrat/core/scope.rb</filename>
    </modified>
    <modified>
      <diff>@@ -144,6 +144,18 @@ describe &quot;fills_in&quot; do
     @session.fills_in &quot;user[email]&quot;, :with =&gt; &quot;foo@example.com&quot;
     @session.clicks_button
   end
+
+  def test_should_work_without_input_type
+    @response.stubs(:body).returns(&lt;&lt;-EOS)
+      &lt;form method=&quot;post&quot; action=&quot;/login&quot;&gt;
+        &lt;input id=&quot;user_email&quot; name=&quot;user[email]&quot;  /&gt;
+        &lt;input type=&quot;submit&quot; /&gt;
+      &lt;/form&gt;
+    EOS
+    @session.expects(:post_via_redirect).with(&quot;/login&quot;, &quot;user&quot; =&gt; {&quot;email&quot; =&gt; &quot;foo@example.com&quot;})
+    @session.fills_in &quot;user[email]&quot;, :with =&gt; &quot;foo@example.com&quot;
+    @session.clicks_button
+  end
   
   it &quot;should work with symbols&quot; do
     @session.response_body = &lt;&lt;-EOS</diff>
      <filename>spec/api/fills_in_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,13 +4,12 @@ require &quot;spec&quot;
 # gem install redgreen for colored test output
 begin require &quot;redgreen&quot; unless ENV['TM_CURRENT_LINE']; rescue LoadError; end
 
-require &quot;active_support&quot;
-
-silence_warnings do
-  require &quot;action_controller&quot;
-  require &quot;action_controller/integration&quot;
+if [&quot;rails&quot;,&quot;merb&quot;].include?(ENV[&quot;TEST_MODE&quot;])
+  require File.join(File.dirname(__FILE__), &quot;helper_#{ENV[&quot;TEST_MODE&quot;]}.rb&quot;)
+else
+  raise &quot;Please set the environment variable TEST_MODE to either 'rails' or 'merb'.&quot;
 end
-
+  
 require File.expand_path(File.dirname(__FILE__) + &quot;/../lib/webrat&quot;)
 require File.expand_path(File.dirname(__FILE__) + &quot;/../lib/webrat/rails&quot;)
 require File.dirname(__FILE__) + &quot;/fakes/test_session&quot;</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>33fdf33c899c731cbae885547264c3966f9a4b82</id>
    </parent>
    <parent>
      <id>300880db2f0d50a3e2d7b171eb9745cb50e1c534</id>
    </parent>
  </parents>
  <author>
    <name>Rob Kaufman</name>
    <email>rob@notch8.com</email>
  </author>
  <url>http://github.com/brynary/webrat/commit/dbb3883d2708879c2e0364914a47beb77a5e5a3c</url>
  <id>dbb3883d2708879c2e0364914a47beb77a5e5a3c</id>
  <committed-date>2008-10-11T12:53:13-07:00</committed-date>
  <authored-date>2008-10-11T12:53:13-07:00</authored-date>
  <message>merged jrun and gwynms merb changes into main webrat code</message>
  <tree>b691d42c55b6bc761641d2073a02b4dff1667d41</tree>
  <committer>
    <name>Rob Kaufman</name>
    <email>rob@notch8.com</email>
  </committer>
</commit>
