<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/sessions/new.html.erb</filename>
    </added>
    <added>
      <filename>app/views/users/_user_bar.html.erb</filename>
    </added>
    <added>
      <filename>app/views/users/new.html.erb</filename>
    </added>
    <added>
      <filename>config/initializers/site_keys.rb</filename>
    </added>
    <added>
      <filename>lib/authenticated_test_helper.rb</filename>
    </added>
    <added>
      <filename>script/autospec</filename>
    </added>
    <added>
      <filename>script/dbconsole</filename>
    </added>
    <added>
      <filename>spec/fixtures/users.yml</filename>
    </added>
    <added>
      <filename>spec/helpers/users_helper_spec.rb</filename>
    </added>
    <added>
      <filename>stories/all.rb</filename>
    </added>
    <added>
      <filename>stories/helper.rb</filename>
    </added>
    <added>
      <filename>stories/rest_auth_stories.rb</filename>
    </added>
    <added>
      <filename>stories/rest_auth_stories_helper.rb</filename>
    </added>
    <added>
      <filename>stories/steps/ra_navigation_steps.rb</filename>
    </added>
    <added>
      <filename>stories/steps/ra_resource_steps.rb</filename>
    </added>
    <added>
      <filename>stories/steps/ra_response_steps.rb</filename>
    </added>
    <added>
      <filename>stories/steps/user_steps.rb</filename>
    </added>
    <added>
      <filename>stories/users/accounts.story</filename>
    </added>
    <added>
      <filename>stories/users/sessions.story</filename>
    </added>
    <added>
      <filename>vendor/plugins/model_stubbing/init.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/.gitignore</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/CHANGELOG</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/README.textile</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/TODO</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/lib/insert_routes.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/_model_partial.html.erb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/activation.erb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/login.html.erb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/model_helper_spec.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/signup.html.erb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/signup_notification.erb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/site_keys.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/access_control_spec.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/authenticated_system_spec.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/sessions_controller_spec.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/spec/controllers/users_controller_spec.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/spec/fixtures/users.yml</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/spec/helpers/users_helper_spec.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/spec/models/user_spec.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/stories/rest_auth_stories.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/stories/rest_auth_stories_helper.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_resource_steps.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_response_steps.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/user_steps.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/stories/users/accounts.story</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/stories/users/sessions.story</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/test/functional_test.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/test/mailer_test.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/test/model_functional_test.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/test/unit_test.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/init.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/lib/authentication.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/lib/authentication/by_cookie_token.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/lib/authentication/by_password.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/lib/authorization.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/lib/authorization/aasm_roles.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/lib/authorization/stateful_roles.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/lib/trustification.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/lib/trustification/email_validation.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/notes/AccessControl.txt</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/notes/Authentication.txt</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/notes/Authorization.txt</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/notes/RailsPlugins.txt</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/notes/SecurityFramework.graffle</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/notes/SecurityFramework.png</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/notes/SecurityPatterns.txt</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/notes/Tradeoffs.txt</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/notes/Trustification.txt</filename>
    </added>
    <added>
      <filename>vendor/plugins/restful_authentication/tasks/auth.rake</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec-rails/generators/rspec/templates/script/autospec</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec-rails/generators/rspec_default_values.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec-rails/lib/spec/rails/interop/testcase.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec-rails/spec/rails/matchers/render_template_spec.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec-rails/spec_resources/views/layouts/application.rhtml</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec-rails/spec_resources/views/layouts/simple.rhtml</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec-rails/spec_resources/views/objects/_object.html.erb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec-rails/spec_resources/views/render_spec/action_with_alternate_layout.rhtml</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec-rails/spec_resources/views/view_spec/block_helper.rhtml</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec-rails/spec_resources/views/view_spec/should_not_receive.rhtml</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec/examples/pure/yielding_example.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec/lib/spec/runner/formatter/story/progress_bar_formatter.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec/spec/spec/example/base_formatter_spec.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec/spec/spec/mocks/bug_report_496.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/rspec/spec/spec/runner/formatter/story/progress_bar_formatter_spec.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/.gitignore</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/.manifest</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/CHANGELOG.rdoc</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/README.rdoc</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/examples/apple-circle.gif</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/examples/index.haml</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/examples/index.html</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/examples/pagination.css</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/examples/pagination.sass</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/lib/will_paginate/array.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/lib/will_paginate/version.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/test/collection_test.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/test/database.yml</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/test/lib/view_test_process.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/test/tasks.rake</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/test/view_test.rb</filename>
    </added>
    <added>
      <filename>vendor/plugins/will_paginate/will_paginate.gemspec</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -6,7 +6,7 @@ module ApplicationHelper
   end
 
   def pagination(collection)
-    if collection.page_count &gt; 1
+    if collection.total_entries &gt; 1
       &quot;&lt;p class='pages'&gt;&quot; + 'Pages'[:pages_title] + &quot;: &lt;strong&gt;&quot; + 
       will_paginate(collection, :inner_window =&gt; 10, :next_label =&gt; &quot;next&quot;[], :prev_label =&gt; &quot;previous&quot;[]) +
       &quot;&lt;/strong&gt;&lt;/p&gt;&quot;
@@ -14,7 +14,7 @@ module ApplicationHelper
   end
   
   def next_page(collection)
-    unless collection.current_page == collection.page_count or collection.page_count == 0
+    unless collection.current_page == collection.total_entries or collection.total_entries == 0
       &quot;&lt;p style='float:right;'&gt;&quot; + link_to(&quot;Next page&quot;[], { :page =&gt; collection.current_page.next }.merge(params.reject{|k,v| k==&quot;page&quot;})) + &quot;&lt;/p&gt;&quot;
     end
   end</diff>
      <filename>app/helpers/application_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,15 +1,104 @@
 module UsersHelper
-
   def user_count
     pluralize current_site.users.size, 'user'[:user]
   end
-  
+
   def active_user_count
     pluralize current_site.users.count('users.posts_count &gt; 0'), 'active user'[:active_user]
   end
-  
+
   def lurking_user_count
     pluralize current_site.users.count('users.posts_count = 0'), 'lurking user'[:lurking_user]
   end
+  
+  #
+  # Use this to wrap view elements that the user can't access.
+  # !! Note: this is an *interface*, not *security* feature !!
+  # You need to do all access control at the controller level.
+  #
+  # Example:
+  # &lt;%= if_authorized?(:index,   User)  do link_to('List all users', users_path) end %&gt; |
+  # &lt;%= if_authorized?(:edit,    @user) do link_to('Edit this user', edit_user_path) end %&gt; |
+  # &lt;%= if_authorized?(:destroy, @user) do link_to 'Destroy', @user, :confirm =&gt; 'Are you sure?', :method =&gt; :delete end %&gt; 
+  #
+  #
+  def if_authorized?(action, resource, &amp;block)
+    if authorized?(action, resource)
+      yield action, resource
+    end
+  end
+
+  #
+  # Link to user's page ('users/1')
+  #
+  # By default, their login is used as link text and link title (tooltip)
+  #
+  # Takes options
+  # * :content_text =&gt; 'Content text in place of user.login', escaped with
+  #   the standard h() function.
+  # * :content_method =&gt; :user_instance_method_to_call_for_content_text
+  # * :title_method =&gt; :user_instance_method_to_call_for_title_attribute
+  # * as well as link_to()'s standard options
+  #
+  # Examples:
+  #   link_to_user @user
+  #   # =&gt; &lt;a href=&quot;/users/3&quot; title=&quot;barmy&quot;&gt;barmy&lt;/a&gt;
+  #
+  #   # if you've added a .name attribute:
+  #  content_tag :span, :class =&gt; :vcard do
+  #    (link_to_user user, :class =&gt; 'fn n', :title_method =&gt; :login, :content_method =&gt; :name) +
+  #          ': ' + (content_tag :span, user.email, :class =&gt; 'email')
+  #   end
+  #   # =&gt; &lt;span class=&quot;vcard&quot;&gt;&lt;a href=&quot;/users/3&quot; title=&quot;barmy&quot; class=&quot;fn n&quot;&gt;Cyril Fotheringay-Phipps&lt;/a&gt;: &lt;span class=&quot;email&quot;&gt;barmy@blandings.com&lt;/span&gt;&lt;/span&gt;
+  #
+  #   link_to_user @user, :content_text =&gt; 'Your user page'
+  #   # =&gt; &lt;a href=&quot;/users/3&quot; title=&quot;barmy&quot; class=&quot;nickname&quot;&gt;Your user page&lt;/a&gt;
+  #
+  def link_to_user(user, options={})
+    raise &quot;Invalid user&quot; unless user
+    options.reverse_merge! :content_method =&gt; :login, :title_method =&gt; :login, :class =&gt; :nickname
+    content_text      = options.delete(:content_text)
+    content_text    ||= user.send(options.delete(:content_method))
+    options[:title] ||= user.send(options.delete(:title_method))
+    link_to h(content_text), user_path(user), options
+  end
+
+  #
+  # Link to login page using remote ip address as link content
+  #
+  # The :title (and thus, tooltip) is set to the IP address 
+  #
+  # Examples:
+  #   link_to_login_with_IP
+  #   # =&gt; &lt;a href=&quot;/login&quot; title=&quot;169.69.69.69&quot;&gt;169.69.69.69&lt;/a&gt;
+  #
+  #   link_to_login_with_IP :content_text =&gt; 'not signed in'
+  #   # =&gt; &lt;a href=&quot;/login&quot; title=&quot;169.69.69.69&quot;&gt;not signed in&lt;/a&gt;
+  #
+  def link_to_login_with_IP content_text=nil, options={}
+    ip_addr           = request.remote_ip
+    content_text    ||= ip_addr
+    options.reverse_merge! :title =&gt; ip_addr
+    if tag = options.delete(:tag)
+      content_tag tag, h(content_text), options
+    else
+      link_to h(content_text), login_path, options
+    end
+  end
+
+  #
+  # Link to the current user's page (using link_to_user) or to the login page
+  # (using link_to_login_with_IP).
+  #
+  def link_to_current_user(options={})
+    if current_user
+      link_to_user current_user, options
+    else
+      content_text = options.delete(:content_text) || 'not signed in'
+      # kill ignored options from link_to_user
+      [:content_method, :title_method].each{|opt| options.delete(opt)} 
+      link_to_login_with_IP content_text, options
+    end
+  end
 
-end
\ No newline at end of file
+end</diff>
      <filename>app/helpers/users_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,8 @@
 class User &lt; ActiveRecord::Base
+  #include Authentication
+ # include Authentication::ByPassword
+ # include Authentication::ByCookieToken
+  
   concerned_with :validation, :states, :activation, :posting
   formats_attributes :bio
 </diff>
      <filename>app/models/user.rb</filename>
    </modified>
    <modified>
      <diff>@@ -35,11 +35,11 @@
   &lt;%= '{count} post(s)'[(count=@forum.posts.size)==1 ? :post_count : :posts_count, number_with_delimiter(count)] %&gt;
 &lt;/p&gt;
 
-&lt;% if @topics.page_count &gt; 1 -%&gt;
+&lt;% if @topics.total_entries &gt; 1 -%&gt;
 &lt;% if logged_in? %&gt;
 &lt;p style=&quot;float:right; margin-top:0;&quot;&gt;&lt;%= link_to 'New topic'[], new_topic_path(@forum), :class =&gt; &quot;utility&quot; %&gt;&lt;/p&gt;
 &lt;% end %&gt;
-&lt;%= pagination @topics %&gt;
+&lt;%= will_paginate @topics %&gt;
 &lt;% end -%&gt;
 
 &lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;wide topics&quot;&gt;
@@ -88,8 +88,7 @@
 &lt;% end %&gt;
 &lt;/table&gt;
 
-&lt;%= next_page @topics %&gt;
-&lt;%= pagination @topics %&gt;
+&lt;%= will_paginate @topics %&gt;
 
 &lt;% if logged_in? %&gt;
 &lt;p&gt;&lt;%= link_to 'New topic'[:new_topic], new_forum_topic_path(@forum), :class =&gt; &quot;utility&quot; %&gt;&lt;/p&gt;</diff>
      <filename>app/views/forums/show.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -24,9 +24,8 @@ module Rails
       File.exist?(&quot;#{RAILS_ROOT}/vendor/rails&quot;)
     end
 
-    # FIXME : Ruby 1.9
     def preinitialize
-      load(preinitializer_path) if File.exists?(preinitializer_path)
+      load(preinitializer_path) if File.exist?(preinitializer_path)
     end
 
     def preinitializer_path
@@ -44,6 +43,7 @@ module Rails
   class VendorBoot &lt; Boot
     def load_initializer
       require &quot;#{RAILS_ROOT}/vendor/rails/railties/lib/initializer&quot;
+      Rails::Initializer.run(:install_gem_spec_stubs)
     end
   end
 
@@ -82,14 +82,14 @@ module Rails
 
       def load_rubygems
         require 'rubygems'
-
-        unless rubygems_version &gt;= '0.9.4'
-          $stderr.puts %(Rails requires RubyGems &gt;= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
+        min_version = '1.1.1'
+        unless rubygems_version &gt;= min_version
+          $stderr.puts %Q(Rails requires RubyGems &gt;= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
           exit 1
         end
 
       rescue LoadError
-        $stderr.puts %(Rails requires RubyGems &gt;= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
+        $stderr.puts %Q(Rails requires RubyGems &gt;= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
         exit 1
       end
 </diff>
      <filename>config/boot.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@
 # ENV['RAILS_ENV'] ||= 'production'
 
 # Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION
+RAILS_GEM_VERSION = '2.1.1' unless defined? RAILS_GEM_VERSION
 
 # Bootstrap the Rails environment, frameworks, and default configuration
 require File.join(File.dirname(__FILE__), 'boot')</diff>
      <filename>config/environment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,7 +12,6 @@ config.whiny_nils = true
 config.action_controller.consider_all_requests_local = true
 config.action_view.debug_rjs                         = true
 config.action_controller.perform_caching             = false
-config.action_view.cache_template_extensions         = false
 
 # Don't care if the mailer can't send
 config.action_mailer.raise_delivery_errors = false
\ No newline at end of file</diff>
      <filename>config/environments/development.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,6 @@
 ActionController::Routing::Routes.draw do |map|
+  map.resource :session
+
   map.resources :sites, :moderatorships
 
   map.resources :forums, :has_many =&gt; :posts do |forum|</diff>
      <filename>config/routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 # This file is auto-generated from the current state of the database. Instead of editing this file, 
-# please use the migrations feature of ActiveRecord to incrementally modify your database, and
+# please use the migrations feature of Active Record to incrementally modify your database, and
 # then regenerate this schema definition.
 #
 # Note that this schema.rb definition is the authoritative source for your database schema. If you need</diff>
      <filename>db/schema.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,36 +3,37 @@ module AuthenticatedSystem
     def current_site
       @current_site ||= Site.find_by_host(request.host) or raise Site::UndefinedError
     end
-    
+  
     # Returns true or false if the user is logged in.
     # Preloads @current_user with the user model if they're logged in.
     def logged_in?
-      current_user != :false
+      !!current_user
     end
-    
-    # Accesses the current user from the session.  Set it to :false if login fails
-    # so that future calls do not hit the database.
+
+    # Accesses the current user from the session.
+    # Future calls avoid the database because nil is not equal to false.
     def current_user
-      @current_user ||= (login_from_session || login_from_basic_auth || login_from_cookie || :false)
+      @current_user ||= (login_from_session || login_from_basic_auth || login_from_cookie) unless @current_user == false
     end
-    
-    # Store the given user in the session.
+
+    # Store the given user id in the session.
     def current_user=(new_user)
-      session[:user] = (new_user.nil? || new_user.is_a?(Symbol)) ? nil : new_user.id
-      @current_user = new_user
+      session[:user_id] = new_user ? new_user.id : nil
+      @current_user = new_user || false
     end
-    
+
     def admin?
       logged_in? &amp;&amp; current_user.admin?
     end
     
     def moderator_of?(record)
-      return true  if admin?
+      return true if admin?
       return false unless logged_in?
       forum = record.respond_to?(:forum) ? record.forum : record
       current_user.moderator_of? forum
     end
-    
+
+
     # Check if the user is authorized
     #
     # Override this method in your controllers if you want to restrict access
@@ -45,8 +46,9 @@ module AuthenticatedSystem
     #  def authorized?
     #    current_user.login != &quot;bob&quot;
     #  end
-    def authorized?
-      true
+    #
+    def authorized?(action = action_name, resource = nil)
+      logged_in?
     end
 
     # Filter method to enforce a login requirement.
@@ -64,9 +66,9 @@ module AuthenticatedSystem
     #   skip_before_filter :login_required
     #
     def login_required
-      (logged_in? &amp;&amp; authorized?) || access_denied
+      authorized? || access_denied
     end
-    
+
     def admin_required
       admin? || access_denied
     end
@@ -80,67 +82,128 @@ module AuthenticatedSystem
     # to access the requested action.  For example, a popup window might
     # simply close itself.
     def access_denied
-      respond_to do |accepts|
-        accepts.html do
+      respond_to do |format|
+        format.html do
           store_location
-          redirect_to :controller =&gt; '/sessions', :action =&gt; 'new'
+          redirect_to new_session_path
         end
-        accepts.xml do
-          headers[&quot;Status&quot;]           = &quot;Unauthorized&quot;
-          headers[&quot;WWW-Authenticate&quot;] = %(Basic realm=&quot;Web Password&quot;)
-          render :text =&gt; &quot;Could't authenticate you&quot;, :status =&gt; '401 Unauthorized'
+        # format.any doesn't work in rails version &lt; http://dev.rubyonrails.org/changeset/8987
+        # Add any other API formats here.  (Some browsers, notably IE6, send Accept: */* and trigger 
+        # the 'format.any' block incorrectly. See http://bit.ly/ie6_borken or http://bit.ly/ie6_borken2
+        # for a workaround.)
+        format.any(:json, :xml) do
+          request_http_basic_authentication 'Web Password'
         end
       end
-      false
-    end  
-    
+    end
+
     # Store the URI of the current request in the session.
     #
     # We can return to this location by calling #redirect_back_or_default.
     def store_location
       session[:return_to] = request.request_uri
     end
-    
+
     # Redirect to the URI stored by the most recent store_location call or
-    # to the passed default.
+    # to the passed default.  Set an appropriately modified
+    #   after_filter :store_location, :only =&gt; [:index, :new, :show, :edit]
+    # for any controller you want to be bounce-backable.
     def redirect_back_or_default(default)
       redirect_to(session[:return_to] || default)
       session[:return_to] = nil
     end
-    
+
     # Inclusion hook to make #current_user and #logged_in?
     # available as ActionView helper methods.
     def self.included(base)
-      base.send :helper_method, :current_user, :logged_in?, :current_site, :admin?, :moderator_of?
+      base.send :helper_method, :current_user, :logged_in?, :current_site, :admin?, :moderator_of? if base.respond_to? :helper_method
     end
 
+    #
+    # Login
+    #
+
     # Called from #current_user.  First attempt to login by the user id stored in the session.
     def login_from_session
-      self.current_user = current_site.users.find_by_id(session[:user]) if session[:user]
+      self.current_user = User.find_by_id(session[:user_id]) if session[:user_id]
     end
 
     # Called from #current_user.  Now, attempt to login by basic authentication information.
     def login_from_basic_auth
-      username, passwd = get_auth_data
-      self.current_user = current_site.users.authenticate(username, passwd) if username &amp;&amp; passwd
+      authenticate_with_http_basic do |login, password|
+        self.current_user = User.authenticate(login, password)
+      end
     end
+    
+    #
+    # Logout
+    #
 
     # Called from #current_user.  Finaly, attempt to login by an expiring token in the cookie.
+    # for the paranoid: we _should_ be storing user_token = hash(cookie_token, request IP)
     def login_from_cookie
-      user = cookies[:auth_token] &amp;&amp; current_site.users.find_by_remember_token(cookies[:auth_token])
+      user = cookies[:auth_token] &amp;&amp; User.find_by_remember_token(cookies[:auth_token])
       if user &amp;&amp; user.remember_token?
-        user.remember_me
-        cookies[:auth_token] = { :value =&gt; user.remember_token, :expires =&gt; user.remember_token_expires_at }
         self.current_user = user
+        handle_remember_cookie! false # freshen cookie token (keeping date)
+        self.current_user
       end
     end
 
-  private
-    @@http_auth_headers = %w(X-HTTP_AUTHORIZATION HTTP_AUTHORIZATION Authorization)
-    # gets BASIC auth info
-    def get_auth_data
-      auth_key  = @@http_auth_headers.detect { |h| request.env.has_key?(h) }
-      auth_data = request.env[auth_key].to_s.split unless auth_key.blank?
-      return auth_data &amp;&amp; auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil] 
+    # This is ususally what you want; resetting the session willy-nilly wreaks
+    # havoc with forgery protection, and is only strictly necessary on login.
+    # However, **all session state variables should be unset here**.
+    def logout_keeping_session!
+      # Kill server-side auth cookie
+      @current_user.forget_me if @current_user.is_a? User
+      @current_user = false     # not logged in, and don't do it for me
+      kill_remember_cookie!     # Kill client-side auth cookie
+      session[:user_id] = nil   # keeps the session but kill our variable
+      # explicitly kill any other session variables you set
     end
+
+    # The session should only be reset at the tail end of a form POST --
+    # otherwise the request forgery protection fails. It's only really necessary
+    # when you cross quarantine (logged-out to logged-in).
+    def logout_killing_session!
+      logout_keeping_session!
+      reset_session
+    end
+    
+    #
+    # Remember_me Tokens
+    #
+    # Cookies shouldn't be allowed to persist past their freshness date,
+    # and they should be changed at each login
+
+    # Cookies shouldn't be allowed to persist past their freshness date,
+    # and they should be changed at each login
+
+    def valid_remember_cookie?
+      return nil unless @current_user
+      (@current_user.remember_token?) &amp;&amp; 
+        (cookies[:auth_token] == @current_user.remember_token)
+    end
+    
+    # Refresh the cookie auth token if it exists, create it otherwise
+    def handle_remember_cookie!(new_cookie_flag)
+      return unless @current_user
+      case
+      when valid_remember_cookie? then @current_user.refresh_token # keeping same expiry date
+      when new_cookie_flag        then @current_user.remember_me 
+      else                             @current_user.forget_me
+      end
+      send_remember_cookie!
+    end
+  
+    def kill_remember_cookie!
+      cookies.delete :auth_token
+    end
+    
+    def send_remember_cookie!
+      cookies[:auth_token] = {
+        :value   =&gt; @current_user.remember_token,
+        :expires =&gt; @current_user.remember_token_expires_at }
+    end
+
 end</diff>
      <filename>lib/authenticated_system.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
 //           (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
 //           (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
 // Contributors:</diff>
      <filename>public/javascripts/controls.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
 //           (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
 // 
 // script.aculo.us is freely distributable under the terms of an MIT-style license.</diff>
      <filename>public/javascripts/dragdrop.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
 // Contributors:
 //  Justin Palmer (http://encytemedia.com/)
 //  Mark Pilgrim (http://diveintomark.org/)</diff>
      <filename>public/javascripts/effects.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,4 @@
 #!/usr/bin/env ruby
-$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn
 $LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
 require 'rubygems'
 require 'drb/drb'
@@ -23,17 +22,29 @@ module Spec
               active_connections.delete(name)
             end
           end
-        end        
+        end
 
-        if ::Dispatcher.respond_to?(:cleanup_application)
-          ::Dispatcher.cleanup_application
+        if ActionController.const_defined?(:Dispatcher)
+          dispatcher = ::ActionController::Dispatcher.new($stdout)
+          dispatcher.cleanup_application
         elsif ::Dispatcher.respond_to?(:reset_application!)
           ::Dispatcher.reset_application!
+        else
+          raise &quot;Application reloading failed&quot;
+        end
+        if Object.const_defined?(:Fixtures) &amp;&amp; Fixtures.respond_to?(:reset_cache)
+          Fixtures.reset_cache
         end
+
         ::Dependencies.mechanism = :load
         require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
         load File.dirname(__FILE__) + '/../spec/spec_helper.rb'
 
+        if in_memory_database?
+          load &quot;#{RAILS_ROOT}/db/schema.rb&quot; # use db agnostic schema by default
+          ActiveRecord::Migrator.up('db/migrate') # use migrations
+        end
+
         ::Spec::Runner::CommandLine.run(
           ::Spec::Runner::OptionParser.parse(
             argv,
@@ -42,6 +53,12 @@ module Spec
           )
         )
       end
+
+      def in_memory_database?
+        ENV[&quot;RAILS_ENV&quot;] == &quot;test&quot; and
+        ::ActiveRecord::Base.connection.class.to_s == &quot;ActiveRecord::ConnectionAdapters::SQLite3Adapter&quot; and
+        ::Rails::Configuration.new.database_configuration['test']['database'] == ':memory:'
+      end
     end
   end
 end
@@ -88,7 +105,7 @@ opts.parse!(ARGV)
 puts &quot;Ready&quot;
 exec_server = lambda {
   trap(&quot;USR2&quot;) { restart_test_server } if Signal.list.has_key?(&quot;USR2&quot;)
-  DRb.start_service(&quot;druby://localhost:8989&quot;, Spec::Runner::RailsSpecServer.new)
+  DRb.start_service(&quot;druby://127.0.0.1:8989&quot;, Spec::Runner::RailsSpecServer.new)
   DRb.thread.join
 }
 </diff>
      <filename>script/spec_server</filename>
    </modified>
    <modified>
      <diff>@@ -21,7 +21,9 @@ describe ModeratorshipsController, &quot;POST #create&quot; do
     it_assigns :moderatorship, :flash =&gt; {:notice =&gt; nil, :error =&gt; :not_nil}
     it_redirects_to { user_path(users(:default)) }
   end
-  
+
+# Seriously, I could give a crap about XML.
+=begin
   describe ModeratorshipsController, &quot;(successful creation, xml)&quot; do
     define_models
     act! { post :create, :moderatorship =&gt; @attributes, :format =&gt; 'xml' }
@@ -41,6 +43,7 @@ describe ModeratorshipsController, &quot;POST #create&quot; do
       assigns(:moderatorship).errors.to_xml
     end
   end
+=end
 end
 
 describe ModeratorshipsController, &quot;DELETE #destroy&quot; do</diff>
      <filename>spec/controllers/moderatorships_controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 require File.dirname(__FILE__) + '/../spec_helper'
+require 'model_stubbing'
 
 describe Forum do
   define_models do</diff>
      <filename>spec/models/forum_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,10 +7,11 @@ require 'spec/rails'
 require 'rspec_on_rails_on_crack'
 require 'model_stubbing'
 require File.dirname(__FILE__) + &quot;/model_stubs&quot;
-require 'ruby-debug'
-Debugger.start
+#require 'ruby-debug'
+#Debugger.start
 
 Spec::Runner.configure do |config|
+  include AuthenticatedTestHelper
   config.use_transactional_fixtures = true
   config.use_instantiated_fixtures  = false
   config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
@@ -18,13 +19,13 @@ Spec::Runner.configure do |config|
   def current_site(site)
     @controller.stub!(:current_site).and_return(@site = site ? sites(site) : nil)
   end
-
+ 
   # Sets the current user in the session from the user fixtures.
-  def login_as(user)
-    controller.stub!(:current_user).and_return(@user = user ? users(user) : nil)
-  end
-
-  def authorize_as(user)
-    @request.env[&quot;HTTP_AUTHORIZATION&quot;] = user ? &quot;Basic #{Base64.encode64(&quot;#{users(user).login}:test&quot;)}&quot; : nil
-  end
-end
\ No newline at end of file
+#  def login_as(user)
+ #   controller.stub!(:current_user).and_return(@user = user ? users(user) : nil)
+ # end
+ 
+  #def authorize_as(user)
+ #   @request.env[&quot;HTTP_AUTHORIZATION&quot;] = user ? &quot;Basic #{Base64.encode64(&quot;#{users(user).login}:test&quot;)}&quot; : nil
+  #end
+end</diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -50,7 +50,7 @@ module ModelStubbing
         # if options are given first, assume that base_name is default
         when Hash
           options   = base_name
-          base_name = nil
+          base_name = self
         when nil
         else
           unless options[:copy] || block.nil?</diff>
      <filename>vendor/plugins/model_stubbing/lib/model_stubbing.rb</filename>
    </modified>
    <modified>
      <diff>@@ -115,7 +115,7 @@ module ModelStubbing
       ModelStubbing.records.clear
       ModelStubbing.stub_current_time_with(current_time) if current_time
       return unless database?
-      ActiveRecord::Base.send :increment_open_transactions
+      ActiveRecord::Base.connection.increment_open_transactions
       ActiveRecord::Base.connection.begin_db_transaction
     end
     </diff>
      <filename>vendor/plugins/model_stubbing/lib/model_stubbing/definition.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@ module ModelStubbing
   # Models hold one or more stubs.
   class Model
     attr_accessor :name, :plural, :singular
-    attr_reader   :definition, :stubs, :model_class, :options
+    attr_reader   :definition, :stubs, :model_class, :options, :ordered_stubs
 
     # Creates a stub for this model.  A stub with no name is assumed to be the default
     # stub.  A global key for the definition is also created based on the singular
@@ -17,13 +17,14 @@ module ModelStubbing
     end
 
     def initialize(definition, klass, options = {}, &amp;block)
-      @definition  = definition
-      @model_class = klass
-      @name        = options.delete(:name)     || default_name.to_sym
-      @plural      = options.delete(:plural)   || name
-      @singular    = options.delete(:singular) || name.to_s.singularize
-      @options     = options
-      @stubs       = {}
+      @definition    = definition
+      @model_class   = klass
+      @name          = options.delete(:name)     || default_name.to_sym
+      @plural        = options.delete(:plural)   || name
+      @singular      = options.delete(:singular) || name.to_s.singularize
+      @options       = options
+      @stubs         = {}
+      @ordered_stubs = []
       unless @model_class.respond_to?(:mock_id)
         class &lt;&lt; @model_class
           define_method :mock_id do
@@ -92,7 +93,11 @@ module ModelStubbing
     
     def insert
       purge
-      @stubs.values.each &amp;:insert
+      @ordered_stubs.each do |name| 
+        if stub = @stubs[name]
+          stub.insert
+        end
+      end
     end
     
     def purge
@@ -104,5 +109,19 @@ module ModelStubbing
     def connection
       @connection ||= model_class.respond_to?(:connection) &amp;&amp; model_class.connection
     end
+
+  protected
+    def method_missing(model_name, stub_name, *args)
+      named_model = @definition.models[model_name]
+      if named_model.nil?
+        raise &quot;No #{model_name.inspect} model found when calling #{model_name}(#{stub_name})&quot;
+      end
+      stub = named_model.stubs[stub_name]
+      if stub.nil?
+        raise &quot;No #{stub_name.inspect} stub found in the #{model_name.inspect} model when calling #{model_name}(#{stub_name})&quot;
+      else
+        stub
+      end
+    end
   end
 end
\ No newline at end of file</diff>
      <filename>vendor/plugins/model_stubbing/lib/model_stubbing/model.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,6 +19,8 @@ module ModelStubbing
         end
 
       @global_key = (name == :default ? @model.singular : &quot;#{name}_#{@model.singular}&quot;).to_sym
+      @model.ordered_stubs &lt;&lt; name
+      @model.ordered_stubs.uniq!
       @model.all_stubs[@global_key] = @model.stubs[name] = self
     end
     
@@ -39,7 +41,11 @@ module ModelStubbing
     # pass :id =&gt; :new to specify you want a new record, not one in the database
     def record(attributes = {})
       this_record_key = record_key(attributes)
-      ModelStubbing.records[this_record_key] ||= instantiate(this_record_key, attributes)
+      if attributes[:id] != :new &amp;&amp; ModelStubbing.records.key?(this_record_key)
+        ModelStubbing.records[this_record_key]
+      else
+        ModelStubbing.records[this_record_key] = instantiate(this_record_key, attributes)
+      end
     end
     
     def inspect
@@ -157,7 +163,6 @@ module ModelStubbing
     def record_key(attributes)
       return @record_key if @record_key &amp;&amp; attributes.empty?
       key = [model.model_class.name, @global_key, @attributes.merge(attributes).inspect] * &quot;:&quot;
-      key &lt;&lt; model.model_class.base_class.mock_id.to_s if attributes[:id] == :new
       @record_key = key if attributes.empty?
       key 
     end</diff>
      <filename>vendor/plugins/model_stubbing/lib/model_stubbing/stub.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,9 @@
 namespace :stubs do
-  
   desc &quot;Load a ModelStubbing definition into the database. Specify Stub file with STUBS= and Definition with DEF=&quot;
   task :load do
     root = File.dirname(__FILE__) + '/../../../../'
     require File.expand_path(root + &quot;config/environment&quot;)
-    
+
     begin
       require 'spec'
     rescue
@@ -12,15 +11,10 @@ namespace :stubs do
       require 'spec'
     end
     require 'model_stubbing'
-    
-    # note to Rick: I've taken to using 'stubs.rb' instead of 'model_stubs.rb'
-    # because 'model_stubs' has a tab-completion collision with 'spec/models' and
-    # that drives me batty. Change the default to 'spec/model_stubs' if you want,
-    # you won't hurt my feelings.
+
     require root + (ENV['STUBS'] || 'spec/stubs')
     
     defn = (ENV['DEF'] || 'default').intern
     ModelStubbing.definitions[defn].insert!
   end
-  
 end
\ No newline at end of file</diff>
      <filename>vendor/plugins/model_stubbing/tasks/stubs.rake</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1 @@
-./script/generate authenticated USERMODEL CONTROLLERNAME [--include-activation] [--stateful] [--rspec]
\ No newline at end of file
+./script/generate authenticated USERMODEL CONTROLLERNAME
\ No newline at end of file</diff>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/USAGE</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,11 @@
+require File.expand_path(File.dirname(__FILE__) + &quot;/lib/insert_routes.rb&quot;)
+require 'digest/sha1'
 class AuthenticatedGenerator &lt; Rails::Generator::NamedBase
+  default_options :skip_migration =&gt; false,
+                  :skip_routes    =&gt; false,
+                  :old_passwords  =&gt; false,
+                  :include_activation =&gt; false
+
   attr_reader   :controller_name,
                 :controller_class_path,
                 :controller_file_path,
@@ -6,8 +13,11 @@ class AuthenticatedGenerator &lt; Rails::Generator::NamedBase
                 :controller_class_nesting_depth,
                 :controller_class_name,
                 :controller_singular_name,
-                :controller_plural_name
-  alias_method  :controller_file_name,  :controller_singular_name
+                :controller_plural_name,
+                :controller_routing_name,                 # new_session_path
+                :controller_routing_path,                 # /session/new
+                :controller_controller_name,              # sessions
+                :controller_file_name
   alias_method  :controller_table_name, :controller_plural_name
   attr_reader   :model_controller_name,
                 :model_controller_class_path,
@@ -16,37 +26,52 @@ class AuthenticatedGenerator &lt; Rails::Generator::NamedBase
                 :model_controller_class_nesting_depth,
                 :model_controller_class_name,
                 :model_controller_singular_name,
-                :model_controller_plural_name
+                :model_controller_plural_name,
+                :model_controller_routing_name,           # new_user_path
+                :model_controller_routing_path,           # /users/new
+                :model_controller_controller_name         # users
   alias_method  :model_controller_file_name,  :model_controller_singular_name
   alias_method  :model_controller_table_name, :model_controller_plural_name
 
   def initialize(runtime_args, runtime_options = {})
     super
-    
+
     @rspec = has_rspec?
 
-    @controller_name = args.shift || 'sessions'
+    @controller_name = (args.shift || 'sessions').pluralize
     @model_controller_name = @name.pluralize
 
     # sessions controller
     base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
-    @controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
-
+    @controller_class_name_without_nesting, @controller_file_name, @controller_plural_name = inflect_names(base_name)
+    @controller_singular_name = @controller_file_name.singularize
     if @controller_class_nesting.empty?
       @controller_class_name = @controller_class_name_without_nesting
     else
       @controller_class_name = &quot;#{@controller_class_nesting}::#{@controller_class_name_without_nesting}&quot;
     end
+    @controller_routing_name  = @controller_singular_name
+    @controller_routing_path  = @controller_file_path.singularize
+    @controller_controller_name = @controller_plural_name
 
     # model controller
     base_name, @model_controller_class_path, @model_controller_file_path, @model_controller_class_nesting, @model_controller_class_nesting_depth = extract_modules(@model_controller_name)
     @model_controller_class_name_without_nesting, @model_controller_singular_name, @model_controller_plural_name = inflect_names(base_name)
-    
+
     if @model_controller_class_nesting.empty?
       @model_controller_class_name = @model_controller_class_name_without_nesting
     else
       @model_controller_class_name = &quot;#{@model_controller_class_nesting}::#{@model_controller_class_name_without_nesting}&quot;
     end
+    @model_controller_routing_name    = @table_name
+    @model_controller_routing_path    = @model_controller_file_path
+    @model_controller_controller_name = @model_controller_plural_name
+
+    load_or_initialize_site_keys()
+
+    if options[:dump_generator_attribute_names]
+      dump_generator_attribute_names
+    end
   end
 
   def manifest
@@ -70,16 +95,21 @@ class AuthenticatedGenerator &lt; Rails::Generator::NamedBase
       m.directory File.join('app/controllers', model_controller_class_path)
       m.directory File.join('app/helpers', model_controller_class_path)
       m.directory File.join('app/views', model_controller_class_path, model_controller_file_name)
+      m.directory File.join('config/initializers')
 
       if @rspec
         m.directory File.join('spec/controllers', controller_class_path)
         m.directory File.join('spec/controllers', model_controller_class_path)
         m.directory File.join('spec/models', class_path)
+        m.directory File.join('spec/helpers', model_controller_class_path)
         m.directory File.join('spec/fixtures', class_path)
+        m.directory File.join('stories', model_controller_file_path)
+        m.directory File.join('stories', 'steps')
       else
         m.directory File.join('test/functional', controller_class_path)
         m.directory File.join('test/functional', model_controller_class_path)
         m.directory File.join('test/unit', class_path)
+        m.directory File.join('test/fixtures', class_path)
       end
 
       m.template 'model.rb',
@@ -111,40 +141,76 @@ class AuthenticatedGenerator &lt; Rails::Generator::NamedBase
       m.template 'authenticated_test_helper.rb',
                   File.join('lib', 'authenticated_test_helper.rb')
 
+      m.template 'site_keys.rb', site_keys_file
+
       if @rspec
-        m.template 'functional_spec.rb',
+        # RSpec Specs
+        m.template  'spec/controllers/users_controller_spec.rb',
+                    File.join('spec/controllers',
+                              model_controller_class_path,
+                              &quot;#{model_controller_file_name}_controller_spec.rb&quot;)
+        m.template  'spec/controllers/sessions_controller_spec.rb',
                     File.join('spec/controllers',
                               controller_class_path,
                               &quot;#{controller_file_name}_controller_spec.rb&quot;)
-        m.template 'model_functional_spec.rb',
+        m.template  'spec/controllers/access_control_spec.rb',
+                    File.join('spec/controllers',
+                              controller_class_path,
+                              &quot;access_control_spec.rb&quot;)
+        m.template  'spec/controllers/authenticated_system_spec.rb',
                     File.join('spec/controllers',
+                              controller_class_path,
+                              &quot;authenticated_system_spec.rb&quot;)
+        m.template  'spec/helpers/users_helper_spec.rb',
+                    File.join('spec/helpers',
                               model_controller_class_path,
-                              &quot;#{model_controller_file_name}_controller_spec.rb&quot;)
-        m.template 'unit_spec.rb',
+                              &quot;#{table_name}_helper_spec.rb&quot;)
+        m.template  'spec/models/user_spec.rb',
                     File.join('spec/models',
                               class_path,
                               &quot;#{file_name}_spec.rb&quot;)
-        m.template 'fixtures.yml',
+        m.template 'spec/fixtures/users.yml',
                     File.join('spec/fixtures',
+                               class_path,
                               &quot;#{table_name}.yml&quot;)
+
+        # RSpec Stories
+        m.template  'stories/steps/ra_navigation_steps.rb',
+         File.join('stories/steps/ra_navigation_steps.rb')
+        m.template  'stories/steps/ra_response_steps.rb',
+         File.join('stories/steps/ra_response_steps.rb')
+        m.template  'stories/steps/ra_resource_steps.rb',
+         File.join('stories/steps/ra_resource_steps.rb')
+        m.template  'stories/steps/user_steps.rb',
+         File.join('stories/steps/', &quot;#{file_name}_steps.rb&quot;)
+        m.template  'stories/users/accounts.story',
+         File.join('stories', model_controller_file_path, 'accounts.story')
+        m.template  'stories/users/sessions.story',
+         File.join('stories', model_controller_file_path, 'sessions.story')
+        m.template  'stories/rest_auth_stories_helper.rb',
+         File.join('stories', 'rest_auth_stories_helper.rb')
+        m.template  'stories/rest_auth_stories.rb',
+         File.join('stories', 'rest_auth_stories.rb')
+
       else
-        m.template 'functional_test.rb',
+        m.template 'test/functional_test.rb',
                     File.join('test/functional',
                               controller_class_path,
                               &quot;#{controller_file_name}_controller_test.rb&quot;)
-        m.template 'model_functional_test.rb',
+        m.template 'test/model_functional_test.rb',
                     File.join('test/functional',
                               model_controller_class_path,
                               &quot;#{model_controller_file_name}_controller_test.rb&quot;)
-        m.template 'unit_test.rb',
+        m.template 'test/unit_test.rb',
                     File.join('test/unit',
                               class_path,
                               &quot;#{file_name}_test.rb&quot;)
         if options[:include_activation]
-          m.template 'mailer_test.rb', File.join('test/unit', class_path, &quot;#{file_name}_mailer_test.rb&quot;)
+          m.template 'test/mailer_test.rb', File.join('test/unit', class_path, &quot;#{file_name}_mailer_test.rb&quot;)
         end
-        m.template 'fixtures.yml',
+        m.template 'spec/fixtures/users.yml',
                     File.join('test/fixtures',
+                              class_path,
                               &quot;#{table_name}.yml&quot;)
       end
 
@@ -160,14 +226,15 @@ class AuthenticatedGenerator &lt; Rails::Generator::NamedBase
 
 
       # Controller templates
-      m.template 'login.rhtml',  File.join('app/views', controller_class_path, controller_file_name, &quot;new.rhtml&quot;)
-      m.template 'signup.rhtml', File.join('app/views', model_controller_class_path, model_controller_file_name, &quot;new.rhtml&quot;)
+      m.template 'login.html.erb',  File.join('app/views', controller_class_path, controller_file_name, &quot;new.html.erb&quot;)
+      m.template 'signup.html.erb', File.join('app/views', model_controller_class_path, model_controller_file_name, &quot;new.html.erb&quot;)
+      m.template '_model_partial.html.erb', File.join('app/views', model_controller_class_path, model_controller_file_name, &quot;_#{file_name}_bar.html.erb&quot;)
 
       if options[:include_activation]
         # Mailer templates
         %w( activation signup_notification ).each do |action|
-          m.template &quot;#{action}.rhtml&quot;,
-                     File.join('app/views', &quot;#{file_name}_mailer&quot;, &quot;#{action}.rhtml&quot;)
+          m.template &quot;#{action}.erb&quot;,
+                     File.join('app/views', &quot;#{file_name}_mailer&quot;, &quot;#{action}.erb&quot;)
         end
       end
 
@@ -176,83 +243,236 @@ class AuthenticatedGenerator &lt; Rails::Generator::NamedBase
           :migration_name =&gt; &quot;Create#{class_name.pluralize.gsub(/::/, '')}&quot;
         }, :migration_file_name =&gt; &quot;create_#{file_path.gsub(/\//, '_').pluralize}&quot;
       end
+      unless options[:skip_routes]
+        # Note that this fails for nested classes -- you're on your own with setting up the routes.
+        m.route_resource  controller_singular_name
+        m.route_resources model_controller_plural_name
+        m.route_name('signup',   '/signup',   {:controller =&gt; model_controller_plural_name, :action =&gt; 'new'})
+        m.route_name('register', '/register', {:controller =&gt; model_controller_plural_name, :action =&gt; 'create'})
+        m.route_name('login',    '/login',    {:controller =&gt; controller_controller_name, :action =&gt; 'new'})
+        m.route_name('logout',   '/logout',   {:controller =&gt; controller_controller_name, :action =&gt; 'destroy'})
+      end
     end
 
-    action = nil
-    action = $0.split(&quot;/&quot;)[1]
+    #
+    # Post-install notes
+    #
+    action = File.basename($0) # grok the action from './script/generate' or whatever
     case action
-      when &quot;generate&quot; 
-        puts
-        puts (&quot;-&quot; * 70)
-        puts &quot;Don't forget to:&quot;
-        puts
-        puts &quot;  - add restful routes in config/routes.rb&quot;
-        puts &quot;    map.resources :#{model_controller_file_name}&quot;
-        puts &quot;    map.resource  :#{controller_singular_name.singularize}&quot;
-        puts
-        puts &quot; Rails 1.2.3 may need a :controller option for the singular resource:&quot;
-        puts &quot;  - map.resource :#{controller_singular_name.singularize}, :controller =&gt; '#{controller_file_name}'&quot;
-        puts
-        if options[:include_activation]
-          puts &quot;    map.activate '/activate/:activation_code', :controller =&gt; '#{model_controller_file_name}', :action =&gt; 'activate'&quot;
-          puts
-          puts &quot;  - add an observer to config/environment.rb&quot;
-          puts &quot;    config.active_record.observers = :#{file_name}_observer&quot;
-          puts
-        end
-        if options[:stateful]
-          puts &quot;Also, don't forget to install the acts_as_state_machine plugin!&quot;
-          puts
-          puts &quot;  svn co http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk vendor/plugins/acts_as_state_machine&quot;
-          puts
-        end
-        puts &quot;Try these for some familiar login URLs if you like:&quot;
-        puts
-        puts &quot;  map.signup '/signup', :controller =&gt; '#{model_controller_file_name}', :action =&gt; 'new'&quot;
-        puts &quot;  map.login  '/login', :controller =&gt; '#{controller_file_name}', :action =&gt; 'new'&quot;
-        puts &quot;  map.logout '/logout', :controller =&gt; '#{controller_file_name}', :action =&gt; 'destroy'&quot;
-        puts
-        puts (&quot;-&quot; * 70)
-        puts
-      when &quot;destroy&quot; 
-        puts
-        puts (&quot;-&quot; * 70)
-        puts
-        puts &quot;Thanks for using restful_authentication&quot;
-        puts
-        puts &quot;Don't forget to comment out the observer line in environment.rb&quot;
-        puts &quot;  (This was optional so it may not even be there)&quot;
-        puts &quot;  # config.active_record.observers = :#{file_name}_observer&quot;
-        puts
-        puts (&quot;-&quot; * 70)
-        puts
+    when &quot;generate&quot;
+      puts &quot;Ready to generate.&quot;
+      puts (&quot;-&quot; * 70)
+      puts &quot;Once finished, don't forget to:&quot;
+      puts
+      if options[:include_activation]
+        puts &quot;- Add an observer to config/environment.rb&quot;
+        puts &quot;    config.active_record.observers = :#{file_name}_observer&quot;
+      end
+      if options[:aasm]
+        puts &quot;- Install the acts_as_state_machine gem:&quot;
+        puts &quot;    sudo gem sources -a http://gems.github.com (If you haven't already)&quot;
+        puts &quot;    sudo gem install rubyist-aasm&quot;
+      elsif options[:stateful]
+        puts &quot;- Install the acts_as_state_machine plugin:&quot;
+        puts &quot;    svn export http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk vendor/plugins/acts_as_state_machine&quot;
+      end
+      puts &quot;- Add routes to these resources. In config/routes.rb, insert routes like:&quot;
+      puts %(    map.signup '/signup', :controller =&gt; '#{model_controller_file_name}', :action =&gt; 'new')
+      puts %(    map.login  '/login',  :controller =&gt; '#{controller_file_name}', :action =&gt; 'new')
+      puts %(    map.logout '/logout', :controller =&gt; '#{controller_file_name}', :action =&gt; 'destroy')
+      if options[:include_activation]
+        puts %(    map.activate '/activate/:activation_code', :controller =&gt; '#{model_controller_file_name}', :action =&gt; 'activate', :activation_code =&gt; nil)
+      end
+      if options[:stateful]
+        puts  &quot;  and modify the map.resources :#{model_controller_file_name} line to include these actions:&quot;
+        puts  &quot;    map.resources :#{model_controller_file_name}, :member =&gt; { :suspend =&gt; :put, :unsuspend =&gt; :put, :purge =&gt; :delete }&quot;
+      end
+      puts
+      puts (&quot;-&quot; * 70)
+      puts
+      if $rest_auth_site_key_from_generator.blank?
+        puts &quot;You've set a nil site key. This preserves existing users' passwords,&quot;
+        puts &quot;but allows dictionary attacks in the unlikely event your database is&quot;
+        puts &quot;compromised and your site code is not.  See the README for more.&quot;
+      elsif $rest_auth_keys_are_new
+        puts &quot;We've create a new site key in #{site_keys_file}.  If you have existing&quot;
+        puts &quot;user accounts their passwords will no longer work (see README). As always,&quot;
+        puts &quot;keep this file safe but don't post it in public.&quot;
       else
-        puts
+        puts &quot;We've reused the existing site key in #{site_keys_file}.  As always,&quot;
+        puts &quot;keep this file safe but don't post it in public.&quot;
+      end
+      puts
+      puts (&quot;-&quot; * 70)
+    when &quot;destroy&quot;
+      puts
+      puts (&quot;-&quot; * 70)
+      puts
+      puts &quot;Thanks for using restful_authentication&quot;
+      puts
+      puts &quot;Don't forget to comment out the observer line in environment.rb&quot;
+      puts &quot;  (This was optional so it may not even be there)&quot;
+      puts &quot;  # config.active_record.observers = :#{file_name}_observer&quot;
+      puts
+      puts (&quot;-&quot; * 70)
+      puts
+    else
+      puts &quot;Didn't understand the action '#{action}' -- you might have missed the 'after running me' instructions.&quot;
     end
 
+    #
+    # Do the thing
+    #
     recorded_session
   end
 
   def has_rspec?
-    options[:rspec] || (File.exist?('spec') &amp;&amp; File.directory?('spec'))
+    spec_dir = File.join(RAILS_ROOT, 'spec')
+    options[:rspec] ||= (File.exist?(spec_dir) &amp;&amp; File.directory?(spec_dir)) unless (options[:rspec] == false)
   end
-  
-  protected
-    # Override with your own usage banner.
-    def banner
-      &quot;Usage: #{$0} authenticated ModelName [ControllerName]&quot;
+
+  #
+  # !! These must match the corresponding routines in by_password.rb !!
+  #
+  def secure_digest(*args)
+    Digest::SHA1.hexdigest(args.flatten.join('--'))
+  end
+  def make_token
+    secure_digest(Time.now, (1..10).map{ rand.to_s })
+  end
+  def password_digest(password, salt)
+    digest = $rest_auth_site_key_from_generator
+    $rest_auth_digest_stretches_from_generator.times do
+      digest = secure_digest(digest, salt, password, $rest_auth_site_key_from_generator)
     end
+    digest
+  end
 
-    def add_options!(opt)
-      opt.separator ''
-      opt.separator 'Options:'
-      opt.on(&quot;--skip-migration&quot;, 
-             &quot;Don't generate a migration file for this model&quot;) { |v| options[:skip_migration] = v }
-      opt.on(&quot;--include-activation&quot;, 
-             &quot;Generate signup 'activation code' confirmation via email&quot;) { |v| options[:include_activation] = true }
-      opt.on(&quot;--stateful&quot;, 
-             &quot;Use acts_as_state_machine.  Assumes --include-activation&quot;) { |v| options[:include_activation] = options[:stateful] = true }
-      opt.on(&quot;--rspec&quot;,
-             &quot;Force rspec mode (checks for RAILS_ROOT/spec by default)&quot;) { |v| options[:rspec] = true }
+  #
+  # Try to be idempotent:
+  # pull in the existing site key if any,
+  # seed it with reasonable defaults otherwise
+  #
+  def load_or_initialize_site_keys
+    case
+    when defined? REST_AUTH_SITE_KEY
+      if (options[:old_passwords]) &amp;&amp; ((! REST_AUTH_SITE_KEY.blank?) || (REST_AUTH_DIGEST_STRETCHES != 1))
+        raise &quot;You have a site key, but --old-passwords will overwrite it.  If this is really what you want, move the file #{site_keys_file} and re-run.&quot;
+      end
+      $rest_auth_site_key_from_generator         = REST_AUTH_SITE_KEY
+      $rest_auth_digest_stretches_from_generator = REST_AUTH_DIGEST_STRETCHES
+    when options[:old_passwords]
+      $rest_auth_site_key_from_generator         = nil
+      $rest_auth_digest_stretches_from_generator = 1
+      $rest_auth_keys_are_new                    = true
+    else
+      $rest_auth_site_key_from_generator         = make_token
+      $rest_auth_digest_stretches_from_generator = 10
+      $rest_auth_keys_are_new                    = true
     end
+  end
+  def site_keys_file
+    File.join(&quot;config&quot;, &quot;initializers&quot;, &quot;site_keys.rb&quot;)
+  end
+
+protected
+  # Override with your own usage banner.
+  def banner
+    &quot;Usage: #{$0} authenticated ModelName [ControllerName]&quot;
+  end
+
+  def add_options!(opt)
+    opt.separator ''
+    opt.separator 'Options:'
+    opt.on(&quot;--skip-migration&quot;,
+      &quot;Don't generate a migration file for this model&quot;)           { |v| options[:skip_migration] = v }
+    opt.on(&quot;--include-activation&quot;,
+      &quot;Generate signup 'activation code' confirmation via email&quot;) { |v| options[:include_activation] = true }
+    opt.on(&quot;--stateful&quot;,
+      &quot;Use acts_as_state_machine.  Assumes --include-activation&quot;) { |v| options[:include_activation] = options[:stateful] = true }
+    opt.on(&quot;--aasm&quot;,
+      &quot;Use (gem) aasm.  Assumes --include-activation&quot;)            { |v| options[:include_activation] = options[:stateful] = options[:aasm] = true }
+    opt.on(&quot;--rspec&quot;,
+      &quot;Force rspec mode (checks for RAILS_ROOT/spec by default)&quot;) { |v| options[:rspec] = true }
+    opt.on(&quot;--no-rspec&quot;,
+      &quot;Force test (not RSpec mode&quot;)                               { |v| options[:rspec] = false }
+    opt.on(&quot;--skip-routes&quot;,
+      &quot;Don't generate a resource line in config/routes.rb&quot;)       { |v| options[:skip_routes] = v }
+    opt.on(&quot;--old-passwords&quot;,
+      &quot;Use the older password encryption scheme (see README)&quot;)    { |v| options[:old_passwords] = v }
+    opt.on(&quot;--dump-generator-attrs&quot;,
+      &quot;(generator debug helper)&quot;)                                 { |v| options[:dump_generator_attribute_names] = v }
+  end
+
+  def dump_generator_attribute_names
+    generator_attribute_names = [
+      :table_name,
+      :file_name,
+      :class_name,
+      :controller_name,
+      :controller_class_path,
+      :controller_file_path,
+      :controller_class_nesting,
+      :controller_class_nesting_depth,
+      :controller_class_name,
+      :controller_singular_name,
+      :controller_plural_name,
+      :controller_routing_name,                 # new_session_path
+      :controller_routing_path,                 # /session/new
+      :controller_controller_name,              # sessions
+      :controller_file_name,
+      :controller_table_name, :controller_plural_name,
+      :model_controller_name,
+      :model_controller_class_path,
+      :model_controller_file_path,
+      :model_controller_class_nesting,
+      :model_controller_class_nesting_depth,
+      :model_controller_class_name,
+      :model_controller_singular_name,
+      :model_controller_plural_name,
+      :model_controller_routing_name,           # new_user_path
+      :model_controller_routing_path,           # /users/new
+      :model_controller_controller_name,        # users
+      :model_controller_file_name,  :model_controller_singular_name,
+      :model_controller_table_name, :model_controller_plural_name,
+    ]
+    generator_attribute_names.each do |attr|
+      puts &quot;%-40s %s&quot; % [&quot;#{attr}:&quot;, self.send(attr)]  # instance_variable_get(&quot;@#{attr.to_s}&quot;
+    end
+
+  end
 end
+
+# ./script/generate authenticated FoonParent::Foon SporkParent::Spork -p --force --rspec --dump-generator-attrs
+# table_name:                              foon_parent_foons
+# file_name:                               foon
+# class_name:                              FoonParent::Foon
+# controller_name:                         SporkParent::Sporks
+# controller_class_path:                   spork_parent
+# controller_file_path:                    spork_parent/sporks
+# controller_class_nesting:                SporkParent
+# controller_class_nesting_depth:          1
+# controller_class_name:                   SporkParent::Sporks
+# controller_singular_name:                spork
+# controller_plural_name:                  sporks
+# controller_routing_name:                 spork
+# controller_routing_path:                 spork_parent/spork
+# controller_controller_name:              sporks
+# controller_file_name:                    sporks
+# controller_table_name:                   sporks
+# controller_plural_name:                  sporks
+# model_controller_name:                   FoonParent::Foons
+# model_controller_class_path:             foon_parent
+# model_controller_file_path:              foon_parent/foons
+# model_controller_class_nesting:          FoonParent
+# model_controller_class_nesting_depth:    1
+# model_controller_class_name:             FoonParent::Foons
+# model_controller_singular_name:          foons
+# model_controller_plural_name:            foons
+# model_controller_routing_name:           foon_parent_foons
+# model_controller_routing_path:           foon_parent/foons
+# model_controller_controller_name:        foons
+# model_controller_file_name:              foons
+# model_controller_singular_name:          foons
+# model_controller_table_name:             foons
+# model_controller_plural_name:            foons</diff>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/authenticated_generator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,23 +1,23 @@
 module AuthenticatedSystem
   protected
-    # Returns true or false if the user is logged in.
-    # Preloads @current_&lt;%= file_name %&gt; with the user model if they're logged in.
+    # Returns true or false if the &lt;%= file_name %&gt; is logged in.
+    # Preloads @current_&lt;%= file_name %&gt; with the &lt;%= file_name %&gt; model if they're logged in.
     def logged_in?
-      current_&lt;%= file_name %&gt; != :false
+      !!current_&lt;%= file_name %&gt;
     end
-    
-    # Accesses the current &lt;%= file_name %&gt; from the session.  Set it to :false if login fails
-    # so that future calls do not hit the database.
+
+    # Accesses the current &lt;%= file_name %&gt; from the session.
+    # Future calls avoid the database because nil is not equal to false.
     def current_&lt;%= file_name %&gt;
-      @current_&lt;%= file_name %&gt; ||= (login_from_session || login_from_basic_auth || login_from_cookie || :false)
+      @current_&lt;%= file_name %&gt; ||= (login_from_session || login_from_basic_auth || login_from_cookie) unless @current_&lt;%= file_name %&gt; == false
     end
-    
-    # Store the given &lt;%= file_name %&gt; in the session.
+
+    # Store the given &lt;%= file_name %&gt; id in the session.
     def current_&lt;%= file_name %&gt;=(new_&lt;%= file_name %&gt;)
-      session[:&lt;%= file_name %&gt;] = (new_&lt;%= file_name %&gt;.nil? || new_&lt;%= file_name %&gt;.is_a?(Symbol)) ? nil : new_&lt;%= file_name %&gt;.id
-      @current_&lt;%= file_name %&gt; = new_&lt;%= file_name %&gt;
+      session[:&lt;%= file_name %&gt;_id] = new_&lt;%= file_name %&gt; ? new_&lt;%= file_name %&gt;.id : nil
+      @current_&lt;%= file_name %&gt; = new_&lt;%= file_name %&gt; || false
     end
-    
+
     # Check if the &lt;%= file_name %&gt; is authorized
     #
     # Override this method in your controllers if you want to restrict access
@@ -30,7 +30,8 @@ module AuthenticatedSystem
     #  def authorized?
     #    current_&lt;%= file_name %&gt;.login != &quot;bob&quot;
     #  end
-    def authorized?
+    #
+    def authorized?(action = action_name, resource = nil)
       logged_in?
     end
 
@@ -61,67 +62,128 @@ module AuthenticatedSystem
     # to access the requested action.  For example, a popup window might
     # simply close itself.
     def access_denied
-      respond_to do |accepts|
-        accepts.html do
+      respond_to do |format|
+        format.html do
           store_location
-          redirect_to :controller =&gt; '/&lt;%= controller_file_name %&gt;', :action =&gt; 'new'
+          redirect_to new_&lt;%= controller_routing_name %&gt;_path
         end
-        accepts.xml do
-          headers[&quot;Status&quot;]           = &quot;Unauthorized&quot;
-          headers[&quot;WWW-Authenticate&quot;] = %(Basic realm=&quot;Web Password&quot;)
-          render :text =&gt; &quot;Could't authenticate you&quot;, :status =&gt; '401 Unauthorized'
+        # format.any doesn't work in rails version &lt; http://dev.rubyonrails.org/changeset/8987
+        # Add any other API formats here.  (Some browsers, notably IE6, send Accept: */* and trigger 
+        # the 'format.any' block incorrectly. See http://bit.ly/ie6_borken or http://bit.ly/ie6_borken2
+        # for a workaround.)
+        format.any(:json, :xml) do
+          request_http_basic_authentication 'Web Password'
         end
       end
-      false
-    end  
-    
+    end
+
     # Store the URI of the current request in the session.
     #
     # We can return to this location by calling #redirect_back_or_default.
     def store_location
       session[:return_to] = request.request_uri
     end
-    
+
     # Redirect to the URI stored by the most recent store_location call or
-    # to the passed default.
+    # to the passed default.  Set an appropriately modified
+    #   after_filter :store_location, :only =&gt; [:index, :new, :show, :edit]
+    # for any controller you want to be bounce-backable.
     def redirect_back_or_default(default)
       redirect_to(session[:return_to] || default)
       session[:return_to] = nil
     end
-    
+
     # Inclusion hook to make #current_&lt;%= file_name %&gt; and #logged_in?
     # available as ActionView helper methods.
     def self.included(base)
-      base.send :helper_method, :current_&lt;%= file_name %&gt;, :logged_in?
+      base.send :helper_method, :current_&lt;%= file_name %&gt;, :logged_in?, :authorized? if base.respond_to? :helper_method
     end
 
-    # Called from #current_user.  First attempt to login by the user id stored in the session.
+    #
+    # Login
+    #
+
+    # Called from #current_&lt;%= file_name %&gt;.  First attempt to login by the &lt;%= file_name %&gt; id stored in the session.
     def login_from_session
-      self.current_&lt;%= file_name %&gt; = &lt;%= class_name %&gt;.find_by_id(session[:&lt;%= file_name %&gt;]) if session[:&lt;%= file_name %&gt;]
+      self.current_&lt;%= file_name %&gt; = &lt;%= class_name %&gt;.find_by_id(session[:&lt;%= file_name %&gt;_id]) if session[:&lt;%= file_name %&gt;_id]
     end
 
-    # Called from #current_user.  Now, attempt to login by basic authentication information.
+    # Called from #current_&lt;%= file_name %&gt;.  Now, attempt to login by basic authentication information.
     def login_from_basic_auth
-      username, passwd = get_auth_data
-      self.current_&lt;%= file_name %&gt; = &lt;%= class_name %&gt;.authenticate(username, passwd) if username &amp;&amp; passwd
+      authenticate_with_http_basic do |login, password|
+        self.current_&lt;%= file_name %&gt; = &lt;%= class_name %&gt;.authenticate(login, password)
+      end
     end
+    
+    #
+    # Logout
+    #
 
-    # Called from #current_user.  Finaly, attempt to login by an expiring token in the cookie.
-    def login_from_cookie      
+    # Called from #current_&lt;%= file_name %&gt;.  Finaly, attempt to login by an expiring token in the cookie.
+    # for the paranoid: we _should_ be storing &lt;%= file_name %&gt;_token = hash(cookie_token, request IP)
+    def login_from_cookie
       &lt;%= file_name %&gt; = cookies[:auth_token] &amp;&amp; &lt;%= class_name %&gt;.find_by_remember_token(cookies[:auth_token])
       if &lt;%= file_name %&gt; &amp;&amp; &lt;%= file_name %&gt;.remember_token?
-        &lt;%= file_name %&gt;.remember_me
-        cookies[:auth_token] = { :value =&gt; &lt;%= file_name %&gt;.remember_token, :expires =&gt; &lt;%= file_name %&gt;.remember_token_expires_at }
         self.current_&lt;%= file_name %&gt; = &lt;%= file_name %&gt;
+        handle_remember_cookie! false # freshen cookie token (keeping date)
+        self.current_&lt;%= file_name %&gt;
       end
     end
 
-  private
-    @@http_auth_headers = %w(X-HTTP_AUTHORIZATION HTTP_AUTHORIZATION Authorization)
-    # gets BASIC auth info
-    def get_auth_data
-      auth_key  = @@http_auth_headers.detect { |h| request.env.has_key?(h) }
-      auth_data = request.env[auth_key].to_s.split unless auth_key.blank?
-      return auth_data &amp;&amp; auth_data[0] == 'Basic' ? Base64.decode64(auth_data[1]).split(':')[0..1] : [nil, nil] 
+    # This is ususally what you want; resetting the session willy-nilly wreaks
+    # havoc with forgery protection, and is only strictly necessary on login.
+    # However, **all session state variables should be unset here**.
+    def logout_keeping_session!
+      # Kill server-side auth cookie
+      @current_&lt;%= file_name %&gt;.forget_me if @current_&lt;%= file_name %&gt;.is_a? &lt;%= class_name %&gt;
+      @current_&lt;%= file_name %&gt; = false     # not logged in, and don't do it for me
+      kill_remember_cookie!     # Kill client-side auth cookie
+      session[:&lt;%= file_name %&gt;_id] = nil   # keeps the session but kill our variable
+      # explicitly kill any other session variables you set
+    end
+
+    # The session should only be reset at the tail end of a form POST --
+    # otherwise the request forgery protection fails. It's only really necessary
+    # when you cross quarantine (logged-out to logged-in).
+    def logout_killing_session!
+      logout_keeping_session!
+      reset_session
+    end
+    
+    #
+    # Remember_me Tokens
+    #
+    # Cookies shouldn't be allowed to persist past their freshness date,
+    # and they should be changed at each login
+
+    # Cookies shouldn't be allowed to persist past their freshness date,
+    # and they should be changed at each login
+
+    def valid_remember_cookie?
+      return nil unless @current_&lt;%= file_name %&gt;
+      (@current_&lt;%= file_name %&gt;.remember_token?) &amp;&amp; 
+        (cookies[:auth_token] == @current_&lt;%= file_name %&gt;.remember_token)
+    end
+    
+    # Refresh the cookie auth token if it exists, create it otherwise
+    def handle_remember_cookie!(new_cookie_flag)
+      return unless @current_&lt;%= file_name %&gt;
+      case
+      when valid_remember_cookie? then @current_&lt;%= file_name %&gt;.refresh_token # keeping same expiry date
+      when new_cookie_flag        then @current_&lt;%= file_name %&gt;.remember_me 
+      else                             @current_&lt;%= file_name %&gt;.forget_me
+      end
+      send_remember_cookie!
     end
+  
+    def kill_remember_cookie!
+      cookies.delete :auth_token
+    end
+    
+    def send_remember_cookie!
+      cookies[:auth_token] = {
+        :value   =&gt; @current_&lt;%= file_name %&gt;.remember_token,
+        :expires =&gt; @current_&lt;%= file_name %&gt;.remember_token_expires_at }
+    end
+
 end</diff>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_system.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,22 @@
 module AuthenticatedTestHelper
   # Sets the current &lt;%= file_name %&gt; in the session from the &lt;%= file_name %&gt; fixtures.
   def login_as(&lt;%= file_name %&gt;)
-    @request.session[:&lt;%= file_name %&gt;] = &lt;%= file_name %&gt; ? &lt;%= table_name %&gt;(&lt;%= file_name %&gt;).id : nil
+    @request.session[:&lt;%= file_name %&gt;_id] = &lt;%= file_name %&gt; ? &lt;%= table_name %&gt;(&lt;%= file_name %&gt;).id : nil
   end
 
-  def authorize_as(user)
-    @request.env[&quot;HTTP_AUTHORIZATION&quot;] = user ? &quot;Basic #{Base64.encode64(&quot;#{users(user).login}:test&quot;)}&quot; : nil
+  def authorize_as(&lt;%= file_name %&gt;)
+    @request.env[&quot;HTTP_AUTHORIZATION&quot;] = &lt;%= file_name %&gt; ? ActionController::HttpAuthentication::Basic.encode_credentials(&lt;%= table_name %&gt;(&lt;%= file_name %&gt;).login, 'monkey') : nil
   end
-end
\ No newline at end of file
+  
+&lt;% if options[:rspec] -%&gt;
+  # rspec
+  def mock_&lt;%= file_name %&gt;
+    &lt;%= file_name %&gt; = mock_model(&lt;%= class_name %&gt;, :id =&gt; 1,
+      :login  =&gt; 'user_name',
+      :name   =&gt; 'U. Surname',
+      :to_xml =&gt; &quot;&lt;%= class_name %&gt;-in-XML&quot;, :to_json =&gt; &quot;&lt;%= class_name %&gt;-in-JSON&quot;, 
+      :errors =&gt; [])
+    &lt;%= file_name %&gt;
+  end  
+&lt;% end -%&gt;
+end</diff>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,24 +8,36 @@ class &lt;%= controller_class_name %&gt;Controller &lt; ApplicationController
   end
 
   def create
-    self.current_&lt;%= file_name %&gt; = &lt;%= class_name %&gt;.authenticate(params[:login], params[:password])
-    if logged_in?
-      if params[:remember_me] == &quot;1&quot;
-        self.current_&lt;%= file_name %&gt;.remember_me
-        cookies[:auth_token] = { :value =&gt; self.current_&lt;%= file_name %&gt;.remember_token , :expires =&gt; self.current_&lt;%= file_name %&gt;.remember_token_expires_at }
-      end
+    logout_keeping_session!
+    &lt;%= file_name %&gt; = &lt;%= class_name %&gt;.authenticate(params[:login], params[:password])
+    if &lt;%= file_name %&gt;
+      # Protects against session fixation attacks, causes request forgery
+      # protection if user resubmits an earlier form using back
+      # button. Uncomment if you understand the tradeoffs.
+      # reset_session
+      self.current_&lt;%= file_name %&gt; = &lt;%= file_name %&gt;
+      new_cookie_flag = (params[:remember_me] == &quot;1&quot;)
+      handle_remember_cookie! new_cookie_flag
       redirect_back_or_default('/')
       flash[:notice] = &quot;Logged in successfully&quot;
     else
+      note_failed_signin
+      @login       = params[:login]
+      @remember_me = params[:remember_me]
       render :action =&gt; 'new'
     end
   end
 
   def destroy
-    self.current_&lt;%= file_name %&gt;.forget_me if logged_in?
-    cookies.delete :auth_token
-    reset_session
+    logout_killing_session!
     flash[:notice] = &quot;You have been logged out.&quot;
     redirect_back_or_default('/')
   end
+
+protected
+  # Track failed login attempts
+  def note_failed_signin
+    flash[:error] = &quot;Couldn't log you in as '#{params[:login]}'&quot;
+    logger.warn &quot;Failed login for '#{params[:login]}' from #{request.remote_ip} at #{Time.now.utc}&quot;
+  end
 end</diff>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,19 +1,23 @@
 class &lt;%= migration_name %&gt; &lt; ActiveRecord::Migration
   def self.up
     create_table &quot;&lt;%= table_name %&gt;&quot;, :force =&gt; true do |t|
-      t.column :login,                     :string
-      t.column :email,                     :string
+      t.column :login,                     :string, :limit =&gt; 40
+      t.column :name,                      :string, :limit =&gt; 100, :default =&gt; '', :null =&gt; true
+      t.column :email,                     :string, :limit =&gt; 100
       t.column :crypted_password,          :string, :limit =&gt; 40
       t.column :salt,                      :string, :limit =&gt; 40
       t.column :created_at,                :datetime
       t.column :updated_at,                :datetime
-      t.column :remember_token,            :string
+      t.column :remember_token,            :string, :limit =&gt; 40
       t.column :remember_token_expires_at, :datetime
-      &lt;% if options[:include_activation] %&gt;t.column :activation_code, :string, :limit =&gt; 40
-      t.column :activated_at, :datetime&lt;% end %&gt;
-      &lt;% if options[:stateful] %&gt;t.column :state, :string, :null =&gt; :no, :default =&gt; 'passive'
-      t.column :deleted_at, :datetime&lt;% end %&gt;
+&lt;% if options[:include_activation] -%&gt;
+      t.column :activation_code,           :string, :limit =&gt; 40
+      t.column :activated_at,              :datetime&lt;% end %&gt;
+&lt;% if options[:stateful] -%&gt;
+      t.column :state,                     :string, :null =&gt; :no, :default =&gt; 'passive'
+      t.column :deleted_at,                :datetime&lt;% end %&gt;
     end
+    add_index :&lt;%= table_name %&gt;, :login, :unique =&gt; true
   end
 
   def self.down</diff>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/migration.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,141 +1,83 @@
 require 'digest/sha1'
-class &lt;%= class_name %&gt; &lt; ActiveRecord::Base
-  # Virtual attribute for the unencrypted password
-  attr_accessor :password
 
-  validates_presence_of     :login, :email
-  validates_presence_of     :password,                   :if =&gt; :password_required?
-  validates_presence_of     :password_confirmation,      :if =&gt; :password_required?
-  validates_length_of       :password, :within =&gt; 4..40, :if =&gt; :password_required?
-  validates_confirmation_of :password,                   :if =&gt; :password_required?
+class &lt;%= class_name %&gt; &lt; ActiveRecord::Base
+  include Authentication
+  include Authentication::ByPassword
+  include Authentication::ByCookieToken
+&lt;% if options[:aasm] -%&gt;
+  include Authorization::AasmRoles
+&lt;% elsif options[:stateful] -%&gt;
+  include Authorization::StatefulRoles&lt;% end %&gt;
+  validates_presence_of     :login
   validates_length_of       :login,    :within =&gt; 3..40
-  validates_length_of       :email,    :within =&gt; 3..100
-  validates_uniqueness_of   :login, :email, :case_sensitive =&gt; false
-  before_save :encrypt_password
+  validates_uniqueness_of   :login
+  validates_format_of       :login,    :with =&gt; Authentication.login_regex, :message =&gt; Authentication.bad_login_message
+
+  validates_format_of       :name,     :with =&gt; Authentication.name_regex,  :message =&gt; Authentication.bad_name_message, :allow_nil =&gt; true
+  validates_length_of       :name,     :maximum =&gt; 100
+
+  validates_presence_of     :email
+  validates_length_of       :email,    :within =&gt; 6..100 #r@a.wk
+  validates_uniqueness_of   :email
+  validates_format_of       :email,    :with =&gt; Authentication.email_regex, :message =&gt; Authentication.bad_email_message
+
   &lt;% if options[:include_activation] &amp;&amp; !options[:stateful] %&gt;before_create :make_activation_code &lt;% end %&gt;
+
+  # HACK HACK HACK -- how to do attr_accessible from here?
   # prevents a user from submitting a crafted form that bypasses activation
   # anything else you want your user to change should be added here.
-  attr_accessible :login, :email, :password, :password_confirmation
-&lt;% if options[:stateful] %&gt;
-  acts_as_state_machine :initial =&gt; :pending
-  state :passive
-  state :pending, :enter =&gt; :make_activation_code
-  state :active,  :enter =&gt; :do_activate
-  state :suspended
-  state :deleted, :enter =&gt; :do_delete
+  attr_accessible :login, :email, :name, :password, :password_confirmation
 
-  event :register do
-    transitions :from =&gt; :passive, :to =&gt; :pending, :guard =&gt; Proc.new {|u| !(u.crypted_password.blank? &amp;&amp; u.password.blank?) }
-  end
-  
-  event :activate do
-    transitions :from =&gt; :pending, :to =&gt; :active 
-  end
-  
-  event :suspend do
-    transitions :from =&gt; [:passive, :pending, :active], :to =&gt; :suspended
-  end
-  
-  event :delete do
-    transitions :from =&gt; [:passive, :pending, :active, :suspended], :to =&gt; :deleted
-  end
-
-  event :unsuspend do
-    transitions :from =&gt; :suspended, :to =&gt; :active,  :guard =&gt; Proc.new {|u| !u.activated_at.blank? }
-    transitions :from =&gt; :suspended, :to =&gt; :pending, :guard =&gt; Proc.new {|u| !u.activation_code.blank? }
-    transitions :from =&gt; :suspended, :to =&gt; :passive
-  end
-&lt;% elsif options[:include_activation] %&gt;
+&lt;% if options[:include_activation] &amp;&amp; !options[:stateful] %&gt;
   # Activates the user in the database.
-  def activate
+  def activate!
     @activated = true
     self.activated_at = Time.now.utc
     self.activation_code = nil
     save(false)
   end
 
+  # Returns true if the user has just been activated.
+  def recently_activated?
+    @activated
+  end
+
   def active?
     # the existence of an activation code means they have not activated yet
     activation_code.nil?
-  end
+  end&lt;% end %&gt;
 
-  # Returns true if the user has just been activated.
-  def pending?
-    @activated
-  end
-&lt;% end %&gt;
   # Authenticates a user by their login name and unencrypted password.  Returns the user or nil.
+  #
+  # uff.  this is really an authorization, not authentication routine.  
+  # We really need a Dispatch Chain here or something.
+  # This will also let us return a human error message.
+  #
   def self.authenticate(login, password)
-    u = &lt;% 
-    if options[:stateful] %&gt;find_in_state :first, :active, :conditions =&gt; {:login =&gt; login}&lt;%
-    elsif options[:include_activation] %&gt;find :first, :conditions =&gt; ['login = ? and activated_at IS NOT NULL', login]&lt;% 
-    else %&gt;find_by_login(login)&lt;% 
-    end %&gt; # need to get the salt
+    return nil if login.blank? || password.blank?
+    u = &lt;% if    options[:stateful]           %&gt;find_in_state :first, :active, :conditions =&gt; {:login =&gt; login}&lt;%
+           elsif options[:include_activation] %&gt;find :first, :conditions =&gt; ['login = ? and activated_at IS NOT NULL', login]&lt;%
+           else %&gt;find_by_login(login)&lt;% end %&gt; # need to get the salt
     u &amp;&amp; u.authenticated?(password) ? u : nil
   end
 
-  # Encrypts some data with the salt.
-  def self.encrypt(password, salt)
-    Digest::SHA1.hexdigest(&quot;--#{salt}--#{password}--&quot;)
-  end
-
-  # Encrypts the password with the user salt
-  def encrypt(password)
-    self.class.encrypt(password, salt)
-  end
-
-  def authenticated?(password)
-    crypted_password == encrypt(password)
-  end
-
-  def remember_token?
-    remember_token_expires_at &amp;&amp; Time.now.utc &lt; remember_token_expires_at 
-  end
-
-  # These create and unset the fields required for remembering users between browser closes
-  def remember_me
-    remember_me_for 2.weeks
+  def login=(value)
+    write_attribute :login, (value ? value.downcase : nil)
   end
 
-  def remember_me_for(time)
-    remember_me_until time.from_now.utc
-  end
-
-  def remember_me_until(time)
-    self.remember_token_expires_at = time
-    self.remember_token            = encrypt(&quot;#{email}--#{remember_token_expires_at}&quot;)
-    save(false)
-  end
-
-  def forget_me
-    self.remember_token_expires_at = nil
-    self.remember_token            = nil
-    save(false)
+  def email=(value)
+    write_attribute :email, (value ? value.downcase : nil)
   end
 
   protected
-    # before filter 
-    def encrypt_password
-      return if password.blank?
-      self.salt = Digest::SHA1.hexdigest(&quot;--#{Time.now.to_s}--#{login}--&quot;) if new_record?
-      self.crypted_password = encrypt(password)
-    end
-      
-    def password_required?
-      crypted_password.blank? || !password.blank?
-    end
-    &lt;% if options[:include_activation] %&gt;
+    
+&lt;% if options[:include_activation] -%&gt;
     def make_activation_code
-&lt;% if options[:stateful] %&gt;      self.deleted_at = nil&lt;% end %&gt;
-      self.activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
-    end&lt;% end %&gt;
-    &lt;% if options[:stateful] %&gt;
-    def do_delete
-      self.deleted_at = Time.now.utc
+  &lt;% if options[:stateful] -%&gt;
+      self.deleted_at = nil
+  &lt;% end -%&gt;
+      self.activation_code = self.class.make_token
     end
+&lt;% end %&gt;
 
-    def do_activate
-      self.activated_at = Time.now.utc
-      self.deleted_at = self.activation_code = nil
-    end&lt;% end %&gt;
 end</diff>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/model.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,56 +9,77 @@ class &lt;%= model_controller_class_name %&gt;Controller &lt; ApplicationController
 
   # render new.rhtml
   def new
+    @&lt;%= file_name %&gt; = &lt;%= class_name %&gt;.new
   end
-
+ 
   def create
-    cookies.delete :auth_token
-    # protects against session fixation attacks, wreaks havoc with 
-    # request forgery protection.
-    # uncomment at your own risk
-    # reset_session
+    logout_keeping_session!
     @&lt;%= file_name %&gt; = &lt;%= class_name %&gt;.new(params[:&lt;%= file_name %&gt;])
-&lt;% if options[:stateful] %&gt;    raise ActiveRecord::RecordInvalid.new(@user) unless @user.valid?&lt;% end %&gt;
-    @&lt;%= file_name %&gt;.&lt;% if options[:stateful] %&gt;register&lt;% else %&gt;save&lt;% end %&gt;!
-    self.current_&lt;%= file_name %&gt; = @&lt;%= file_name %&gt;
-    redirect_back_or_default('/')
-    flash[:notice] = &quot;Thanks for signing up!&quot;
-  rescue ActiveRecord::RecordInvalid
-    render :action =&gt; 'new'
+&lt;% if options[:stateful] -%&gt;
+    @&lt;%= file_name %&gt;.register! if @&lt;%= file_name %&gt; &amp;&amp; @&lt;%= file_name %&gt;.valid?
+    success = @&lt;%= file_name %&gt; &amp;&amp; @&lt;%= file_name %&gt;.valid?
+&lt;% else -%&gt;
+    success = @&lt;%= file_name %&gt; &amp;&amp; @&lt;%= file_name %&gt;.save
+&lt;% end -%&gt;
+    if success &amp;&amp; @&lt;%= file_name %&gt;.errors.empty?
+      &lt;% if !options[:include_activation] -%&gt;
+      # Protects against session fixation attacks, causes request forgery
+      # protection if visitor resubmits an earlier form using back
+      # button. Uncomment if you understand the tradeoffs.
+      # reset session
+      self.current_&lt;%= file_name %&gt; = @&lt;%= file_name %&gt; # !! now logged in
+      &lt;% end -%&gt;redirect_back_or_default('/')
+      flash[:notice] = &quot;Thanks for signing up!  We're sending you an email with your activation code.&quot;
+    else
+      flash[:error]  = &quot;We couldn't set up that account, sorry.  Please try again, or contact an admin (link is above).&quot;
+      render :action =&gt; 'new'
+    end
   end
 &lt;% if options[:include_activation] %&gt;
   def activate
-    self.current_&lt;%= file_name %&gt; = params[:activation_code].blank? ? :false : &lt;%= class_name %&gt;.find_by_activation_code(params[:activation_code])
-    if logged_in? &amp;&amp; !current_&lt;%= file_name %&gt;.active?
-      current_&lt;%= file_name %&gt;.activate&lt;% if options[:stateful] %&gt;!&lt;% end %&gt;
-      flash[:notice] = &quot;Signup complete!&quot;
+    logout_keeping_session!
+    &lt;%= file_name %&gt; = &lt;%= class_name %&gt;.find_by_activation_code(params[:activation_code]) unless params[:activation_code].blank?
+    case
+    when (!params[:activation_code].blank?) &amp;&amp; &lt;%= file_name %&gt; &amp;&amp; !&lt;%= file_name %&gt;.active?
+      &lt;%= file_name %&gt;.activate!
+      flash[:notice] = &quot;Signup complete! Please sign in to continue.&quot;
+      redirect_to '/login'
+    when params[:activation_code].blank?
+      flash[:error] = &quot;The activation code was missing.  Please follow the URL from your email.&quot;
+      redirect_back_or_default('/')
+    else 
+      flash[:error]  = &quot;We couldn't find a &lt;%= file_name %&gt; with that activation code -- check your email? Or maybe you've already activated -- try signing in.&quot;
+      redirect_back_or_default('/')
     end
-    redirect_back_or_default('/')
   end
 &lt;% end %&gt;&lt;% if options[:stateful] %&gt;
   def suspend
-    @user.suspend! 
-    redirect_to users_url
+    @&lt;%= file_name %&gt;.suspend! 
+    redirect_to &lt;%= model_controller_routing_name %&gt;_path
   end
 
   def unsuspend
-    @user.unsuspend! 
-    redirect_to users_url
+    @&lt;%= file_name %&gt;.unsuspend! 
+    redirect_to &lt;%= model_controller_routing_name %&gt;_path
   end
 
   def destroy
-    @user.delete!
-    redirect_to users_url
+    @&lt;%= file_name %&gt;.delete!
+    redirect_to &lt;%= model_controller_routing_name %&gt;_path
   end
 
   def purge
-    @user.destroy
-    redirect_to users_url
+    @&lt;%= file_name %&gt;.destroy
+    redirect_to &lt;%= model_controller_routing_name %&gt;_path
   end
+  
+  # There's no page here to update or destroy a &lt;%= file_name %&gt;.  If you add those, be
+  # smart -- make sure you check that the visitor is authorized to do so, that they
+  # supply their old password along with a new one to update it, etc.
 
 protected
   def find_&lt;%= file_name %&gt;
-    @&lt;%= file_name %&gt; = User.find(params[:id])
+    @&lt;%= file_name %&gt; = &lt;%= class_name %&gt;.find(params[:id])
   end
-&lt;% end %&gt;
+&lt;% end -%&gt;
 end</diff>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/model_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,93 @@
 module &lt;%= model_controller_class_name %&gt;Helper
-end
\ No newline at end of file
+  
+  #
+  # Use this to wrap view elements that the user can't access.
+  # !! Note: this is an *interface*, not *security* feature !!
+  # You need to do all access control at the controller level.
+  #
+  # Example:
+  # &lt;%%= if_authorized?(:index,   User)  do link_to('List all users', users_path) end %&gt; |
+  # &lt;%%= if_authorized?(:edit,    @user) do link_to('Edit this user', edit_user_path) end %&gt; |
+  # &lt;%%= if_authorized?(:destroy, @user) do link_to 'Destroy', @user, :confirm =&gt; 'Are you sure?', :method =&gt; :delete end %&gt; 
+  #
+  #
+  def if_authorized?(action, resource, &amp;block)
+    if authorized?(action, resource)
+      yield action, resource
+    end
+  end
+
+  #
+  # Link to user's page ('&lt;%= table_name %&gt;/1')
+  #
+  # By default, their login is used as link text and link title (tooltip)
+  #
+  # Takes options
+  # * :content_text =&gt; 'Content text in place of &lt;%= file_name %&gt;.login', escaped with
+  #   the standard h() function.
+  # * :content_method =&gt; :&lt;%= file_name %&gt;_instance_method_to_call_for_content_text
+  # * :title_method =&gt; :&lt;%= file_name %&gt;_instance_method_to_call_for_title_attribute
+  # * as well as link_to()'s standard options
+  #
+  # Examples:
+  #   link_to_&lt;%= file_name %&gt; @&lt;%= file_name %&gt;
+  #   # =&gt; &lt;a href=&quot;/&lt;%= table_name %&gt;/3&quot; title=&quot;barmy&quot;&gt;barmy&lt;/a&gt;
+  #
+  #   # if you've added a .name attribute:
+  #  content_tag :span, :class =&gt; :vcard do
+  #    (link_to_&lt;%= file_name %&gt; &lt;%= file_name %&gt;, :class =&gt; 'fn n', :title_method =&gt; :login, :content_method =&gt; :name) +
+  #          ': ' + (content_tag :span, &lt;%= file_name %&gt;.email, :class =&gt; 'email')
+  #   end
+  #   # =&gt; &lt;span class=&quot;vcard&quot;&gt;&lt;a href=&quot;/&lt;%= table_name %&gt;/3&quot; title=&quot;barmy&quot; class=&quot;fn n&quot;&gt;Cyril Fotheringay-Phipps&lt;/a&gt;: &lt;span class=&quot;email&quot;&gt;barmy@blandings.com&lt;/span&gt;&lt;/span&gt;
+  #
+  #   link_to_&lt;%= file_name %&gt; @&lt;%= file_name %&gt;, :content_text =&gt; 'Your user page'
+  #   # =&gt; &lt;a href=&quot;/&lt;%= table_name %&gt;/3&quot; title=&quot;barmy&quot; class=&quot;nickname&quot;&gt;Your user page&lt;/a&gt;
+  #
+  def link_to_&lt;%= file_name %&gt;(&lt;%= file_name %&gt;, options={})
+    raise &quot;Invalid &lt;%= file_name %&gt;&quot; unless &lt;%= file_name %&gt;
+    options.reverse_merge! :content_method =&gt; :login, :title_method =&gt; :login, :class =&gt; :nickname
+    content_text      = options.delete(:content_text)
+    content_text    ||= &lt;%= file_name %&gt;.send(options.delete(:content_method))
+    options[:title] ||= &lt;%= file_name %&gt;.send(options.delete(:title_method))
+    link_to h(content_text), &lt;%= model_controller_routing_name.singularize %&gt;_path(&lt;%= file_name %&gt;), options
+  end
+
+  #
+  # Link to login page using remote ip address as link content
+  #
+  # The :title (and thus, tooltip) is set to the IP address 
+  #
+  # Examples:
+  #   link_to_login_with_IP
+  #   # =&gt; &lt;a href=&quot;/login&quot; title=&quot;169.69.69.69&quot;&gt;169.69.69.69&lt;/a&gt;
+  #
+  #   link_to_login_with_IP :content_text =&gt; 'not signed in'
+  #   # =&gt; &lt;a href=&quot;/login&quot; title=&quot;169.69.69.69&quot;&gt;not signed in&lt;/a&gt;
+  #
+  def link_to_login_with_IP content_text=nil, options={}
+    ip_addr           = request.remote_ip
+    content_text    ||= ip_addr
+    options.reverse_merge! :title =&gt; ip_addr
+    if tag = options.delete(:tag)
+      content_tag tag, h(content_text), options
+    else
+      link_to h(content_text), login_path, options
+    end
+  end
+
+  #
+  # Link to the current user's page (using link_to_&lt;%= file_name %&gt;) or to the login page
+  # (using link_to_login_with_IP).
+  #
+  def link_to_current_&lt;%= file_name %&gt;(options={})
+    if current_&lt;%= file_name %&gt;
+      link_to_&lt;%= file_name %&gt; current_&lt;%= file_name %&gt;, options
+    else
+      content_text = options.delete(:content_text) || 'not signed in'
+      # kill ignored options from link_to_&lt;%= file_name %&gt;
+      [:content_method, :title_method].each{|opt| options.delete(opt)} 
+      link_to_login_with_IP content_text, options
+    end
+  end
+
+end</diff>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/model_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ class &lt;%= class_name %&gt;Observer &lt; ActiveRecord::Observer
 
   def after_save(&lt;%= file_name %&gt;)
   &lt;% if options[:include_activation] %&gt;
-    &lt;%= class_name %&gt;Mailer.deliver_activation(&lt;%= file_name %&gt;) if &lt;%= file_name %&gt;.pending?
+    &lt;%= class_name %&gt;Mailer.deliver_activation(&lt;%= file_name %&gt;) if &lt;%= file_name %&gt;.recently_activated?
   &lt;% end %&gt;
   end
 end</diff>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/observer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,25 @@
 === In Development (git clone git://github.com/dchelimsky/rspec-rails.git)
 
+IMPORTANT: use 'script/autospec' (or just 'autospec' if you have the rspec gem
+installed) instead of 'autotest'. We changed the way autotest discovers rspec
+so the autotest executable won't automatically load rspec anymore. This allows
+rspec to live side by side other spec frameworks without always co-opting
+autotest through autotest's discovery mechanism.
+
+ALSO IMPORTANT: Rails v2.1.1 changed assert_select_rjs such that it doesn't
+always fail when it should. Please see
+http://rails.lighthouseapp.com/projects/8994/tickets/982.
+
+* Generated route specs have shorter names, making it less painful to modify their implementation
 * Add conditional so Rails 2.1.0 doesn't warn about cache_template_extensions (patch from James Herdman)
 * Fixed stub_model examples to work with Rails 2.1.0 (the code was fine, just the examples needed patching)
 * use hoe for build/release
 * reworked generated examples for rspec_scaffold - thanks to Mikel Lindsaar and Dan Manges for their feedback
 * bye, bye translator
 * Added proxy to cookies so you can set them in examples the same way you set them in controllers
+* Added script/autospec so you can run autospec without installing the gem
+* Support --skip-fixture in the rspec_model generator (patches from Alex Tomlins and Niels Ganser)
+* Add mock_model#as_new_record (patch from Zach Dennis)
 
 === Version 1.1.4
 </diff>
      <filename>vendor/plugins/rspec-rails/History.txt</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,4 @@
-.gitignore
 History.txt
-MIT-LICENSE
 Manifest.txt
 README.txt
 Rakefile
@@ -11,6 +9,7 @@ generators/rspec/templates/all_stories.rb
 generators/rspec/templates/previous_failures.txt
 generators/rspec/templates/rcov.opts
 generators/rspec/templates/rspec.rake
+generators/rspec/templates/script/autospec
 generators/rspec/templates/script/spec
 generators/rspec/templates/script/spec_server
 generators/rspec/templates/spec.opts
@@ -21,6 +20,7 @@ generators/rspec_controller/rspec_controller_generator.rb
 generators/rspec_controller/templates/controller_spec.rb
 generators/rspec_controller/templates/helper_spec.rb
 generators/rspec_controller/templates/view_spec.rb
+generators/rspec_default_values.rb
 generators/rspec_model/USAGE
 generators/rspec_model/rspec_model_generator.rb
 generators/rspec_model/templates/model_spec.rb
@@ -39,6 +39,7 @@ lib/spec/rails.rb
 lib/spec/rails/example.rb
 lib/spec/rails/example/assigns_hash_proxy.rb
 lib/spec/rails/example/controller_example_group.rb
+lib/spec/rails/example/cookies_proxy.rb
 lib/spec/rails/example/functional_example_group.rb
 lib/spec/rails/example/helper_example_group.rb
 lib/spec/rails/example/model_example_group.rb
@@ -54,6 +55,7 @@ lib/spec/rails/extensions/active_record/base.rb
 lib/spec/rails/extensions/object.rb
 lib/spec/rails/extensions/spec/example/configuration.rb
 lib/spec/rails/extensions/spec/matchers/have.rb
+lib/spec/rails/interop/testcase.rb
 lib/spec/rails/matchers.rb
 lib/spec/rails/matchers/assert_select.rb
 lib/spec/rails/matchers/have_text.rb
@@ -64,11 +66,11 @@ lib/spec/rails/mocks.rb
 lib/spec/rails/story_adapter.rb
 lib/spec/rails/version.rb
 spec/rails/autotest/mappings_spec.rb
-spec/rails/autotest/rails_rspec_spec.rb
 spec/rails/example/assigns_hash_proxy_spec.rb
 spec/rails/example/configuration_spec.rb
 spec/rails/example/controller_isolation_spec.rb
 spec/rails/example/controller_spec_spec.rb
+spec/rails/example/cookies_proxy_spec.rb
 spec/rails/example/example_group_factory_spec.rb
 spec/rails/example/helper_spec_spec.rb
 spec/rails/example/model_spec_spec.rb
@@ -78,13 +80,14 @@ spec/rails/example/view_spec_spec.rb
 spec/rails/extensions/action_controller_rescue_action_spec.rb
 spec/rails/extensions/action_view_base_spec.rb
 spec/rails/extensions/active_record_spec.rb
+spec/rails/interop/testcase_spec.rb
 spec/rails/matchers/assert_select_spec.rb
 spec/rails/matchers/description_generation_spec.rb
 spec/rails/matchers/errors_on_spec.rb
 spec/rails/matchers/have_text_spec.rb
 spec/rails/matchers/include_text_spec.rb
 spec/rails/matchers/redirect_to_spec.rb
-spec/rails/matchers/render_spec.rb
+spec/rails/matchers/render_template_spec.rb
 spec/rails/mocks/ar_classes.rb
 spec/rails/mocks/mock_model_spec.rb
 spec/rails/mocks/stub_model_spec.rb
@@ -109,7 +112,11 @@ spec_resources/views/controller_spec/action_setting_flash_before_session_reset.r
 spec_resources/views/controller_spec/action_setting_the_assigns_hash.rhtml
 spec_resources/views/controller_spec/action_with_errors_in_template.rhtml
 spec_resources/views/controller_spec/action_with_template.rhtml
+spec_resources/views/layouts/application.rhtml
+spec_resources/views/layouts/simple.rhtml
+spec_resources/views/objects/_object.html.erb
 spec_resources/views/render_spec/_a_partial.rhtml
+spec_resources/views/render_spec/action_with_alternate_layout.rhtml
 spec_resources/views/render_spec/some_action.js.rjs
 spec_resources/views/render_spec/some_action.rhtml
 spec_resources/views/render_spec/some_action.rjs
@@ -131,6 +138,7 @@ spec_resources/views/view_spec/_partial_with_local_variable.rhtml
 spec_resources/views/view_spec/_partial_with_sub_partial.rhtml
 spec_resources/views/view_spec/_spacer.rhtml
 spec_resources/views/view_spec/accessor.rhtml
+spec_resources/views/view_spec/block_helper.rhtml
 spec_resources/views/view_spec/entry_form.rhtml
 spec_resources/views/view_spec/explicit_helper.rhtml
 spec_resources/views/view_spec/foo/show.rhtml
@@ -140,6 +148,7 @@ spec_resources/views/view_spec/template_with_partial.rhtml
 spec_resources/views/view_spec/template_with_partial_using_collection.rhtml
 spec_resources/views/view_spec/template_with_partial_with_array.rhtml
 stories/all.rb
+stories/configuration/stories.rb
 stories/helper.rb
 stories/steps/people.rb
 stories/transactions_should_rollback</diff>
      <filename>vendor/plugins/rspec-rails/Manifest.txt</filename>
    </modified>
    <modified>
      <diff>@@ -14,13 +14,16 @@ class RspecGenerator &lt; Rails::Generator::Base
     record do |m|
       script_options     = { :chmod =&gt; 0755, :shebang =&gt; options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang] }
 
+      m.file      'rspec.rake',                    'lib/tasks/rspec.rake'
+
+      m.file      'script/autospec',               'script/autospec',    script_options
+      m.file      'script/spec',                   'script/spec',        script_options
+      m.file      'script/spec_server',            'script/spec_server', script_options
+
       m.directory 'spec'
-      m.template  'spec_helper.rb',                'spec/spec_helper.rb'
-      m.file      'spec.opts',                     'spec/spec.opts'
       m.file      'rcov.opts',                     'spec/rcov.opts'
-      m.file      'script/spec_server',            'script/spec_server', script_options
-      m.file      'script/spec',                   'script/spec',        script_options
-      m.file      'rspec.rake',                    'lib/tasks/rspec.rake'
+      m.file      'spec.opts',                     'spec/spec.opts'
+      m.template  'spec_helper.rb',                'spec/spec_helper.rb'
 
       m.directory 'stories'
       m.file      'all_stories.rb',                'stories/all.rb'</diff>
      <filename>vendor/plugins/rspec-rails/generators/rspec/rspec_generator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 require 'rails_generator/generators/components/model/model_generator'
+require File.dirname(__FILE__) + '/../rspec_default_values'
 
 class RspecModelGenerator &lt; ModelGenerator
 
@@ -11,12 +12,16 @@ class RspecModelGenerator &lt; ModelGenerator
       # Model, spec, and fixture directories.
       m.directory File.join('app/models', class_path)
       m.directory File.join('spec/models', class_path)
-      m.directory File.join('spec/fixtures', class_path)
+      unless options[:skip_fixture]
+        m.directory File.join('spec/fixtures', class_path)
+      end
 
       # Model class, spec and fixtures.
       m.template 'model:model.rb',      File.join('app/models', class_path, &quot;#{file_name}.rb&quot;)
-      m.template 'model:fixtures.yml',  File.join('spec/fixtures', class_path, &quot;#{table_name}.yml&quot;)
       m.template 'model_spec.rb',       File.join('spec/models', class_path, &quot;#{file_name}_spec.rb&quot;)
+      unless options[:skip_fixture]
+        m.template 'model:fixtures.yml',  File.join('spec/fixtures', &quot;#{table_name}.yml&quot;)
+      end
 
       unless options[:skip_migration]
         m.migration_template 'model:migration.rb', 'db/migrate', :assigns =&gt; {</diff>
      <filename>vendor/plugins/rspec-rails/generators/rspec_model/rspec_model_generator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,5 @@
+require File.dirname(__FILE__) + '/../rspec_default_values'
+
 class RspecScaffoldGenerator &lt; Rails::Generator::NamedBase
   default_options :skip_migration =&gt; false
   
@@ -140,20 +142,6 @@ end
 module Rails
   module Generator
     class GeneratedAttribute
-      def default_value
-        @default_value ||= case type
-          when :int, :integer               then &quot;\&quot;1\&quot;&quot;
-          when :float                       then &quot;\&quot;1.5\&quot;&quot;
-          when :decimal                     then &quot;\&quot;9.99\&quot;&quot;
-          when :datetime, :timestamp, :time then &quot;Time.now&quot;
-          when :date                        then &quot;Date.today&quot;
-          when :string, :text               then &quot;\&quot;value for #{@name}\&quot;&quot;
-          when :boolean                     then &quot;false&quot;
-          else
-            &quot;&quot;
-        end      
-      end
-
       def input_type
         @input_type ||= case type
           when :text                        then &quot;textarea&quot;</diff>
      <filename>vendor/plugins/rspec-rails/generators/rspec_scaffold/rspec_scaffold_generator.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,59 +2,57 @@ require File.expand_path(File.dirname(__FILE__) + '&lt;%= '/..' * class_nesting_dep
 
 describe &lt;%= controller_class_name %&gt;Controller do
   describe &quot;route generation&quot; do
-
-    it &quot;should map { :controller =&gt; '&lt;%= table_name %&gt;', :action =&gt; 'index' } to /&lt;%= table_name %&gt;&quot; do
+    it &quot;should map #index&quot; do
       route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;index&quot;).should == &quot;/&lt;%= table_name %&gt;&quot;
     end
   
-    it &quot;should map { :controller =&gt; '&lt;%= table_name %&gt;', :action =&gt; 'new' } to /&lt;%= table_name %&gt;/new&quot; do
+    it &quot;should map #new&quot; do
       route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;new&quot;).should == &quot;/&lt;%= table_name %&gt;/new&quot;
     end
   
-    it &quot;should map { :controller =&gt; '&lt;%= table_name %&gt;', :action =&gt; 'show', :id =&gt; 1 } to /&lt;%= table_name %&gt;/1&quot; do
+    it &quot;should map #show&quot; do
       route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;show&quot;, :id =&gt; 1).should == &quot;/&lt;%= table_name %&gt;/1&quot;
     end
   
-    it &quot;should map { :controller =&gt; '&lt;%= table_name %&gt;', :action =&gt; 'edit', :id =&gt; 1 } to /&lt;%= table_name %&gt;/1&lt;%= resource_edit_path %&gt;&quot; do
+    it &quot;should map #edit&quot; do
       route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;edit&quot;, :id =&gt; 1).should == &quot;/&lt;%= table_name %&gt;/1&lt;%= resource_edit_path %&gt;&quot;
     end
   
-    it &quot;should map { :controller =&gt; '&lt;%= table_name %&gt;', :action =&gt; 'update', :id =&gt; 1} to /&lt;%= table_name %&gt;/1&quot; do
+    it &quot;should map #update&quot; do
       route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;update&quot;, :id =&gt; 1).should == &quot;/&lt;%= table_name %&gt;/1&quot;
     end
   
-    it &quot;should map { :controller =&gt; '&lt;%= table_name %&gt;', :action =&gt; 'destroy', :id =&gt; 1} to /&lt;%= table_name %&gt;/1&quot; do
+    it &quot;should map #destroy&quot; do
       route_for(:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;destroy&quot;, :id =&gt; 1).should == &quot;/&lt;%= table_name %&gt;/1&quot;
     end
   end
 
   describe &quot;route recognition&quot; do
-
-    it &quot;should generate params { :controller =&gt; '&lt;%= table_name %&gt;', action =&gt; 'index' } from GET /&lt;%= table_name %&gt;&quot; do
+    it &quot;should generate params for #index&quot; do
       params_from(:get, &quot;/&lt;%= table_name %&gt;&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;index&quot;}
     end
   
-    it &quot;should generate params { :controller =&gt; '&lt;%= table_name %&gt;', action =&gt; 'new' } from GET /&lt;%= table_name %&gt;/new&quot; do
+    it &quot;should generate params for #new&quot; do
       params_from(:get, &quot;/&lt;%= table_name %&gt;/new&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;new&quot;}
     end
   
-    it &quot;should generate params { :controller =&gt; '&lt;%= table_name %&gt;', action =&gt; 'create' } from POST /&lt;%= table_name %&gt;&quot; do
+    it &quot;should generate params for #create&quot; do
       params_from(:post, &quot;/&lt;%= table_name %&gt;&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;create&quot;}
     end
   
-    it &quot;should generate params { :controller =&gt; '&lt;%= table_name %&gt;', action =&gt; 'show', id =&gt; '1' } from GET /&lt;%= table_name %&gt;/1&quot; do
+    it &quot;should generate params for #show&quot; do
       params_from(:get, &quot;/&lt;%= table_name %&gt;/1&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;show&quot;, :id =&gt; &quot;1&quot;}
     end
   
-    it &quot;should generate params { :controller =&gt; '&lt;%= table_name %&gt;', action =&gt; 'edit', id =&gt; '1' } from GET /&lt;%= table_name %&gt;/1;edit&quot; do
+    it &quot;should generate params for #edit&quot; do
       params_from(:get, &quot;/&lt;%= table_name %&gt;/1&lt;%= resource_edit_path %&gt;&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;edit&quot;, :id =&gt; &quot;1&quot;}
     end
   
-    it &quot;should generate params { :controller =&gt; '&lt;%= table_name %&gt;', action =&gt; 'update', id =&gt; '1' } from PUT /&lt;%= table_name %&gt;/1&quot; do
+    it &quot;should generate params for #update&quot; do
       params_from(:put, &quot;/&lt;%= table_name %&gt;/1&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;update&quot;, :id =&gt; &quot;1&quot;}
     end
   
-    it &quot;should generate params { :controller =&gt; '&lt;%= table_name %&gt;', action =&gt; 'destroy', id =&gt; '1' } from DELETE /&lt;%= table_name %&gt;/1&quot; do
+    it &quot;should generate params for #destroy&quot; do
       params_from(:delete, &quot;/&lt;%= table_name %&gt;/1&quot;).should == {:controller =&gt; &quot;&lt;%= table_name %&gt;&quot;, :action =&gt; &quot;destroy&quot;, :id =&gt; &quot;1&quot;}
     end
   end</diff>
      <filename>vendor/plugins/rspec-rails/generators/rspec_scaffold/templates/routing_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -73,9 +73,4 @@ Autotest.add_hook :initialize do |at|
 end
 
 class Autotest::RailsRspec &lt; Autotest::Rspec
-
-  def spec_command
-    &quot;script/spec&quot;
-  end
-    
 end</diff>
      <filename>vendor/plugins/rspec-rails/lib/autotest/rails_rspec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 silence_warnings { RAILS_ENV = &quot;test&quot; }
 
-require 'application'
+require_dependency 'application'
 require 'action_controller/test_process'
 require 'action_controller/integration'
 require 'active_record/fixtures' if defined?(ActiveRecord::Base)
@@ -12,3 +12,4 @@ require 'spec/rails/matchers'
 require 'spec/rails/mocks'
 require 'spec/rails/example'
 require 'spec/rails/extensions'
+require 'spec/rails/interop/testcase'
\ No newline at end of file</diff>
      <filename>vendor/plugins/rspec-rails/lib/spec/rails.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,8 +2,9 @@ module Spec
   module Rails
     module Example
       class AssignsHashProxy #:nodoc:
-        def initialize(object)
-          @object = object
+        def initialize(example_group, &amp;block)
+          @block = block
+          @example_group = example_group
         end
 
         def [](ivar)
@@ -17,8 +18,7 @@ module Spec
         end
 
         def []=(ivar, val)
-          @object.instance_variable_set &quot;@#{ivar}&quot;, val
-          assigns[ivar.to_s] = val
+          @block.call.instance_variable_set(&quot;@#{ivar}&quot;, val)
         end
 
         def delete(name)
@@ -35,7 +35,7 @@ module Spec
 
         protected
         def assigns
-          @object.assigns
+          @example_group.orig_assigns
         end
       end
     end</diff>
      <filename>vendor/plugins/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -158,7 +158,9 @@ module Spec
 
         protected
         def _assigns_hash_proxy
-          @_assigns_hash_proxy ||= AssignsHashProxy.new @controller
+          @_assigns_hash_proxy ||= AssignsHashProxy.new self do
+            @response.template
+          end
         end
 
         private
@@ -183,20 +185,22 @@ module Spec
               unless integrate_views?
                 if @template.respond_to?(:finder)
                   (class &lt;&lt; @template.finder; self; end).class_eval do
-                    define_method :file_exists? do
-                      true
-                    end
+                    define_method :file_exists? do; true; end
                   end
                 else
                   (class &lt;&lt; @template; self; end).class_eval do
-                    define_method :file_exists? do
-                      true
-                    end
+                    define_method :file_exists? do; true; end
                   end
                 end
                 (class &lt;&lt; @template; self; end).class_eval do
                   define_method :render_file do |*args|
-                    @first_render ||= args[0]
+                    @first_render ||= args[0] unless args[0] =~ /^layouts/
+                    @_first_render ||= args[0] unless args[0] =~ /^layouts/
+                  end
+                  
+                  define_method :_pick_template do |*args|
+                    @_first_render ||= args[0] unless args[0] =~ /^layouts/
+                    PickedTemplate.new
                   end
                 end
               end
@@ -206,7 +210,9 @@ module Spec
               expect_render_mock_proxy.render(options, &amp;block)
               @performed_render = true
             else
-              unless matching_stub_exists(options)
+              if matching_stub_exists(options)
+                @performed_render = true
+              else
                 super(options, deprecated_status_or_extra_options, &amp;block)
               end
             end
@@ -266,6 +272,11 @@ module Spec
 
         Spec::Example::ExampleGroupFactory.register(:controller, self)
       end
+      
+      class PickedTemplate
+        def render_template(*ignore_args); end
+        def render_partial(*ignore_args);  end
+      end
     end
   end
 end</diff>
      <filename>vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,12 +8,16 @@ module Spec
           @example = example
         end
       
+        def[]=(name, value)
+          @example.request.cookies[name.to_s] = CGI::Cookie.new(name.to_s, value)
+        end
+        
         def [](name)
           @example.response.cookies[name.to_s]
         end
       
-        def[]=(name, value)
-          @example.request.cookies[name.to_s] = CGI::Cookie.new(name.to_s, value)
+        def delete(name)
+          @example.response.cookies.delete(name.to_s)
         end
       end
     end</diff>
      <filename>vendor/plugins/rspec-rails/lib/spec/rails/example/cookies_proxy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -52,6 +52,8 @@ module Spec
         def cookies
           @cookies ||= Spec::Rails::Example::CookiesProxy.new(self)
         end
+        
+        alias_method :orig_assigns, :assigns
 
         # :call-seq:
         #   assigns()
@@ -78,6 +80,7 @@ module Spec
             _assigns_hash_proxy[key]
           end
         end
+
       end
     end
   end</diff>
      <filename>vendor/plugins/rspec-rails/lib/spec/rails/example/functional_example_group.rb</filename>
    </modified>
    <modified>
      <diff>@@ -148,7 +148,9 @@ module Spec
 
         protected
         def _assigns_hash_proxy
-          @_assigns_hash_proxy ||= AssignsHashProxy.new helper
+          @_assigns_hash_proxy ||= AssignsHashProxy.new self do
+            helper
+          end
         end
 
       end</diff>
      <filename>vendor/plugins/rspec-rails/lib/spec/rails/example/helper_example_group.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,11 +11,15 @@ module Spec
       class RailsExampleGroup &lt; Test::Unit::TestCase
         
         # Rails &gt;= r8570 uses setup/teardown_fixtures explicitly
-        before(:each) do
-          setup_fixtures if self.respond_to?(:setup_fixtures)
-        end
-        after(:each) do
-          teardown_fixtures if self.respond_to?(:teardown_fixtures)
+        # However, Rails &gt;= r8664 extracted these out to use ActiveSupport::Callbacks.
+        # The latter case is handled at the TestCase level, in interop/testcase.rb
+        unless ActiveSupport.const_defined?(:Callbacks) and self.include?(ActiveSupport::Callbacks)
+          before(:each) do
+            setup_fixtures if self.respond_to?(:setup_fixtures)
+          end
+          after(:each) do
+            teardown_fixtures if self.respond_to?(:teardown_fixtures)
+          end
         end
         
         include Spec::Rails::Matchers</diff>
      <filename>vendor/plugins/rspec-rails/lib/spec/rails/example/rails_example_group.rb</filename>
    </modified>
    <modified>
      <diff>@@ -150,7 +150,9 @@ module Spec
 
         protected
         def _assigns_hash_proxy
-          @_assigns_hash_proxy ||= AssignsHashProxy.new @controller
+          @_assigns_hash_proxy ||= AssignsHashProxy.new self do
+            @response.template
+          end
         end
       end
 
@@ -172,6 +174,9 @@ module Spec
             include helper_module
           end
         end
+        
+        def forget_variables_added_to_assigns
+        end
       end
     end
   end</diff>
      <filename>vendor/plugins/rspec-rails/lib/spec/rails/example/view_example_group.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,11 @@ module ActionView #:nodoc:
           end
         end
       end
-      super(partial_path, local_assigns, deprecated_local_assigns)
+      begin
+        super(partial_path, local_assigns, deprecated_local_assigns)
+      rescue ArgumentError # edge rails &gt; 2.1 changed render_partial to accept only one arg
+        super(partial_path)
+      end
     end
 
     alias_method :orig_render, :render</diff>
      <filename>vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -16,6 +16,7 @@ module Spec # :nodoc:
         def matches?(response_or_text, &amp;block)
           if ActionController::TestResponse === response_or_text and
                    response_or_text.headers.key?('Content-Type') and
+                   !response_or_text.headers['Content-Type'].blank? and
                    response_or_text.headers['Content-Type'].to_sym == :xml
             @args.unshift(HTML::Document.new(response_or_text.body, false, true).root)           
           elsif String === response_or_text</diff>
      <filename>vendor/plugins/rspec-rails/lib/spec/rails/matchers/assert_select.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,10 +10,18 @@ module Spec
         end
       
         def matches?(response)
-          @actual = response.rendered_file
-          full_path(@actual) == full_path(@expected)
+          
+          if response.respond_to?(:rendered_file)
+            @actual = response.rendered_file
+          else
+            @actual = response.rendered_template.to_s
+          end
+          return false if @actual.blank?
+          given_controller_path, given_file = path_and_file(@actual)
+          expected_controller_path, expected_file = path_and_file(@expected)
+          given_controller_path == expected_controller_path &amp;&amp; given_file.match(expected_file)
         end
-
+        
         def failure_message
           &quot;expected #{@expected.inspect}, got #{@actual.inspect}&quot;
         end
@@ -27,9 +35,21 @@ module Spec
         end
       
         private
-          def full_path(path)
-            return nil if path.nil?
-            path.include?('/') ? path : &quot;#{@controller.class.to_s.underscore.gsub('_controller','')}/#{path}&quot;
+          def path_and_file(path)
+            parts = path.split('/')
+            file = parts.pop
+            controller = parts.empty? ? current_controller_path : parts.join('/')
+            return controller, file
+          end
+        
+          def controller_path_from(path)
+            parts = path.split('/')
+            parts.pop
+            parts.join('/')
+          end
+
+          def current_controller_path
+            @controller.class.to_s.underscore.gsub(/_controller$/,'')
           end
         
       end</diff>
      <filename>vendor/plugins/rspec-rails/lib/spec/rails/matchers/render_template.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,15 +9,21 @@ module Spec
       # methods stubbed out. Additional methods may be easily stubbed (via
       # add_stubs) if +stubs+ is passed.
       def mock_model(model_class, options_and_stubs = {})
-        id = next_id
-        options_and_stubs.reverse_merge!({
+        id = options_and_stubs[:id] || next_id
+        options_and_stubs = options_and_stubs.reverse_merge({
           :id =&gt; id,
           :to_param =&gt; id.to_s,
           :new_record? =&gt; false,
           :errors =&gt; stub(&quot;errors&quot;, :count =&gt; 0)
         })
-        m = mock(&quot;#{model_class.name}_#{options_and_stubs[:id]}&quot;, options_and_stubs)
+        m = mock(&quot;#{model_class.name}_#{id}&quot;, options_and_stubs)
         m.send(:__mock_proxy).instance_eval &lt;&lt;-CODE
+          def @target.as_new_record
+            self.stub!(:id).and_return nil
+            self.stub!(:to_param).and_return nil
+            self.stub!(:new_record?).and_return true
+            self
+          end
           def @target.is_a?(other)
             #{model_class}.ancestors.include?(other)
           end
@@ -123,4 +129,4 @@ module Spec
 
     end
   end
-end
\ No newline at end of file
+end</diff>
      <filename>vendor/plugins/rspec-rails/lib/spec/rails/mocks.rb</filename>
    </modified>
    <modified>
      <diff>@@ -40,15 +40,23 @@ class ActiveRecordSafetyListener
   include Singleton
   def scenario_started(*args)
     if defined?(ActiveRecord::Base)
-      ActiveRecord::Base.send :increment_open_transactions unless Rails::VERSION::STRING == &quot;1.1.6&quot;
-      ActiveRecord::Base.connection.begin_db_transaction
+      if ActiveRecord::Base.connection.respond_to?(:increment_open_transactions)
+        ActiveRecord::Base.connection.increment_open_transactions
+      else
+        ActiveRecord::Base.send :increment_open_transactions
+      end
     end
+    ActiveRecord::Base.connection.begin_db_transaction
   end
 
   def scenario_succeeded(*args)
     if defined?(ActiveRecord::Base)
       ActiveRecord::Base.connection.rollback_db_transaction
-      ActiveRecord::Base.send :decrement_open_transactions unless Rails::VERSION::STRING == &quot;1.1.6&quot;
+      if ActiveRecord::Base.connection.respond_to?(:decrement_open_transactions)
+        ActiveRecord::Base.connection.decrement_open_transactions
+      else
+        ActiveRecord::Base.send :decrement_open_transactions
+      end
     end
   end
   alias :scenario_pending :scenario_succeeded</diff>
      <filename>vendor/plugins/rspec-rails/lib/spec/rails/story_adapter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,31 +1,41 @@
 require File.dirname(__FILE__) + '/../../spec_helper'
 
 describe &quot;AssignsHashProxy&quot; do
+  def orig_assigns
+    @object.assigns
+  end
+  
   before(:each) do
-    @object = Object.new
-    @assigns = Hash.new
-    @object.stub!(:assigns).and_return(@assigns)
-    @proxy = Spec::Rails::Example::AssignsHashProxy.new(@object)
+    @object = Class.new do
+      attr_accessor :assigns
+    end.new
+    @object.assigns = Hash.new
+    @proxy = Spec::Rails::Example::AssignsHashProxy.new self do
+      @object
+    end
   end
-
-  it &quot;has [] accessor&quot; do
+  
+  it &quot;should set ivars on object using string&quot; do
     @proxy['foo'] = 'bar'
-    @assigns['foo'].should == 'bar'
-    @proxy['foo'].should == 'bar'
+    @object.instance_eval{@foo}.should == 'bar'
   end
-
-  it &quot;works for symbol key&quot; do
-    @assigns[:foo] = 2
-    @proxy[:foo].should == 2
+  
+  it &quot;should set ivars on object using symbol&quot; do
+    @proxy[:foo] = 'bar'
+    @object.instance_eval{@foo}.should == 'bar'
   end
-
-  it &quot;checks for string key before symbol key&quot; do
-    @assigns['foo'] = false
-    @assigns[:foo] = 2
-    @proxy[:foo].should == false
+  
+  it &quot;should access object's assigns with a string&quot; do
+    @object.assigns['foo'] = 'bar'
+    @proxy[:foo].should == 'bar'
+  end
+  
+  it &quot;should access object's assigns with a symbol&quot; do
+    @object.assigns['foo'] = 'bar'
+    @proxy[:foo].should == 'bar'
   end
 
-  it &quot;each method iterates through each element like a Hash&quot; do
+  it &quot;iterates through each element like a Hash&quot; do
     values = {
       'foo' =&gt; 1,
       'bar' =&gt; 2,
@@ -34,27 +44,22 @@ describe &quot;AssignsHashProxy&quot; do
     @proxy['foo'] = values['foo']
     @proxy['bar'] = values['bar']
     @proxy['baz'] = values['baz']
-
+  
     @proxy.each do |key, value|
       key.should == key
       value.should == values[key]
     end
   end
-
-  it &quot;delete method deletes the element of passed in key&quot; do
-    @proxy['foo'] = 'bar'
+  
+  it &quot;deletes the element of passed in key&quot; do
+    @object.assigns['foo'] = 'bar'
     @proxy.delete('foo').should == 'bar'
     @proxy['foo'].should be_nil
   end
-
-  it &quot;has_key? detects the presence of a key&quot; do
-    @proxy['foo'] = 'bar'
+  
+  it &quot;detects the presence of a key&quot; do
+    @object.assigns['foo'] = 'bar'
     @proxy.has_key?('foo').should == true
     @proxy.has_key?('bar').should == false
   end
-  
-  it &quot;should sets an instance var&quot; do
-    @proxy['foo'] = 'bar'
-    @object.instance_eval { @foo }.should == 'bar'
-  end
 end</diff>
      <filename>vendor/plugins/rspec-rails/spec/rails/example/assigns_hash_proxy_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ require 'controller_spec_controller'
   describe &quot;A controller example running in #{mode} mode&quot;, :type =&gt; :controller do
     controller_name :controller_spec
     integrate_views if mode == 'integration'
-  
+    
     it &quot;should provide controller.session as session&quot; do
       get 'action_with_template'
       session.should equal(controller.session)
@@ -143,11 +143,6 @@ require 'controller_spec_controller'
       assigns[:indirect_assigns_key].should == :indirect_assigns_key_value
     end
     
-    it &quot;should expose the assigns hash directly&quot; do
-      get 'action_setting_the_assigns_hash'
-      assigns[:direct_assigns_key].should == :direct_assigns_key_value
-    end
-    
     it &quot;should complain when calling should_receive(:render) on the controller&quot; do
       lambda {
         controller.should_receive(:render)
@@ -167,6 +162,12 @@ require 'controller_spec_controller'
         controller.rspec_verify
       }.should raise_error(Exception, /expected :anything_besides_render/)
     end
+    
+    it &quot;should not run a skipped before_filter&quot; do
+      lambda {
+        get 'action_with_skipped_before_filter'
+      }.should_not raise_error
+    end
   end
 
   describe &quot;Given a controller spec for RedirectSpecController running in #{mode} mode&quot;, :type =&gt; :controller do
@@ -207,6 +208,19 @@ require 'controller_spec_controller'
   
 end
 
+['integration', 'isolation'].each do |mode|
+  describe &quot;A controller example running in #{mode} mode&quot;, :type =&gt; :controller do
+    controller_name :controller_inheriting_from_application_controller
+    integrate_views if mode == 'integration'
+    
+    it &quot;should only have a before filter inherited from ApplicationController run once...&quot; do
+      controller.should_receive(:i_should_only_be_run_once).once
+      get :action_with_inherited_before_filter
+    end
+  end
+end
+
+
 describe ControllerSpecController, :type =&gt; :controller do
   it &quot;should not require naming the controller if describe is passed a type&quot; do
   end  </diff>
      <filename>vendor/plugins/rspec-rails/spec/rails/example/controller_spec_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -38,26 +38,35 @@ module Spec
         describe &quot;with a Symbol key&quot; do
         
           it &quot;should accept a String value&quot; do
-            cookies = CookiesProxy.new(self)
-            cookies[:key] = 'value'
+            example_cookies = CookiesProxy.new(self)
+            example_cookies[:key] = 'value'
             get :index
-            cookies[:key].should == ['value']
+            example_cookies[:key].should == ['value']
           end
 
           if Rails::VERSION::STRING &gt;= &quot;2.0.0&quot;
             it &quot;should accept a Hash value&quot; do
-              cookies = CookiesProxy.new(self)
-              cookies[:key] = { :value =&gt; 'value', :expires =&gt; expiration = 1.hour.from_now, :path =&gt; path = '/path' }
+              example_cookies = CookiesProxy.new(self)
+              example_cookies[:key] = { :value =&gt; 'value', :expires =&gt; expiration = 1.hour.from_now, :path =&gt; path = '/path' }
               get :index
-              cookies[:key].should == ['value']
-              cookies[:key].value.should == ['value']
-              cookies[:key].expires.should == expiration
-              cookies[:key].path.should == path
+              example_cookies[:key].should == ['value']
+              example_cookies[:key].value.should == ['value']
+              example_cookies[:key].expires.should == expiration
+              example_cookies[:key].path.should == path
             end
           end
 
         end
     
+        describe &quot;#delete&quot; do
+          it &quot;should delete from the response cookies&quot; do
+            example_cookies = CookiesProxy.new(self)
+            response_cookies = mock('cookies')
+            response.should_receive(:cookies).and_return(response_cookies)
+            response_cookies.should_receive(:delete).with('key')
+            example_cookies.delete :key
+          end
+        end
       end
     
     end</diff>
      <filename>vendor/plugins/rspec-rails/spec/rails/example/cookies_proxy_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -149,37 +149,19 @@ describe &quot;A view that includes a partial using :collection and :spacer_template&quot;
 
 end
 
-describe &quot;A view that includes a partial using an array as partial_path&quot;, :type =&gt; :view do
-  before(:each) do
-    module ActionView::Partials
-      def render_template_with_partial_with_array_support(partial_path, local_assigns = nil, deprecated_local_assigns = nil)
-        if partial_path.is_a?(Array)
-          &quot;Array Partial&quot;
-        else
-          render_partial_without_array_support(partial_path, local_assigns, deprecated_local_assigns)
-        end
-      end
-
-      alias :render_partial_without_array_support :render_partial
-      alias :render_partial :render_template_with_partial_with_array_support
+if Rails::VERSION::MAJOR &gt;= 2
+  describe &quot;A view that includes a partial using an array as partial_path&quot;, :type =&gt; :view do
+    before(:each) do
+      renderable_object = Object.new
+      renderable_object.stub!(:name).and_return(&quot;Renderable Object&quot;)
+      assigns[:array] = [renderable_object]
     end
 
-    @array = ['Alice', 'Bob']
-    assigns[:array] = @array
-  end
-
-  after(:each) do
-    module ActionView::Partials
-      alias :render_template_with_partial_with_array_support :render_partial
-      alias :render_partial :render_partial_without_array_support
-      undef render_template_with_partial_with_array_support
+    it &quot;should render the array passed through to render_partial without modification&quot; do
+      render &quot;view_spec/template_with_partial_with_array&quot; 
+      response.body.should match(/^Renderable Object$/)
     end
   end
-
-  it &quot;should render have the array passed through to render_partial without modification&quot; do
-    render &quot;view_spec/template_with_partial_with_array&quot; 
-    response.body.should match(/^Array Partial$/)
-  end
 end
 
 describe &quot;Different types of renders (not :template)&quot;, :type =&gt; :view do
@@ -239,6 +221,20 @@ describe &quot;An instantiated ViewExampleGroupController&quot;, :type =&gt; :view do
   end
 end
 
+describe &quot;a block helper&quot;, :type =&gt; :view do
+  it &quot;should not yield when not told to in the example&quot; do
+    template.should_receive(:if_allowed)
+    render &quot;view_spec/block_helper&quot;
+    response.should_not have_tag(&quot;div&quot;,&quot;block helper was rendered&quot;)
+  end
+
+  it &quot;should yield when told to in the example&quot; do
+    template.should_receive(:if_allowed).and_yield
+    render &quot;view_spec/block_helper&quot;
+    response.should have_tag(&quot;div&quot;,&quot;block helper was rendered&quot;)
+  end
+end
+
 describe &quot;render :inline =&gt; ...&quot;, :type =&gt; :view do
   it &quot;should render ERB right in the spec&quot; do
     render :inline =&gt; %|&lt;%= text_field_tag('field_name', 'Value') %&gt;|
@@ -270,3 +266,14 @@ module Spec
     end
   end
 end
+
+describe &quot;bug http://rspec.lighthouseapp.com/projects/5645/tickets/510&quot;, :type =&gt; :view do
+  describe &quot;a view example with should_not_receive&quot; do
+    it &quot;should render the view&quot; do
+      assigns[:model] = mock('model')
+      assigns[:model].should_receive(:render_partial?).and_return false
+      template.should_not_receive(:render).with(:partial =&gt; 'some_partial')
+      render &quot;view_spec/should_not_receive&quot;
+    end
+  end
+end</diff>
      <filename>vendor/plugins/rspec-rails/spec/rails/example/view_spec_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -601,9 +601,6 @@ describe &quot;have_rjs behaviour_type&quot;, :type =&gt; :controller do
       with_tag(&quot;div&quot;, 1)
       with_tag(&quot;#1&quot;)
     end
-    lambda {
-      response.should have_rjs(:insert, :top, &quot;test2&quot;)
-    }.should raise_error(SpecFailed)
     response.should have_rjs(:insert, :bottom) {|rjs|
       with_tag(&quot;div&quot;, 1)
       with_tag(&quot;#2&quot;)
@@ -629,6 +626,17 @@ describe &quot;have_rjs behaviour_type&quot;, :type =&gt; :controller do
       with_tag(&quot;#4&quot;)
     }
   end
+  
+  it &quot;should find rjs using :insert (positioned)&quot; do
+    pending(&quot;await fix for http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/982&quot;)
+    render_rjs do |page|
+      page.insert_html :top, &quot;test1&quot;, &quot;&lt;div id=\&quot;1\&quot;&gt;foo&lt;/div&gt;&quot;
+      page.insert_html :bottom, &quot;test2&quot;, &quot;&lt;div id=\&quot;2\&quot;&gt;bar&lt;/div&gt;&quot;
+    end
+    lambda {
+      response.should have_rjs(:insert, :top, &quot;test2&quot;)
+    }.should raise_error(SpecFailed)
+  end
 end
 
 describe &quot;send_email behaviour_type&quot;, :type =&gt; :controller do</diff>
      <filename>vendor/plugins/rspec-rails/spec/rails/matchers/assert_select_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -40,30 +40,24 @@ describe &quot;include_text&quot;, :type =&gt; :controller do
         response.should include_text('text for this')
       end
 
-      it &quot;should fail with matching text&quot; do
+      it &quot;should fail with incorrect text&quot; do
         post 'text_action'
         lambda {
-          response.should include_text(&quot;this is NOT the text for this action&quot;)
-        }.should fail_with(&quot;expected to find \&quot;this is NOT the text for this action\&quot; in \&quot;this is the text for this action\&quot;&quot;)
-      end
-
-      it &quot;should fail when a template is rendered&quot; do
-        post 'some_action'
-        failure_message = case mode
-        when 'isolation'
-          /expected to find \&quot;this is the text for this action\&quot; in \&quot;render_spec\/some_action\&quot;/
-        when 'integration'
-          /expected to find \&quot;this is the text for this action\&quot; in \&quot;\&quot;/
-        end
-        lambda {
-          response.should include_text(&quot;this is the text for this action&quot;)
-        }.should fail_with(failure_message)
+          response.should include_text(&quot;the accordian guy&quot;)
+        }.should fail_with(&quot;expected to find \&quot;the accordian guy\&quot; in \&quot;this is the text for this action\&quot;&quot;)
       end
 
       it &quot;should pass using should_not with incorrect text&quot; do
         post 'text_action'
         response.should_not include_text(&quot;the accordian guy&quot;)
       end
+
+      it &quot;should fail when a template is rendered&quot; do
+        get 'some_action'
+        lambda {
+          response.should include_text(&quot;this is the text for this action&quot;)
+        }.should fail_with(/expected to find \&quot;this is the text for this action\&quot;/)
+      end
     end
   end
 end</diff>
      <filename>vendor/plugins/rspec-rails/spec/rails/matchers/include_text_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
       integrate_views
     end
     controller_name :redirect_spec
-  
+    
     it &quot;redirected to another action&quot; do
       get 'action_with_redirect_to_somewhere'
       response.should redirect_to(:action =&gt; 'somewhere')</diff>
      <filename>vendor/plugins/rspec-rails/spec/rails/matchers/redirect_to_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -25,6 +25,14 @@ describe &quot;mock_model&quot; do
   end
 end
 
+describe &quot;mock_mode with params&quot; do
+  it &quot;should not mutate its parameters&quot; do
+    params = {:a =&gt; 'b'}
+    model = mock_model(MockableModel, params)
+    params.should == {:a =&gt; 'b'}
+  end
+end
+
 describe &quot;mock_model with stubbed id&quot;, :type =&gt; :view do
   before(:each) do
     @model = mock_model(MockableModel, :id =&gt; 1)
@@ -32,6 +40,9 @@ describe &quot;mock_model with stubbed id&quot;, :type =&gt; :view do
   it &quot;should be named using the stubbed id value&quot; do
     @model.instance_variable_get(:@name).should == &quot;MockableModel_1&quot;
   end
+  it &quot;should return string of id value for to_param&quot; do
+    @model.to_param.should == &quot;1&quot;
+  end
 end
 
 describe &quot;mock_model with null_object&quot;, :type =&gt; :view do
@@ -62,3 +73,18 @@ describe &quot;mock_model as association&quot;, :type =&gt; :view do
       @real.mockable_model.should == @mock_model
   end
 end
+
+describe &quot;mock_model #as_new_record&quot; do
+  it &quot;should say it is a new record&quot; do
+    mock_model(MockableModel).as_new_record.should be_new_record
+  end
+
+  it &quot;should have a nil id&quot; do
+    mock_model(MockableModel).as_new_record.id.should be(nil)
+  end
+
+  it &quot;should have a nil to_param&quot; do
+    mock_model(MockableModel).as_new_record.to_param.should be(nil)
+  end
+end
+</diff>
      <filename>vendor/plugins/rspec-rails/spec/rails/mocks/mock_model_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,96 +1,96 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-
-describe &quot;script/spec_server file&quot;, :shared =&gt; true do
-  attr_accessor :tmbundle_install_directory
-  attr_reader :animals_yml_path, :original_animals_content
-
-  before do
-    @animals_yml_path = File.expand_path(&quot;#{RAILS_ROOT}/spec/fixtures/animals.yml&quot;)
-    @original_animals_content = File.read(animals_yml_path)
-  end
-
-  after do
-    File.open(animals_yml_path, &quot;w&quot;) do |f|
-      f.write original_animals_content
-    end
-  end
-
-  after(:each) do
-    system &quot;lsof -i tcp:8989 | sed /COMMAND/d | awk '{print $2}' | xargs kill&quot;
-  end
-
-  it &quot;runs a spec&quot; do
-    dir = File.dirname(__FILE__)
-    output = &quot;&quot;
-    Timeout.timeout(10) do
-      loop do
-        output = `#{RAILS_ROOT}/script/spec #{dir}/sample_spec.rb --drb 2&gt;&amp;1`
-        break unless output.include?(&quot;No server is running&quot;)
-      end
-    end
-
-    if $?.exitstatus != 0 || output !~ /0 failures/
-      flunk &quot;command 'script/spec spec/sample_spec' failed\n#{output}&quot;
-    end
-
-    fixtures = YAML.load(@original_animals_content)
-    fixtures['pig']['name'] = &quot;Piggy&quot;
-
-    File.open(animals_yml_path, &quot;w&quot;) do |f|
-      f.write YAML.dump(fixtures)
-    end
-
-    Timeout.timeout(10) do
-      loop do
-        output = `#{RAILS_ROOT}/script/spec #{dir}/sample_modified_fixture.rb --drb 2&gt;&amp;1`
-        break unless output.include?(&quot;No server is running&quot;)
-      end
-    end
-
-    if $?.exitstatus != 0 || output !~ /0 failures/
-      flunk &quot;command 'script/spec spec/sample_modified_fixture' failed\n#{output}&quot;
-    end
-  end
-
-  def start_spec_server
-    dir = File.dirname(__FILE__)
-    Thread.start do
-      system &quot;cd #{RAILS_ROOT}; script/spec_server&quot;
-    end
-
-    file_content = &quot;&quot;
-  end
-end
-
-describe &quot;script/spec_server file without TextMate bundle&quot; do
-  it_should_behave_like &quot;script/spec_server file&quot;
-  before(:each) do
-    start_spec_server
-  end
-end
-
-describe &quot;script/spec_server file with TextMate bundle&quot; do
-  it_should_behave_like &quot;script/spec_server file&quot;
-  before(:each) do
-    dir = File.dirname(__FILE__)
-    @tmbundle_install_directory = File.expand_path(&quot;#{Dir.tmpdir}/Library/Application Support/TextMate/Bundles&quot;)
-    @bundle_name = &quot;RSpec.tmbundle&quot;
-    FileUtils.mkdir_p(tmbundle_install_directory)
-    bundle_dir = File.expand_path(&quot;#{dir}/../../../../../../#{@bundle_name}&quot;)
-    File.directory?(bundle_dir).should be_true
-    unless system(%Q|ln -s #{bundle_dir} &quot;#{tmbundle_install_directory}&quot;|)
-      raise &quot;Creating link to Textmate Bundle&quot;
-    end
-    start_spec_server
-  end
-
-  after(:each) do
-    bundle_file_to_remove = &quot;#{tmbundle_install_directory}/#{@bundle_name}&quot;
-    if bundle_file_to_remove == &quot;/&quot;
-      raise &quot;bundle file path resolved to '/' - could not call rm&quot;
-    end
-    unless system(%Q|rm &quot;#{bundle_file_to_remove}&quot;|)
-      raise &quot;Removing Textmate bundle link failed&quot;
-    end
-  end
-end
+# require File.dirname(__FILE__) + '/../spec_helper'
+# 
+# describe &quot;script/spec_server file&quot;, :shared =&gt; true do
+#   attr_accessor :tmbundle_install_directory
+#   attr_reader :animals_yml_path, :original_animals_content
+# 
+#   before do
+#     @animals_yml_path = File.expand_path(&quot;#{RAILS_ROOT}/spec/fixtures/animals.yml&quot;)
+#     @original_animals_content = File.read(animals_yml_path)
+#   end
+# 
+#   after do
+#     File.open(animals_yml_path, &quot;w&quot;) do |f|
+#       f.write original_animals_content
+#     end
+#   end
+# 
+#   after(:each) do
+#     system &quot;lsof -i tcp:8989 | sed /COMMAND/d | awk '{print $2}' | xargs kill&quot;
+#   end
+# 
+#   it &quot;runs a spec&quot; do
+#     dir = File.dirname(__FILE__)
+#     output = &quot;&quot;
+#     Timeout.timeout(10) do
+#       loop do
+#         output = `#{RAILS_ROOT}/script/spec #{dir}/sample_spec.rb --drb 2&gt;&amp;1`
+#         break unless output.include?(&quot;No server is running&quot;)
+#       end
+#     end
+# 
+#     if $?.exitstatus != 0 || output !~ /0 failures/
+#       flunk &quot;command 'script/spec spec/sample_spec' failed\n#{output}&quot;
+#     end
+# 
+#     fixtures = YAML.load(@original_animals_content)
+#     fixtures['pig']['name'] = &quot;Piggy&quot;
+# 
+#     File.open(animals_yml_path, &quot;w&quot;) do |f|
+#       f.write YAML.dump(fixtures)
+#     end
+# 
+#     Timeout.timeout(10) do
+#       loop do
+#         output = `#{RAILS_ROOT}/script/spec #{dir}/sample_modified_fixture.rb --drb 2&gt;&amp;1`
+#         break unless output.include?(&quot;No server is running&quot;)
+#       end
+#     end
+# 
+#     if $?.exitstatus != 0 || output !~ /0 failures/
+#       flunk &quot;command 'script/spec spec/sample_modified_fixture' failed\n#{output}&quot;
+#     end
+#   end
+# 
+#   def start_spec_server
+#     dir = File.dirname(__FILE__)
+#     Thread.start do
+#       system &quot;cd #{RAILS_ROOT}; script/spec_server&quot;
+#     end
+# 
+#     file_content = &quot;&quot;
+#   end
+# end
+# 
+# describe &quot;script/spec_server file without TextMate bundle&quot; do
+#   it_should_behave_like &quot;script/spec_server file&quot;
+#   before(:each) do
+#     start_spec_server
+#   end
+# end
+# 
+# describe &quot;script/spec_server file with TextMate bundle&quot; do
+#   it_should_behave_like &quot;script/spec_server file&quot;
+#   before(:each) do
+#     dir = File.dirname(__FILE__)
+#     @tmbundle_install_directory = File.expand_path(&quot;#{Dir.tmpdir}/Library/Application Support/TextMate/Bundles&quot;)
+#     @bundle_name = &quot;RSpec.tmbundle&quot;
+#     FileUtils.mkdir_p(tmbundle_install_directory)
+#     bundle_dir = File.expand_path(&quot;#{dir}/../../../../../../#{@bundle_name}&quot;)
+#     File.directory?(bundle_dir).should be_true
+#     unless system(%Q|ln -s #{bundle_dir} &quot;#{tmbundle_install_directory}&quot;|)
+#       raise &quot;Creating link to Textmate Bundle&quot;
+#     end
+#     start_spec_server
+#   end
+# 
+#   after(:each) do
+#     bundle_file_to_remove = &quot;#{tmbundle_install_directory}/#{@bundle_name}&quot;
+#     if bundle_file_to_remove == &quot;/&quot;
+#       raise &quot;bundle file path resolved to '/' - could not call rm&quot;
+#     end
+#     unless system(%Q|rm &quot;#{bundle_file_to_remove}&quot;|)
+#       raise &quot;Removing Textmate bundle link failed&quot;
+#     end
+#   end
+# end</diff>
      <filename>vendor/plugins/rspec-rails/spec/rails/spec_server_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,7 +12,12 @@ require File.expand_path(&quot;#{dir}/../spec_resources/helpers/more_explicit_helper&quot;
 require File.expand_path(&quot;#{dir}/../spec_resources/helpers/view_spec_helper&quot;)
 require File.expand_path(&quot;#{dir}/../spec_resources/helpers/plugin_application_helper&quot;)
 
-ActionController::Routing.controller_paths &lt;&lt; File.expand_path(&quot;#{dir}/../spec_resources/controllers&quot;)
+extra_controller_paths = File.expand_path(&quot;#{dir}/../spec_resources/controllers&quot;)
+
+unless ActionController::Routing.controller_paths.include?(extra_controller_paths)
+  ActionController::Routing.instance_eval {@possible_controllers = nil}
+  ActionController::Routing.controller_paths &lt;&lt; extra_controller_paths
+end
 
 module Spec
   module Rails
@@ -38,6 +43,12 @@ class Proc
   end
 end
 
+Spec::Runner.configure do |config|
+  config.before(:each, :type =&gt; :controller) do
+  end
+end
+
+
 ActionController::Routing::Routes.draw do |map|
   map.resources :rspec_on_rails_specs
   map.connect 'custom_route', :controller =&gt; 'custom_route_spec', :action =&gt; 'custom_route'</diff>
      <filename>vendor/plugins/rspec-rails/spec/spec_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,12 @@
 class ControllerSpecController &lt; ActionController::Base
+  before_filter :raise_error, :only =&gt; :action_with_skipped_before_filter
+  
+  def raise_error
+    raise &quot;from a before filter&quot;
+  end
+  
+  skip_before_filter :raise_error
+  
   if ['edge','2.0.0'].include?(ENV['RSPEC_RAILS_VERSION'])
     set_view_path [File.join(File.dirname(__FILE__), &quot;..&quot;, &quot;views&quot;)]
   else
@@ -54,7 +62,6 @@ class ControllerSpecController &lt; ActionController::Base
   end
 
   def action_setting_the_assigns_hash
-    assigns['direct_assigns_key'] = :direct_assigns_key_value
     @indirect_assigns_key = :indirect_assigns_key_value
   end
   
@@ -74,5 +81,14 @@ class ControllerSpecController &lt; ActionController::Base
                             :partial =&gt; 'non_existent_partial'
     end
   end
+  
+  def action_with_skipped_before_filter
+    render :text =&gt; &quot;&quot;
+  end
 end
 
+class ControllerInheritingFromApplicationControllerController &lt; ApplicationController
+  def action_with_inherited_before_filter
+    render :text =&gt; &quot;&quot;
+  end
+end
\ No newline at end of file</diff>
      <filename>vendor/plugins/rspec-rails/spec_resources/controllers/controller_spec_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,4 +23,8 @@ class RenderSpecController &lt; ApplicationController
   def action_that_renders_nothing
     render :nothing =&gt; true
   end
+  
+  def action_with_alternate_layout
+    render :layout =&gt; 'simple'
+  end
 end</diff>
      <filename>vendor/plugins/rspec-rails/spec_resources/controllers/render_spec_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,9 @@ automatically load rspec anymore. This allows rspec to live side by side other
 spec frameworks without always co-opting autotest through autotest's discovery
 mechanism.
 
+ALSO IMPORTANT: $rspec_options is gone. If you were using this for anything
+(like your own runners), use Spec::Runner.options instead.
+
 * Consider MinGW as valid RUBY_PLATFORM for --colour option. (patch from Luis Lavena). Closes #406.
 * Added additional characters to be escaped in step strings (patch from Jake Cahoon). Closes #417.
 * Disable color codes on STDOUT when STDOUT.tty? is false (patch from Tim Pope). Closes #413.
@@ -22,6 +25,10 @@ mechanism.
 * should and should_not return true on success
 * use hoe for build/release
 * bye, bye translator
+* autotest/rspec uses ruby command instead of spec command (no need for spec command unless loading directories)
+* Avoid 'invalid option -O' in autotest (patch from Jonathan del Strother). Closes #486.
+* Fix: Unimplemented step with new line throws error (patch from Ben Mabey). Closes #494.
+* Only use color codes on tty; override for autospec (patch from Tim Pope). Closes #413.
 
 === Version 1.1.4
 </diff>
      <filename>vendor/plugins/rspec/History.txt</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@
 
 * http://rspec.info
 * http://rspec.info/rdoc/
-* http://github.com/dchelimsky/rspec-rails/wikis
+* http://github.com/dchelimsky/rspec/wikis
 * mailto:rspec-devel@rubyforge.org
 
 == DESCRIPTION:</diff>
      <filename>vendor/plugins/rspec/README.txt</filename>
    </modified>
    <modified>
      <diff>@@ -25,8 +25,8 @@ end
   Rake.application.instance_variable_get('@tasks').delete(task)
 end
 
-task :default =&gt; :verify_rcov
 task :verify_rcov =&gt; [:spec, :stories]
+task :default =&gt; :verify_rcov
 
 # # Some of the tasks are in separate files since they are also part of the website documentation
 load File.dirname(__FILE__) + '/rake_tasks/examples.rake'
@@ -41,7 +41,7 @@ Spec::Rake::SpecTask.new do |t|
   unless ENV['NO_RCOV']
     t.rcov = true
     t.rcov_dir = 'coverage'
-    t.rcov_opts = ['--exclude', 'lib/spec.rb,lib/spec/runner.rb,spec\/spec,bin\/spec,examples,\/var\/lib\/gems,\/Library\/Ruby,\.autotest']
+    t.rcov_opts = ['--exclude', &quot;lib/spec.rb,lib/spec/runner.rb,spec\/spec,bin\/spec,examples,\/var\/lib\/gems,\/Library\/Ruby,\.autotest,#{ENV['GEM_HOME']}&quot;]
   end
 end
 </diff>
      <filename>vendor/plugins/rspec/Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,4 @@
 #!/usr/bin/env ruby
 ENV['RSPEC'] = 'true'
-system 'autotest'
\ No newline at end of file
+ENV['AUTOTEST'] = 'true'
+system (&quot;autotest&quot;, *ARGV)</diff>
      <filename>vendor/plugins/rspec/bin/autospec</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
 #!/usr/bin/env ruby
 $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + &quot;/../lib&quot;))
 require 'spec'
-exit ::Spec::Runner::CommandLine.run(rspec_options)
+exit ::Spec::Runner::CommandLine.run</diff>
      <filename>vendor/plugins/rspec/bin/spec</filename>
    </modified>
    <modified>
      <diff>@@ -36,37 +36,11 @@ class Autotest::Rspec &lt; Autotest
   end
 
   def make_test_cmd(files_to_test)
-    return &quot;#{ruby} -S #{spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}&quot;
+    return '' if files_to_test.empty?
+    return &quot;#{ruby} -S #{files_to_test.keys.flatten.join(' ')} #{add_options_if_present}&quot;
   end
   
   def add_options_if_present # :nodoc:
     File.exist?(&quot;spec/spec.opts&quot;) ? &quot;-O spec/spec.opts &quot; : &quot;&quot;
   end
-
-  # Finds the proper spec command to use.  Precendence is set in the
-  # lazily-evaluated method spec_commands.  Alias + Override that in
-  # ~/.autotest to provide a different spec command then the default
-  # paths provided.
-  def spec_command(separator=File::ALT_SEPARATOR)
-    unless defined? @spec_command then
-      @spec_command = spec_commands.find { |cmd| File.exists? cmd }
-
-      raise RspecCommandError, &quot;No spec command could be found!&quot; unless @spec_command
-
-      @spec_command.gsub! File::SEPARATOR, separator if separator
-    end
-    @spec_command
-  end
-
-  # Autotest will look for spec commands in the following
-  # locations, in this order:
-  #
-  #   * bin/spec
-  #   * default spec bin/loader installed in Rubygems
-  def spec_commands
-    [
-      File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec')),
-      File.join(Config::CONFIG['bindir'], 'spec')
-    ]
-  end
 end</diff>
      <filename>vendor/plugins/rspec/lib/autotest/rspec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,16 +13,13 @@ end
 module Spec
   class &lt;&lt; self
     def run?
-      @run || rspec_options.examples_run?
+      Runner.options.examples_run?
     end
 
     def run
       return true if run?
-      result = rspec_options.run_examples
-      @run = true
-      result
+      Runner.options.run_examples
     end
-    attr_writer :run
     
     def exit?
       !Object.const_defined?(:Test) || Test::Unit.run?</diff>
      <filename>vendor/plugins/rspec/lib/spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,12 @@
 module Spec
   module Example
     class ExamplePendingError &lt; StandardError
+      def initialize(a_message=nil)
+        super
+        @pending_caller = caller[2]
+      end
+      
+      attr_reader :pending_caller
     end
 
     class PendingExampleFixedError &lt; StandardError</diff>
      <filename>vendor/plugins/rspec/lib/spec/example/errors.rb</filename>
    </modified>
    <modified>
      <diff>@@ -171,7 +171,7 @@ module Spec
       def examples #:nodoc:
         examples = example_objects.dup
         add_method_examples(examples)
-        rspec_options.reverse ? examples.reverse : examples
+        Spec::Runner.options.reverse ? examples.reverse : examples
       end
 
       def number_of_examples #:nodoc:
@@ -252,11 +252,11 @@ module Spec
 
       def register(&amp;registration_binding_block)
         @registration_binding_block = registration_binding_block
-        rspec_options.add_example_group self
+        Spec::Runner.options.add_example_group self
       end
 
       def unregister #:nodoc:
-        rspec_options.remove_example_group self
+        Spec::Runner.options.remove_example_group self
       end
 
       def registration_backtrace
@@ -278,8 +278,8 @@ module Spec
     private
       def dry_run(examples)
         examples.each do |example|
-          rspec_options.reporter.example_started(example)
-          rspec_options.reporter.example_finished(example)
+          Spec::Runner.options.reporter.example_started(example)
+          Spec::Runner.options.reporter.example_finished(example)
         end
         return true
       end
@@ -302,7 +302,7 @@ module Spec
 
         after_all_instance_variables = instance_variables
         examples.each do |example_group_instance|
-          success &amp;= example_group_instance.execute(rspec_options, instance_variables)
+          success &amp;= example_group_instance.execute(Spec::Runner.options, instance_variables)
           after_all_instance_variables = example_group_instance.instance_variable_hash
         end
         return [success, after_all_instance_variables]
@@ -335,15 +335,15 @@ module Spec
       end
 
       def specified_examples
-        rspec_options.examples
+        Spec::Runner.options.examples
       end
 
       def reporter
-        rspec_options.reporter
+        Spec::Runner.options.reporter
       end
 
       def dry_run?
-        rspec_options.dry_run
+        Spec::Runner.options.dry_run
       end
 
       def example_objects
@@ -398,7 +398,7 @@ module Spec
         case scope
         when :each; before_each_parts
         when :all; before_all_parts
-        when :suite; rspec_options.before_suite_parts
+        when :suite; Spec::Runner.options.before_suite_parts
         end
       end
 
@@ -406,7 +406,7 @@ module Spec
         case scope
         when :each; after_each_parts
         when :all; after_all_parts
-        when :suite; rspec_options.after_suite_parts
+        when :suite; Spec::Runner.options.after_suite_parts
         end
       end
 </diff>
      <filename>vendor/plugins/rspec/lib/spec/example/example_group_methods.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,7 +23,7 @@ module Spec
         raise ArgumentError if args.empty?
         raise ArgumentError unless block
         args &lt;&lt; {} unless Hash === args.last
-        args.last[:spec_path] = caller(0)[1]
+        args.last[:spec_path] = File.expand_path(caller(0)[1])
         Spec::Example::ExampleGroupFactory.create_example_group(*args, &amp;block)
       end
       alias :context :describe
@@ -80,23 +80,8 @@ module Spec
           raise NameError.new(e.message + &quot;\nThe first argument to share_as must be a legal name for a constant\n&quot;)
         end
       end
-
-    private
-    
-      def rspec_options
-        $rspec_options ||= begin; \
-          parser = ::Spec::Runner::OptionParser.new(STDERR, STDOUT); \
-          parser.order!(ARGV); \
-          $rspec_options = parser.options; \
-        end
-        $rspec_options
-      end
-      
-      def init_rspec_options(options)
-        $rspec_options = options if $rspec_options.nil?
-      end
     end
   end
 end
 
-include Spec::Extensions::Main
\ No newline at end of file
+include Spec::Extensions::Main</diff>
      <filename>vendor/plugins/rspec/lib/spec/extensions/main.rb</filename>
    </modified>
    <modified>
      <diff>@@ -27,9 +27,9 @@ EOF
       end
       
       def execute_change
-        @before = @block.nil? ? @receiver.send(@message) : @block.call
+        @before = @block.nil? ? @receiver.__send__(@message) : @block.call
         @target.call
-        @after = @block.nil? ? @receiver.send(@message) : @block.call
+        @after = @block.nil? ? @receiver.__send__(@message) : @block.call
       end
       
       def failure_message</diff>
      <filename>vendor/plugins/rspec/lib/spec/matchers/change.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,7 +8,7 @@ module Spec
       end
       
       def matches?(target)
-        target.send(predicate, *@args)
+        target.__send__(predicate, *@args)
       end
       
       def failure_message</diff>
      <filename>vendor/plugins/rspec/lib/spec/matchers/has.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,5 @@
 module Spec
   module Matchers
-    
     class Have #:nodoc:
       def initialize(expected, relativity=:exactly)
         @expected = (expected == :no ? 0 : expected)
@@ -15,25 +14,15 @@ module Spec
         }
       end
     
-      def method_missing(sym, *args, &amp;block)
-        @collection_name = sym
-        if inflector = (defined?(ActiveSupport::Inflector) ? ActiveSupport::Inflector : (defined?(Inflector) ? Inflector : nil))
-          @plural_collection_name = inflector.pluralize(sym.to_s)
-        end
-        @args = args
-        @block = block
-        self
-      end
-    
       def matches?(collection_owner)
         if collection_owner.respond_to?(@collection_name)
-          collection = collection_owner.send(@collection_name, *@args, &amp;@block)
+          collection = collection_owner.__send__(@collection_name, *@args, &amp;@block)
         elsif (@plural_collection_name &amp;&amp; collection_owner.respond_to?(@plural_collection_name))
-          collection = collection_owner.send(@plural_collection_name, *@args, &amp;@block)
+          collection = collection_owner.__send__(@plural_collection_name, *@args, &amp;@block)
         elsif (collection_owner.respond_to?(:length) || collection_owner.respond_to?(:size))
           collection = collection_owner
         else
-          collection_owner.send(@collection_name, *@args, &amp;@block)
+          collection_owner.__send__(@collection_name, *@args, &amp;@block)
         end
         @actual = collection.size if collection.respond_to?(:size)
         @actual = collection.length if collection.respond_to?(:length)
@@ -77,8 +66,22 @@ EOF
         &quot;have #{relative_expectation} #{@collection_name}&quot;
       end
       
+      def respond_to?(sym)
+        @expected.respond_to?(sym) || super
+      end
+    
       private
       
+      def method_missing(sym, *args, &amp;block)
+        @collection_name = sym
+        if inflector = (defined?(ActiveSupport::Inflector) ? ActiveSupport::Inflector : (defined?(Inflector) ? Inflector : nil))
+          @plural_collection_name = inflector.pluralize(sym.to_s)
+        end
+        @args = args
+        @block = block
+        self
+      end
+      
       def relative_expectation
         &quot;#{relativities[@relativity]}#{@expected}&quot;
       end</diff>
      <filename>vendor/plugins/rspec/lib/spec/matchers/have.rb</filename>
    </modified>
    <modified>
      <diff>@@ -57,7 +57,7 @@ module Spec
       def __delegate_method_missing_to_target(operator, expected)
         @operator = operator
         ::Spec::Matchers.last_matcher = self
-        return true if @target.send(operator, expected)
+        return true if @target.__send__(operator, expected)
         return fail_with_message(&quot;expected: #{expected.inspect},\n     got: #{@target.inspect} (using #{operator})&quot;) if ['==','===', '=~'].include?(operator)
         return fail_with_message(&quot;expected: #{operator} #{expected.inspect},\n     got: #{operator.gsub(/./, ' ')} #{@target.inspect}&quot;)
       end
@@ -69,7 +69,7 @@ module Spec
       def __delegate_method_missing_to_target(operator, expected)
         @operator = operator
         ::Spec::Matchers.last_matcher = self
-        return true unless @target.send(operator, expected)
+        return true unless @target.__send__(operator, expected)
         return fail_with_message(&quot;expected not: #{operator} #{expected.inspect},\n         got: #{operator.gsub(/./, ' ')} #{@target.inspect}&quot;)
       end
 </diff>
      <filename>vendor/plugins/rspec/lib/spec/matchers/operator_matcher.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,10 @@ module Spec
 
     class BaseExpectation
       attr_reader :sym
+      attr_writer :expected_received_count, :method_block, :expected_from, :args_to_yield
+      protected :expected_received_count=, :method_block=, :expected_from=, :args_to_yield=
+      attr_accessor :error_generator
+      protected :error_generator, :error_generator=
       
       def initialize(error_generator, expectation_ordering, expected_from, sym, method_block, expected_received_count=1, opts={})
         @error_generator = error_generator
@@ -23,6 +27,23 @@ module Spec
         @args_to_yield = []
       end
       
+      def build_child(expected_from, method_block, expected_received_count, opts={})
+        child = clone
+        child.expected_from = expected_from
+        child.method_block = method_block
+        child.expected_received_count = expected_received_count
+        new_gen = error_generator.clone
+        new_gen.opts = opts
+        child.error_generator = new_gen
+        child.args_to_yield = @args_to_yield.clone
+        child
+      end
+      
+      def error_generator_opts=(opts={})
+        @error_generator.opts = opts
+      end
+      protected :error_generator_opts=
+      
       def expected_args
         @args_expectation.args
       end
@@ -103,6 +124,11 @@ module Spec
           @actual_received_count += 1
         end
       end
+
+      def called_max_times?
+        @expected_received_count != :any &amp;&amp;
+          @actual_received_count &gt;= @expected_received_count
+      end
       
       protected
 </diff>
      <filename>vendor/plugins/rspec/lib/spec/mocks/message_expectation.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,8 +9,12 @@ module Spec
         __mock_proxy.add_negative_message_expectation(caller(1)[0], sym.to_sym, &amp;block)
       end
       
-      def stub!(sym, opts={})
-        __mock_proxy.add_stub(caller(1)[0], sym.to_sym, opts)
+      def stub!(sym_or_hash, opts={})
+        if Hash === sym_or_hash
+          sym_or_hash.each {|method, value| stub!(method).and_return value }
+        else
+          __mock_proxy.add_stub(caller(1)[0], sym_or_hash.to_sym, opts)
+        end
       end
       
       def received_message?(sym, *args, &amp;block) #:nodoc:
@@ -24,6 +28,14 @@ module Spec
       def rspec_reset #:nodoc:
         __mock_proxy.reset
       end
+      
+      def as_null_object
+        __mock_proxy.act_as_null_object
+      end
+      
+      def null_object?
+        __mock_proxy.null_object?
+      end
 
     private
 </diff>
      <filename>vendor/plugins/rspec/lib/spec/mocks/methods.rb</filename>
    </modified>
    <modified>
      <diff>@@ -20,10 +20,20 @@ module Spec
       def null_object?
         @options[:null_object]
       end
+      
+      def act_as_null_object
+        @options[:null_object] = true
+        @target
+      end
 
       def add_message_expectation(expected_from, sym, opts={}, &amp;block)
         __add sym
-        @expectations &lt;&lt; MessageExpectation.new(@error_generator, @expectation_ordering, expected_from, sym, block_given? ? block : nil, 1, opts)
+        if existing_stub = @stubs.detect {|s| s.sym == sym }
+          expectation = existing_stub.build_child(expected_from, block_given?? block : nil, 1, opts)
+        else
+          expectation = MessageExpectation.new(@error_generator, @expectation_ordering, expected_from, sym, block_given? ? block : nil, 1, opts)
+        end
+        @expectations &lt;&lt; expectation
         @expectations.last
       end
 
@@ -61,13 +71,17 @@ module Spec
       end
 
       def message_received(sym, *args, &amp;block)
-        if expectation = find_matching_expectation(sym, *args)
-          expectation.invoke(args, block)
-        elsif (stub = find_matching_method_stub(sym, *args))
+        expectation = find_matching_expectation(sym, *args)
+        stub = find_matching_method_stub(sym, *args)
+
+        if (stub &amp;&amp; expectation &amp;&amp; expectation.called_max_times?) ||
+            (stub &amp;&amp; !expectation)
           if expectation = find_almost_matching_expectation(sym, *args)
             expectation.advise(args, block) unless expectation.expected_messages_received?
           end
           stub.invoke([], block)
+        elsif expectation
+          expectation.invoke(args, block)
         elsif expectation = find_almost_matching_expectation(sym, *args)
           expectation.advise(args, block) if null_object? unless expectation.expected_messages_received?
           raise_unexpected_message_args_error(expectation, *args) unless (has_negative_expectation?(sym) or null_object?)</diff>
      <filename>vendor/plugins/rspec/lib/spec/mocks/proxy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -35,11 +35,11 @@ module RCov
     def define
       desc &quot;Verify that rcov coverage is at least #{threshold}%&quot;
       task @name do
-        total_coverage = nil
+        total_coverage = 0
 
         File.open(index_html).each_line do |line|
-          if line =~ /&lt;tt class='coverage_total'&gt;(\d+\.\d+)%&lt;\/tt&gt;/
-            total_coverage = eval($1)
+          if line =~ /&lt;tt class='coverage_total'&gt;\s*(\d+\.\d+)%\s*&lt;\/tt&gt;/
+            total_coverage = $1.to_f
             break
           end
         end</diff>
      <filename>vendor/plugins/rspec/lib/spec/rake/verify_rcov.rb</filename>
    </modified>
    <modified>
      <diff>@@ -185,17 +185,30 @@ module Spec
       end
       
       def register_at_exit_hook # :nodoc:
-        $spec_runner_at_exit_hook_registered ||= nil
-        unless $spec_runner_at_exit_hook_registered
+        @spec_runner_at_exit_hook_registered ||= nil
+        unless @spec_runner_at_exit_hook_registered
           at_exit do
             unless $! || Spec.run?
               success = Spec.run
               exit success if Spec.exit?
             end
           end
-          $spec_runner_at_exit_hook_registered = true
+          @spec_runner_at_exit_hook_registered = true
         end
       end
+
+      def options # :nodoc:
+        @options ||= begin
+          parser = ::Spec::Runner::OptionParser.new(STDERR, STDOUT)
+          parser.order!(ARGV)
+          parser.options
+        end
+      end
+      
+      def use options
+        @options = options
+      end
+
     end
   end
 end</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -40,15 +40,14 @@ module Spec
       
       def tweak_backtrace(error)
         return if error.backtrace.nil?
-        error.backtrace.collect! do |line|
-          clean_up_double_slashes(line)
-          IGNORE_PATTERNS.each do |ignore|
-            if line =~ ignore
-              line = nil
-              break
+        error.backtrace.collect! do |message|
+          clean_up_double_slashes(message)
+          kept_lines = message.split(&quot;\n&quot;).select do |line|
+            IGNORE_PATTERNS.each do |ignore|
+              break if line =~ ignore
             end
           end
-          line
+          kept_lines.empty?? nil : kept_lines.join(&quot;\n&quot;)
         end
         error.backtrace.compact!
       end</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/backtrace_tweaker.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,25 +2,14 @@ require 'spec/runner/option_parser'
 
 module Spec
   module Runner
-    # Facade to run specs without having to fork a new ruby process (using `spec ...`)
     class CommandLine
       class &lt;&lt; self
-        # Runs specs. +argv+ is the commandline args as per the spec commandline API, +err+
-        # and +out+ are the streams output will be written to.
-        def run(instance_rspec_options)
-          # NOTE - this call to init_rspec_options is not spec'd, but neither is any of this
-          # swapping of $rspec_options. That is all here to enable rspec to run against itself
-          # and maintain coverage in a single process. Therefore, DO NOT mess with this stuff
-          # unless you know what you are doing!
-          init_rspec_options(instance_rspec_options)
-          orig_rspec_options = rspec_options
-          begin
-            $rspec_options = instance_rspec_options
-            return $rspec_options.run_examples
-          ensure
-            ::Spec.run = true
-            $rspec_options = orig_rspec_options
-          end
+        def run(tmp_options=Spec::Runner.options)
+          orig_options = Spec::Runner.options
+          Spec::Runner.use tmp_options
+          tmp_options.run_examples
+        ensure
+          Spec::Runner.use orig_options
         end
       end
     end</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/command_line.rb</filename>
    </modified>
    <modified>
      <diff>@@ -45,7 +45,9 @@ module Spec
         # been provided a block), or when an ExamplePendingError is raised.
         # +message+ is the message from the ExamplePendingError, if it exists, or the
         # default value of &quot;Not Yet Implemented&quot;
-        def example_pending(example, message)
+        # +pending_caller+ is the file and line number of the spec which
+        # has called the pending method
+        def example_pending(example, message, pending_caller)
         end
 
         # This method is invoked after all of the examples have executed. The next method</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/formatter/base_formatter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,19 +15,14 @@ module Spec
           super
           if where.is_a?(String)
             @output = File.open(where, 'w')
-          elsif where == STDOUT
-            @output = Kernel
-            def @output.flush
-              STDOUT.flush
-            end
           else
             @output = where
           end
           @pending_examples = []
         end
         
-        def example_pending(example, message)
-          @pending_examples &lt;&lt; [example.__full_description, message]
+        def example_pending(example, message, pending_caller)
+          @pending_examples &lt;&lt; [example.__full_description, message, pending_caller]
         end
         
         def dump_failure(counter, failure)
@@ -75,13 +70,14 @@ module Spec
             @output.puts &quot;Pending:&quot;
             @pending_examples.each do |pending_example|
               @output.puts &quot;#{pending_example[0]} (#{pending_example[1]})&quot; 
+              @output.puts &quot;  Called from #{pending_example[2]}&quot;
             end
           end
           @output.flush
         end
         
         def close
-          if IO === @output
+          if IO === @output &amp;&amp; @output != STDOUT
             @output.close 
           end
         end
@@ -112,7 +108,7 @@ module Spec
 
         def output_to_tty?
           begin
-            @output == Kernel || @output.tty?
+            @output.tty? || ENV.has_key?(&quot;AUTOTEST&quot;)
           rescue NoMethodError
             false
           end</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -85,7 +85,7 @@ module Spec
           @output.flush
         end
 
-        def example_pending(example, message)
+        def example_pending(example, message, pending_caller)
           @output.puts &quot;    &lt;script type=\&quot;text/javascript\&quot;&gt;makeYellow('rspec-header');&lt;/script&gt;&quot; unless @header_red
           @output.puts &quot;    &lt;script type=\&quot;text/javascript\&quot;&gt;makeYellow('example_group_#{example_group_number}');&lt;/script&gt;&quot; unless @example_group_red
           move_progress</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/formatter/html_formatter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -40,7 +40,7 @@ module Spec
           output.flush
         end
 
-        def example_pending(example, message)
+        def example_pending(example, message, pending_caller)
           super
           output.puts yellow(&quot;#{current_indentation}#{example.description} (PENDING: #{message})&quot;)
           output.flush</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/formatter/nested_text_formatter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,7 +14,7 @@ module Spec
           @output.flush
         end
       
-        def example_pending(example, message)
+        def example_pending(example, message, pending_caller)
           super
           @output.print yellow('P')
           @output.flush</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/formatter/progress_bar_formatter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -28,7 +28,7 @@ module Spec
           output.flush
         end
         
-        def example_pending(example, message)
+        def example_pending(example, message, pending_caller)
           super
           output.puts yellow(&quot;- #{example.description} (PENDING: #{message})&quot;)
           output.flush</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/formatter/specdoc_formatter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -86,6 +86,7 @@ EOF
           end
      
           def scenario_started(story_title, scenario_name)
+            @previous_type = nil
             @scenario_failed = false
             @scenario_text = &lt;&lt;-EOF
               &lt;dt&gt;Scenario: #{h scenario_name}&lt;/dt&gt;
@@ -149,10 +150,22 @@ EOF
             spans = args.map { |arg| &quot;&lt;span class=\&quot;param\&quot;&gt;#{arg}&lt;/span&gt;&quot; }
             desc_string = description.step_name
             arg_regexp = description.arg_regexp           
+            inner = if(type == @previous_type)
+              &quot;And &quot;
+            else
+              &quot;#{type.to_s.capitalize} &quot;
+            end
             i = -1
-            inner = type.to_s.capitalize + ' ' + desc_string.gsub(arg_regexp) { |param| spans[i+=1] }
+            inner += desc_string.gsub(arg_regexp) { |param| spans[i+=1] }
+            
             @scenario_text += &quot;                  &lt;li class=\&quot;#{klass}\&quot;&gt;#{inner}&lt;/li&gt;\n&quot;
             
+            if type == :'given scenario'
+              @previous_type = :given
+            else
+              @previous_type = type
+            end
+            
           end
         end
       end</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/formatter/story/html_formatter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -104,7 +104,14 @@ module Spec
           end
           
           def run_ended
-            @output.puts &quot;#@count scenarios: #@successful_scenario_count succeeded, #{@failed_scenarios.size} failed, #@pending_scenario_count pending&quot;
+            summary_text = &quot;#@count scenarios: #@successful_scenario_count succeeded, #{@failed_scenarios.size} failed, #@pending_scenario_count pending&quot;
+            if !@failed_scenarios.empty?
+              @output.puts red(summary_text)
+            elsif !@pending_steps.empty?
+              @output.puts yellow(summary_text)
+            else
+              @output.puts green(summary_text)
+            end
             unless @pending_steps.empty?
               @output.puts &quot;\nPending Steps:&quot;
               @pending_steps.each_with_index do |pending, i|
@@ -116,11 +123,10 @@ module Spec
               @output.print &quot;\nFAILURES:&quot;
               @failed_scenarios.each_with_index do |failure, i|
                 title, scenario_name, err = failure
-                @output.print %[
-    #{i+1}) #{title} (#{scenario_name}) FAILED
-    #{err.class}: #{err.message}
-    #{err.backtrace.join(&quot;\n&quot;)}
-]
+                @output.print &quot;\n    #{i+1}) &quot;
+                @output.print red(&quot;#{title} (#{scenario_name}) FAILED&quot;)
+                @output.print red(&quot;\n    #{err.class}: #{err.message}&quot;)
+                @output.print &quot;\n    #{err.backtrace.join(&quot;\n&quot;)}\n&quot;
               end
             end            
           end</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/formatter/story/plain_text_formatter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -25,7 +25,7 @@ module Spec
       
       def heckle_method(class_name, method_name)
         verify_constant(class_name)
-        heckle = @heckle_class.new(class_name, method_name, rspec_options)
+        heckle = @heckle_class.new(class_name, method_name, Spec::Runner.options)
         heckle.validate
       end
       
@@ -39,7 +39,7 @@ module Spec
         
         classes.each do |klass|
           klass.instance_methods(false).each do |method_name|
-            heckle = @heckle_class.new(klass.name, method_name, rspec_options)
+            heckle = @heckle_class.new(klass.name, method_name, Spec::Runner.options)
             heckle.validate
           end
         end</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/heckle_runner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -54,6 +54,7 @@ module Spec
                                                     &quot;Builtin formats for stories: &quot;,
                                                     &quot;plain|p              : Plain Text&quot;,
                                                     &quot;html|h               : A nice HTML report&quot;,
+                                                    &quot;progress|r           : Text progress&quot;,
                                                     &quot; &quot;,
                                                     &quot;FORMAT can also be the name of a custom formatter class&quot;,
                                                     &quot;(in which case you should also specify --require to load it)&quot;],</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/option_parser.rb</filename>
    </modified>
    <modified>
      <diff>@@ -24,10 +24,13 @@ module Spec
       }
 
       STORY_FORMATTERS = {
-        'plain' =&gt; ['spec/runner/formatter/story/plain_text_formatter', 'Formatter::Story::PlainTextFormatter'],
-            'p' =&gt; ['spec/runner/formatter/story/plain_text_formatter', 'Formatter::Story::PlainTextFormatter'],
-         'html' =&gt; ['spec/runner/formatter/story/html_formatter',       'Formatter::Story::HtmlFormatter'],
-            'h' =&gt; ['spec/runner/formatter/story/html_formatter',       'Formatter::Story::HtmlFormatter']
+        'plain' =&gt; ['spec/runner/formatter/story/plain_text_formatter',   'Formatter::Story::PlainTextFormatter'],
+            'p' =&gt; ['spec/runner/formatter/story/plain_text_formatter',   'Formatter::Story::PlainTextFormatter'],
+         'html' =&gt; ['spec/runner/formatter/story/html_formatter',         'Formatter::Story::HtmlFormatter'],
+            'h' =&gt; ['spec/runner/formatter/story/html_formatter',         'Formatter::Story::HtmlFormatter'],
+     'progress' =&gt; ['spec/runner/formatter/story/progress_bar_formatter', 'Formatter::Story::ProgressBarFormatter'],
+            'r' =&gt; ['spec/runner/formatter/story/progress_bar_formatter', 'Formatter::Story::ProgressBarFormatter']
+            
       }
 
       attr_accessor(
@@ -54,7 +57,7 @@ module Spec
         :argv
       )
       attr_reader :colour, :differ_class, :files, :example_groups
-
+      
       def initialize(error_stream, output_stream)
         @error_stream = error_stream
         @output_stream = output_stream
@@ -89,9 +92,6 @@ module Spec
         return true unless examples_should_be_run?
         success = true
         begin
-          before_suite_parts.each do |part|
-            part.call
-          end
           runner = custom_runner || ExampleGroupRunner.new(self)
 
           unless @files_loaded
@@ -99,6 +99,15 @@ module Spec
             @files_loaded = true
           end
 
+          # TODO - this has to happen after the files get loaded,
+          # otherwise the before_suite_parts are not populated
+          # from the configuration. There is no spec for this
+          # directly, but stories/configuration/before_blocks.story
+          # will fail if this happens before the files are loaded.
+          before_suite_parts.each do |part|
+            part.call
+          end
+
           if example_groups.empty?
             true
           else</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/options.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,11 @@
 module Spec
   module Runner
     class Reporter
+      PENDING_FORMATTER_DEPRECATION_MESSAGE = &lt;&lt;-HERE
+        Formatter deprecation: pending_example now takes three arguments, not two.
+        See http://rspec.info/deprecation_warnings for more info
+      HERE
+      
       attr_reader :options, :example_groups
       
       def initialize(options)
@@ -26,7 +31,7 @@ module Spec
         if error.nil?
           example_passed(example)
         elsif Spec::Example::ExamplePendingError === error
-          example_pending(example, error.message)
+          example_pending(example, error.pending_caller, error.message)
         else
           example_failed(example, error)
         end
@@ -104,13 +109,26 @@ module Spec
         formatters.each{|f| f.example_passed(example)}
       end
       
-      def example_pending(example, message=&quot;Not Yet Implemented&quot;)
+      def example_pending(example, pending_caller, message=&quot;Not Yet Implemented&quot;)
         @pending_count += 1
-        formatters.each do |f|
-          f.example_pending(example, message)
+        formatters.each do |formatter|
+          if pending_method_deprecated_on_formatter?(formatter)
+            warn_with_deprecation_message PENDING_FORMATTER_DEPRECATION_MESSAGE
+            formatter.example_pending(example, message)
+          else
+            formatter.example_pending(example, message, pending_caller)
+          end
         end
       end
       
+      def pending_method_deprecated_on_formatter?(formatter)
+        formatter.method(:example_pending).arity == 2
+      end
+      
+      def warn_with_deprecation_message(message)
+        Kernel.warn(message)
+      end
+
       class Failure
         attr_reader :example, :exception
         </diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/reporter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@ module Spec
       def spec_name_for(file, line_number)
         best_match.clear
         file = File.expand_path(file)
-        rspec_options.example_groups.each do |example_group|
+        Spec::Runner.options.example_groups.each do |example_group|
           consider_example_groups_for_best_match example_group, file, line_number
 
           example_group.examples.each do |example|</diff>
      <filename>vendor/plugins/rspec/lib/spec/runner/spec_parser.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,8 +10,7 @@ module Spec
     module Runner
       class &lt;&lt; self
         def run_options # :nodoc:
-          rspec_options
-          # @run_options ||= ::Spec::Runner::OptionParser.parse(ARGV, $stderr, $stdout)
+          Spec::Runner.options
         end
         
         def story_runner # :nodoc:</diff>
      <filename>vendor/plugins/rspec/lib/spec/story/runner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -19,11 +19,11 @@ module Spec
       end
 
       def matches?(name)
-        !(matches = name.match(@expression)).nil?
+        !(name.strip =~ @expression).nil?
       end
             
       def parse_args(name)
-        name.match(@expression)[1..-1]
+        name.strip.match(@expression)[1..-1]
       end
 
       private
@@ -60,7 +60,7 @@ module Spec
           expression = string_or_regexp.source
         end
         while expression =~ PARAM_PATTERN
-          expression.gsub!($2, &quot;(.*?)&quot;)
+          expression.sub!($2, &quot;(.*?)&quot;)
         end
         @expression = Regexp.new(&quot;\\A#{expression}\\Z&quot;, Regexp::MULTILINE)
       end</diff>
      <filename>vendor/plugins/rspec/lib/spec/story/step.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,7 +13,8 @@ module Spec
         @steps.add(type, step)
       end
       
-      def find(type, name)
+      def find(type, unstripped_name)
+        name = unstripped_name.strip
         if @steps.find(type, name).nil?
           @steps.add(type,
           Step.new(name) do</diff>
      <filename>vendor/plugins/rspec/lib/spec/story/step_mother.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,6 @@ require 'rake'
 require 'spec/rake/verify_rcov'
 
 RCov::VerifyTask.new(:verify_rcov =&gt; :spec) do |t|
-  t.threshold = 100.0 # Make sure you have rcov 0.7 or higher!
+  t.threshold = 100.0
   t.index_html = 'coverage/index.html'
 end</diff>
      <filename>vendor/plugins/rspec/rake_tasks/verify_rcov.rake</filename>
    </modified>
    <modified>
      <diff>@@ -37,62 +37,6 @@ HERE
   end
 
   describe Rspec do
-    describe &quot;selection of rspec command&quot; do
-      include AutotestHelper
-    
-      before(:each) do
-        common_setup
-        @rspec_autotest = Rspec.new
-      end
-    
-      it &quot;should try to find the spec command if it exists in ./bin and use it above everything else&quot; do
-        File.stub!(:exists?).and_return true
-
-        spec_path = File.expand_path(&quot;#{File.dirname(__FILE__)}/../../bin/spec&quot;)
-        File.should_receive(:exists?).with(spec_path).and_return true
-        @rspec_autotest.spec_command.should == spec_path
-      end
-
-      it &quot;should otherwise select the default spec command in gem_dir/bin/spec&quot; do
-        @rspec_autotest.stub!(:spec_commands).and_return [&quot;/foo/spec&quot;]
-        Config::CONFIG.stub!(:[]).and_return &quot;/foo&quot;
-        File.should_receive(:exists?).with(&quot;/foo/spec&quot;).and_return(true)
-
-        @rspec_autotest.spec_command.should == &quot;/foo/spec&quot;
-      end
-    
-      it &quot;should raise an error if no spec command is found at all&quot; do
-        File.stub!(:exists?).and_return false
-      
-        lambda {
-          @rspec_autotest.spec_command
-        }.should raise_error(RspecCommandError, &quot;No spec command could be found!&quot;)
-      end
-    end
-    
-    describe &quot;selection of rspec command (windows compatibility issues)&quot; do
-      include AutotestHelper
-    
-      before(:each) do
-        common_setup
-      end
-    
-      it &quot;should use the ALT_SEPARATOR if it is non-nil&quot; do
-        @rspec_autotest = Rspec.new
-        spec_command = File.expand_path(&quot;#{File.dirname(__FILE__)}/../../bin/spec&quot;)
-        @rspec_autotest.stub!(:spec_commands).and_return [spec_command]
-        @rspec_autotest.spec_command(@windows_alt_separator).should == spec_command.gsub('/', @windows_alt_separator)
-      end
-    
-      it &quot;should not use the ALT_SEPATOR if it is nil&quot; do
-        @windows_alt_separator = nil
-        @rspec_autotest = Rspec.new
-        spec_command = File.expand_path(&quot;#{File.dirname(__FILE__)}/../../bin/spec&quot;)
-        @rspec_autotest.stub!(:spec_commands).and_return [spec_command]
-        @rspec_autotest.spec_command.should == spec_command
-      end
-    end
-
     describe &quot;adding spec.opts --options&quot; do 
       before(:each) do
         @rspec_autotest = Rspec.new
@@ -116,7 +60,6 @@ HERE
         @rspec_autotest.stub!(:add_options_if_present).and_return &quot;-O spec/spec.opts&quot;
       
         @ruby = @rspec_autotest.ruby
-        @spec_command = @rspec_autotest.spec_command
         @options = @rspec_autotest.add_options_if_present
         @files_to_test = {
           :spec =&gt; [&quot;file_one&quot;, &quot;file_two&quot;]
@@ -126,16 +69,13 @@ HERE
         @files_to_test.stub!(:keys).and_return @files_to_test[:spec]
         @to_test = @files_to_test.keys.flatten.join ' '
       end
-
-      it &quot;should contain the various commands, ordered by preference&quot; do
-        Rspec.new.spec_commands.should == [
-          File.expand_path(&quot;#{File.dirname(__FILE__)}/../../bin/spec&quot;),
-          &quot;#{Config::CONFIG['bindir']}/spec&quot;
-        ]
-      end
     
-      it &quot;should make the apropriate test command&quot; do
-        @rspec_autotest.make_test_cmd(@files_to_test).should == &quot;#{@ruby} -S #{@spec_command} #{@options} #{@to_test}&quot;
+      it &quot;should make the appropriate test command&quot; do
+        @rspec_autotest.make_test_cmd(@files_to_test).should == &quot;#{@ruby} -S #{@to_test} #{@options}&quot;
+      end
+
+      it &quot;should return a blank command for no files&quot; do
+        @rspec_autotest.make_test_cmd({}).should == ''
       end
     end
   </diff>
      <filename>vendor/plugins/rspec/spec/autotest/rspec_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -125,14 +125,14 @@ module Spec
         it &quot;should register ExampleGroup by default&quot; do
           example_group = Spec::Example::ExampleGroupFactory.create_example_group(&quot;The ExampleGroup&quot;) do
           end
-          rspec_options.example_groups.should include(example_group)
+          Spec::Runner.options.example_groups.should include(example_group)
         end
 
         it &quot;should enable unregistering of ExampleGroups&quot; do
           example_group = Spec::Example::ExampleGroupFactory.create_example_group(&quot;The ExampleGroup&quot;) do
             unregister
           end
-          rspec_options.example_groups.should_not include(example_group)
+          Spec::Runner.options.example_groups.should_not include(example_group)
         end
 
         after(:each) do</diff>
      <filename>vendor/plugins/rspec/spec/spec/example/example_group_factory_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,10 +3,12 @@ require File.dirname(__FILE__) + '/../../spec_helper'
 module Spec
   module Example
     describe 'ExampleGroupMethods' do
-      it_should_behave_like &quot;sandboxed rspec_options&quot;
+      include SandboxedOptions
       attr_reader :example_group, :result, :reporter
       before(:each) do
-        options.formatters &lt;&lt; mock(&quot;formatter&quot;, :null_object =&gt; true)
+        # See http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/525-arity-changed-on-partial-mocks#ticket-525-2
+        method_with_three_args = lambda { |arg1, arg2, arg3| }
+        options.formatters &lt;&lt; mock(&quot;formatter&quot;, :null_object =&gt; true, :example_pending =&gt; method_with_three_args)
         options.backtrace_tweaker = mock(&quot;backtrace_tweaker&quot;, :null_object =&gt; true)
         @reporter = FakeReporter.new(@options)
         options.reporter = reporter</diff>
      <filename>vendor/plugins/rspec/spec/spec/example/example_group_methods_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -65,10 +65,11 @@ module Spec
     end
 
     describe ExampleGroup, &quot;#run&quot; do
-      it_should_behave_like &quot;sandboxed rspec_options&quot;
+      include SandboxedOptions
       attr_reader :example_group, :formatter, :reporter
       before :each do
-        @formatter = mock(&quot;formatter&quot;, :null_object =&gt; true)
+        method_with_three_args = lambda { |arg1, arg2, arg3| }
+        @formatter = mock(&quot;formatter&quot;, :null_object =&gt; true, :example_pending =&gt; method_with_three_args)
         options.formatters &lt;&lt; formatter
         options.backtrace_tweaker = mock(&quot;backtrace_tweaker&quot;, :null_object =&gt; true)
         @reporter = FakeReporter.new(options)</diff>
      <filename>vendor/plugins/rspec/spec/spec/example/example_group_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,9 +23,9 @@ module Spec
 
       describe &quot;lifecycle&quot; do
         before do
-          @original_rspec_options = $rspec_options
+          @original_rspec_options = Spec::Runner.options
           @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new)
-          $rspec_options = @options
+          Spec::Runner.use @options
           @options.formatters &lt;&lt; mock(&quot;formatter&quot;, :null_object =&gt; true)
           @options.backtrace_tweaker = mock(&quot;backtrace_tweaker&quot;, :null_object =&gt; true)
           @reporter = FakeReporter.new(@options)
@@ -43,7 +43,7 @@ module Spec
         end
 
         after do
-          $rspec_options = @original_rspec_options
+          Spec::Runner.use @original_rspec_options
           ExampleMethods.instance_variable_set(&quot;@before_all_parts&quot;, [])
           ExampleMethods.instance_variable_set(&quot;@before_each_parts&quot;, [])
           ExampleMethods.instance_variable_set(&quot;@after_each_parts&quot;, [])</diff>
      <filename>vendor/plugins/rspec/spec/spec/example/example_methods_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -38,5 +38,32 @@ module Spec
         }.should raise_error(PendingExampleFixedError, /TODO/)
       end
     end
+    
+    describe ExamplePendingError do
+      it &quot;should have the caller (from two calls from initialization)&quot; do
+        two_calls_ago = caller[0]
+        ExamplePendingError.new(&quot;a message&quot;).pending_caller.should == two_calls_ago
+      end
+      
+      it &quot;should keep the trace information from initialization&quot; do
+        two_calls_ago = caller[0]
+        obj = ExamplePendingError.new(&quot;a message&quot;)
+        obj.pending_caller
+        def another_caller(obj)
+          obj.pending_caller
+        end
+        
+        another_caller(obj).should == two_calls_ago
+      end
+      
+      it &quot;should have the message provided&quot; do
+        ExamplePendingError.new(&quot;a message&quot;).message.should == &quot;a message&quot;
+      end
+
+      it &quot;should use a 'ExamplePendingError' as it's default message&quot; do
+        ExamplePendingError.new.message.should == &quot;Spec::Example::ExamplePendingError&quot;
+      end
+    end
+    
   end
 end</diff>
      <filename>vendor/plugins/rspec/spec/spec/example/pending_module_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
 module Spec
   module Example
     describe ExampleGroup, &quot;with :shared =&gt; true&quot; do
-      it_should_behave_like &quot;sandboxed rspec_options&quot;
+      include SandboxedOptions
       attr_reader :formatter, :example_group
       before(:each) do
         @formatter = Spec::Mocks::Mock.new(&quot;formatter&quot;, :null_object =&gt; true)</diff>
      <filename>vendor/plugins/rspec/spec/spec/example/shared_example_group_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
 module Spec
   module Extensions
     describe Main do
-      it_should_behave_like &quot;sandboxed rspec_options&quot;
+      include SandboxedOptions
       before(:each) do
         @main = Class.new do; include Main; end
       end
@@ -12,11 +12,6 @@ module Spec
         $rspec_story_steps = @original_rspec_story_steps
       end
 
-      it &quot;should create an Options object&quot; do
-        @main.send(:rspec_options).should be_instance_of(Spec::Runner::Options)
-        @main.send(:rspec_options).should === $rspec_options
-      end
-  
       specify {@main.should respond_to(:describe)}
       specify {@main.should respond_to(:context)}
 
@@ -30,7 +25,7 @@ module Spec
 
       it &quot;should registered ExampleGroups by default&quot; do
         example_group = @main.describe(&quot;The ExampleGroup&quot;) do end
-        rspec_options.example_groups.should include(example_group)
+        Spec::Runner.options.example_groups.should include(example_group)
       end
 
       it &quot;should not run unregistered ExampleGroups&quot; do
@@ -38,7 +33,7 @@ module Spec
           unregister
         end
 
-        rspec_options.example_groups.should_not include(example_group)
+        Spec::Runner.options.example_groups.should_not include(example_group)
       end
       
       it &quot;should create a shared ExampleGroup with share_examples_for&quot; do</diff>
      <filename>vendor/plugins/rspec/spec/spec/extensions/main_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -315,3 +315,15 @@ describe &quot;should change{ block }.from(old).to(new)&quot; do
     lambda { @instance.some_value = &quot;cat&quot; }.should change{@instance.some_value}.from(&quot;string&quot;).to(&quot;cat&quot;)
   end
 end
+
+describe Spec::Matchers::Change do
+  it &quot;should work when the receiver has implemented #send&quot; do
+    @instance = SomethingExpected.new
+    @instance.some_value = &quot;string&quot;
+    def @instance.send(*args); raise &quot;DOH! Library developers shouldn't use #send!&quot; end
+    
+    lambda {
+      lambda { @instance.some_value = &quot;cat&quot; }.should change(@instance, :some_value)
+    }.should_not raise_error
+  end
+end</diff>
      <filename>vendor/plugins/rspec/spec/spec/matchers/change_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -51,3 +51,13 @@ describe &quot;should_not have_sym(*args)&quot; do
     lambda { o.should_not have_sym(:foo) }.should raise_error(&quot;Funky exception&quot;)
   end
 end
+
+describe Spec::Matchers::Has do
+  it &quot;should work when the target implements #send&quot; do
+    o = {:a =&gt; &quot;A&quot;}
+    def o.send(*args); raise &quot;DOH! Library developers shouldn't use #send!&quot; end
+    lambda {
+      o.should have_key(:a)
+    }.should_not raise_error
+  end
+end</diff>
      <filename>vendor/plugins/rspec/spec/spec/matchers/has_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -324,3 +324,71 @@ describe &quot;have(n).things on an object which is not a collection nor contains one
     lambda { Object.new.should have(2).things }.should raise_error(NoMethodError, /undefined method `things' for #&lt;Object:/)
   end
 end
+
+describe Spec::Matchers::Have, &quot;for a collection owner that implements #send&quot; do
+  include HaveSpecHelper
+
+  before(:each) do
+    @collection = Object.new
+    def @collection.floozles; [1,2] end
+    def @collection.send(*args); raise &quot;DOH! Library developers shouldn't use #send!&quot; end
+  end
+  
+  it &quot;should work in the straightforward case&quot; do
+    lambda {
+      @collection.should have(2).floozles
+    }.should_not raise_error
+  end
+
+  it &quot;should work when doing automatic pluralization&quot; do
+    lambda {
+      @collection.should have_at_least(1).floozle
+    }.should_not raise_error
+  end
+
+  it &quot;should blow up when the owner doesn't respond to that method&quot; do
+    lambda {
+      @collection.should have(99).problems
+    }.should raise_error(NoMethodError, /problems/)
+  end
+end
+
+module Spec
+  module Matchers
+    describe Have do
+      it &quot;should have method_missing as private&quot; do
+        Have.private_instance_methods.should include(&quot;method_missing&quot;)
+      end
+      
+      describe &quot;respond_to?&quot; do
+        before :each do
+          @have = Have.new(:foo)
+          @a_method_which_have_defines = Have.instance_methods.first
+          @a_method_which_object_defines = Object.instance_methods.first
+        end
+        
+        it &quot;should be true for a method which Have defines&quot; do
+          @have.should respond_to(@a_method_which_have_defines)
+        end
+        
+        it &quot;should be true for a method that it's superclass (Object) defines&quot; do
+          @have.should respond_to(@a_method_which_object_defines)
+        end
+        
+        it &quot;should be false for a method which neither Object nor nor Have defines&quot; do
+          @have.should_not respond_to(:foo_bar_baz)
+        end
+        
+        it &quot;should be false if the owner doesn't respond to the method&quot; do
+          have = Have.new(99)
+          have.should_not respond_to(:problems)
+        end
+        
+        it &quot;should be true if the owner responds to the method&quot; do
+          have = Have.new(:a_symbol)
+          have.should respond_to(:to_sym)
+        end
+      end
+    end
+  end
+end</diff>
      <filename>vendor/plugins/rspec/spec/spec/matchers/have_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -20,7 +20,7 @@ describe &quot;should ==&quot; do
     Spec::Expectations.should_receive(:fail_with).with(%[expected: &quot;orange&quot;,\n     got: &quot;apple&quot; (using ==)], &quot;orange&quot;, &quot;apple&quot;)
     subject.should == &quot;orange&quot;
   end
-
+  
 end
 
 describe &quot;should_not ==&quot; do
@@ -166,3 +166,26 @@ describe &quot;should &lt;=&quot; do
 
 end
 
+describe Spec::Matchers::PositiveOperatorMatcher do
+
+  it &quot;should work when the target has implemented #send&quot; do
+    o = Object.new
+    def o.send(*args); raise &quot;DOH! Library developers shouldn't use #send!&quot; end
+    lambda {
+      o.should == o
+    }.should_not raise_error
+  end
+
+end
+
+describe Spec::Matchers::NegativeOperatorMatcher do
+
+  it &quot;should work when the target has implemented #send&quot; do
+    o = Object.new
+    def o.send(*args); raise &quot;DOH! Library developers shouldn't use #send!&quot; end
+    lambda {
+      o.should_not == :foo
+    }.should_not raise_error
+  end
+
+end</diff>
      <filename>vendor/plugins/rspec/spec/spec/matchers/operator_matcher_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,6 +23,13 @@ module Spec
       it &quot;should pass if any number of times method is not called&quot; do
         @mock.should_receive(:random_call).any_number_of_times
       end
+
+      it &quot;should return the mocked value when called after a similar stub&quot; do
+        @mock.stub!(:message).and_return :stub_value
+        @mock.should_receive(:message).any_number_of_times.and_return(:mock_value)
+        @mock.message.should == :mock_value
+        @mock.message.should == :mock_value
+      end
     end
 
   end</diff>
      <filename>vendor/plugins/rspec/spec/spec/mocks/any_number_of_times_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -23,6 +23,18 @@ module Spec
         end
       end
       
+      it &quot;should report line number of expectation of unreceived message after #should_receive after similar stub&quot; do
+        @mock.stub!(:wont_happen)
+        expected_error_line = __LINE__; @mock.should_receive(:wont_happen).with(&quot;x&quot;, 3)
+        begin
+          @mock.rspec_verify
+          violated
+        rescue MockExpectationError =&gt; e
+          # NOTE - this regexp ended w/ $, but jruby adds extra info at the end of the line
+          e.backtrace[0].should match(/#{File.basename(__FILE__)}:#{expected_error_line}/)
+        end
+      end
+      
       it &quot;should pass when not receiving message specified as not to be received&quot; do
         @mock.should_not_receive(:not_expected)
         @mock.rspec_verify
@@ -403,7 +415,16 @@ module Spec
         @mock.msg.should equal(:stub_value)
         @mock.rspec_verify
       end
-    
+
+      it &quot;should not require a different signature to replace a method stub&quot; do
+        @mock.stub!(:msg).and_return(:stub_value)
+        @mock.should_receive(:msg).and_return(:mock_value)
+        @mock.msg(:arg).should equal(:mock_value)
+        @mock.msg.should equal(:stub_value)
+        @mock.msg.should equal(:stub_value)
+        @mock.rspec_verify
+      end
+
       it &quot;should temporarily replace a method stub on a non-mock&quot; do
         non_mock = Object.new
         non_mock.stub!(:msg).and_return(:stub_value)
@@ -413,7 +434,22 @@ module Spec
         non_mock.msg.should equal(:stub_value)
         non_mock.rspec_verify
       end
-      
+
+      it &quot;should return the stubbed value when no new value specified&quot; do
+        @mock.stub!(:msg).and_return(:stub_value)
+        @mock.should_receive(:msg)
+        @mock.msg.should equal(:stub_value)
+        @mock.rspec_verify
+      end
+
+      it &quot;should not mess with the stub's yielded values when also mocked&quot; do
+        @mock.stub!(:yield_back).and_yield(:stub_value)
+        @mock.should_receive(:yield_back).and_yield(:mock_value)
+        @mock.yield_back{|v| v}.should == :mock_value
+        @mock.yield_back{|v| v}.should == :stub_value
+        @mock.rspec_verify
+      end
+
       it &quot;should assign stub return values&quot; do
         mock = Mock.new('name', :message =&gt; :response)
         mock.message.should == :response
@@ -439,6 +475,15 @@ module Spec
         @calls.should == 1
       end
     
+      it &quot;should call the block after #should_receive after a similar stub&quot; do
+        @mock.stub!(:foo).and_return(:bar)
+        @mock.should_receive(:foo) { add_call }
+    
+        @mock.foo
+    
+        @calls.should == 1
+      end
+    
       it &quot;should call the block after #once&quot; do
         @mock.should_receive(:foo).once { add_call }
     </diff>
      <filename>vendor/plugins/rspec/spec/spec/mocks/mock_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -36,5 +36,19 @@ module Spec
         @mock.message(:unexpected_arg)
       end
     end
+
+    describe &quot;#null_object?&quot; do
+      it &quot;should default to false&quot; do
+        obj = mock('anything')
+        obj.should_not be_null_object
+      end
+    end
+    
+    describe &quot;#as_null_object&quot; do
+      it &quot;should set the object to null_object&quot; do
+        obj = mock('anything').as_null_object
+        obj.should be_null_object
+      end
+    end
   end
 end</diff>
      <filename>vendor/plugins/rspec/spec/spec/mocks/null_object_mock_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,42 +3,32 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
 module Spec
   module Mocks
     describe &quot;calling :should_receive with an options hash&quot; do
-      it_should_behave_like &quot;sandboxed rspec_options&quot;
-      attr_reader :reporter, :example_group
-      before do
-        @reporter = ::Spec::Runner::Reporter.new(options)
-        @example_group = Class.new(::Spec::Example::ExampleGroup) do
-          plugin_mock_framework
-          describe(&quot;Some Examples&quot;)
-        end
-        reporter.add_example_group example_group
-      end
-
       it &quot;should report the file and line submitted with :expected_from&quot; do
-        example_definition = example_group.it &quot;spec&quot; do
+        begin
           mock = Spec::Mocks::Mock.new(&quot;a mock&quot;)
           mock.should_receive(:message, :expected_from =&gt; &quot;/path/to/blah.ext:37&quot;)
           mock.rspec_verify
+        rescue =&gt; e
+        ensure
+          e.backtrace.to_s.should =~ /\/path\/to\/blah.ext:37/m
         end
-        example = example_group.new(example_definition)
-        
-        reporter.should_receive(:example_finished) do |spec, error|
-          error.backtrace.detect {|line| line =~ /\/path\/to\/blah.ext:37/}.should_not be_nil
-        end
-        example.execute(options, {})
       end
 
       it &quot;should use the message supplied with :message&quot; do
-        example_definition = @example_group.it &quot;spec&quot; do
-          mock = Spec::Mocks::Mock.new(&quot;a mock&quot;)
-          mock.should_receive(:message, :message =&gt; &quot;recebi nada&quot;)
-          mock.rspec_verify
-        end
-        example = @example_group.new(example_definition)
-        @reporter.should_receive(:example_finished) do |spec, error|
-          error.message.should == &quot;recebi nada&quot;
-        end
-        example.execute(@options, {})
+        lambda {
+          m = Spec::Mocks::Mock.new(&quot;a mock&quot;)
+          m.should_receive(:message, :message =&gt; &quot;recebi nada&quot;)
+          m.rspec_verify
+        }.should raise_error(&quot;recebi nada&quot;)
+      end
+      
+      it &quot;should use the message supplied with :message after a similar stub&quot; do
+        lambda {
+          m = Spec::Mocks::Mock.new(&quot;a mock&quot;)
+          m.stub!(:message)
+          m.should_receive(:message, :message =&gt; &quot;from mock&quot;)
+          m.rspec_verify
+        }.should raise_error(&quot;from mock&quot;)
       end
     end
   end</diff>
      <filename>vendor/plugins/rspec/spec/spec/mocks/options_hash_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -44,6 +44,12 @@ module Spec
           @instance.rspec_verify
         end.should_not raise_error
       end
+
+      it &quot;should handle multiple stubbed methods&quot; do
+        @instance.stub!(:msg1 =&gt; 1, :msg2 =&gt; 2)
+        @instance.msg1.should == 1
+        @instance.msg2.should == 2
+      end
       
       it &quot;should clear itself when verified&quot; do
         @instance.stub!(:this_should_go).and_return(:blah)</diff>
      <filename>vendor/plugins/rspec/spec/spec/mocks/stub_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,16 +3,16 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
 module Spec
   module Runner
     describe CommandLine, &quot;.run&quot; do
-      it_should_behave_like &quot;sandboxed rspec_options&quot;
+      include SandboxedOptions
       attr_reader :options, :err, :out
       before do
         @err = options.error_stream
         @out = options.output_stream
       end
-
+      
       it &quot;should run directory&quot; do
         file = File.dirname(__FILE__) + '/../../../examples/pure'
-        Spec::Runner::CommandLine.run(OptionParser.parse([file,&quot;-p&quot;,&quot;**/*.rb&quot;], @err, @out))
+        run_with(OptionParser.parse([file,&quot;-p&quot;,&quot;**/*.rb&quot;], @err, @out))
 
         @out.rewind
         @out.read.should =~ /\d+ examples, 0 failures, 3 pending/n
@@ -20,7 +20,7 @@ module Spec
 
       it &quot;should run file&quot; do
         file = File.dirname(__FILE__) + '/../../../failing_examples/predicate_example.rb'
-        Spec::Runner::CommandLine.run(OptionParser.parse([file], @err, @out))
+        run_with(OptionParser.parse([file], @err, @out))
 
         @out.rewind
         @out.read.should =~ /2 examples, 1 failure/n
@@ -130,18 +130,11 @@ module Spec
         options.reporter.should_receive(:add_example_group).with(example_group)
 
         options.add_example_group example_group
-        Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out))
+        run_with(options)
 
         should_has_run.should be_true
         should_not_has_run.should be_false
       end
-
-      it &quot;sets Spec.run to true&quot; do
-        ::Spec.run = false
-        ::Spec.should_not be_run
-        Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out))
-        ::Spec.should be_run
-      end
     end
   end
 end
\ No newline at end of file</diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/command_line_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,8 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
 module Spec
   module Runner
     describe DrbCommandLine, &quot;without running local server&quot; do
+      include SandboxedOptions
+      
       unless Config::CONFIG['ruby_install_name'] == 'jruby'
         it &quot;should print error when there is no running local server&quot; do
           err = StringIO.new
@@ -15,12 +17,16 @@ module Spec
       end    
     end
 
-    class DrbCommandLineSpec &lt; ::Spec::Example::ExampleGroup
-      describe DrbCommandLine, &quot;with local server&quot;
+    describe &quot;with local server&quot; do
 
       class CommandLineForSpec
         def self.run(argv, stderr, stdout)
-          exit Spec::Runner::CommandLine.run(OptionParser.parse(argv, stderr, stdout))
+          orig_options = Spec::Runner.options
+          tmp_options = OptionParser.parse(argv, stderr, stdout)
+          Spec::Runner.use tmp_options
+          Spec::Runner::CommandLine.run(tmp_options)
+        ensure
+          Spec::Runner.use orig_options
         end
       end
       
@@ -86,7 +92,8 @@ module Spec
           out.rewind; out.read
         end
       end
-
+      
     end
+
   end
 end</diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/drb_command_line_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,7 @@ module Spec
   module Runner
     module Formatter
       describe HtmlFormatter do
+        include SandboxedOptions
         ['--diff', '--dry-run'].each do |opt|
           def jruby?
             PLATFORM == 'java'
@@ -22,7 +23,7 @@ module Spec
               args = ['failing_examples/mocking_example.rb', 'failing_examples/diffing_spec.rb', 'examples/pure/stubbing_example.rb',  'examples/pure/pending_example.rb', '--format', 'html', opt]
               err = StringIO.new
               out = StringIO.new
-              CommandLine.run(
+              run_with(
                 OptionParser.parse(args, err, out)
               )
 </diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/formatter/html_formatter_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ module Spec
   module Runner
     module Formatter
       describe NestedTextFormatter do
-        it_should_behave_like &quot;sandboxed rspec_options&quot;
+        include SandboxedOptions
         attr_reader :io, :options, :formatter, :example_group
         before(:each) do
           @io = StringIO.new
@@ -304,7 +304,7 @@ module Spec
 
           describe &quot;#example_pending&quot; do
             it &quot;should push pending example name and message&quot; do
-              formatter.example_pending(example_group.examples.first, 'reason')
+              formatter.example_pending(example_group.examples.first, 'reason', &quot;#{__FILE__}:#{__LINE__}&quot;)
               expected_output = &lt;&lt;-OUT
               ExampleGroup
                 example (PENDING: reason)
@@ -313,7 +313,7 @@ module Spec
             end
 
             it &quot;should dump pending&quot; do
-              formatter.example_pending(example_group.examples.first, 'reason')
+              formatter.example_pending(example_group.examples.first, 'reason', &quot;#{__FILE__}:#{__LINE__}&quot;)
               io.rewind
               formatter.dump_pending
               io.string.should =~ /Pending\:\nExampleGroup example \(reason\)\n/</diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/formatter/nested_text_formatter_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -29,7 +29,7 @@ module Spec
             end
           end
           example = example_group.examples.first
-          @formatter.example_pending(example, &quot;message&quot;)
+          @formatter.example_pending(example, &quot;message&quot;, &quot;#{__FILE__}:#{__LINE__}&quot;)
           @io.rewind
           @formatter.dump_summary(3, 2, 1, 1)
           @io.string.should eql(%Q|
@@ -94,10 +94,28 @@ EOE
             end
           end
           example = example_group.examples.first
-          @formatter.example_pending(example, &quot;message&quot;)
+          @formatter.example_pending(example, &quot;message&quot;, &quot;#{__FILE__}:#{__LINE__}&quot;)
           @formatter.dump_pending
           @io.string.should =~ /Pending\:\nexample_group example \(message\)\n/
         end
+        
+        it &quot;should dump pending with file and line number&quot; do
+          example_group = ExampleGroup.describe(&quot;example_group&quot;) do
+            specify &quot;example&quot; do
+            end
+          end
+          example = example_group.examples.first
+          file = __FILE__
+          line = __LINE__ + 1
+          @formatter.example_pending(example, &quot;message&quot;, &quot;#{__FILE__}:#{__LINE__}&quot;)
+          @formatter.dump_pending
+          @io.string.should ==(&lt;&lt;-HERE)
+P
+Pending:
+example_group example (message)
+  Called from #{file}:#{line}
+HERE
+        end
       end
       
       describe &quot;ProgressBarFormatter outputting to custom out&quot; do</diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/formatter/progress_bar_formatter_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,7 @@ module Spec
   module Runner
     module Formatter
       describe TextMateFormatter do
+        include SandboxedOptions
         attr_reader :root, :suffix, :expected_file
         before do
           @root = File.expand_path(File.dirname(__FILE__) + '/../../../..')
@@ -33,7 +34,7 @@ module Spec
             err = StringIO.new
             out = StringIO.new
             options = ::Spec::Runner::OptionParser.parse(args, err, out)
-            Spec::Runner::CommandLine.run(options)
+            run_with(options)
 
             yield(out.string)
           end          </diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ module Spec
   module Runner
     module Formatter
       describe SpecdocFormatter do
-        it_should_behave_like &quot;sandboxed rspec_options&quot;
+        include SandboxedOptions
         attr_reader :io, :options, :formatter, :example_group
         before(:each) do
           @io = StringIO.new
@@ -133,12 +133,12 @@ module Spec
 
           describe &quot;#example_pending&quot; do
             it &quot;should push pending example name and message&quot; do
-              formatter.example_pending(example_group.examples.first, 'reason')
+              formatter.example_pending(example_group.examples.first, 'reason', &quot;#{__FILE__}:#{__LINE__}&quot;)
               io.string.should have_example_group_output(&quot;- example (PENDING: reason)\n&quot;)
             end
 
             it &quot;should dump pending&quot; do
-              formatter.example_pending(example_group.examples.first, 'reason')
+              formatter.example_pending(example_group.examples.first, 'reason', &quot;#{__FILE__}:#{__LINE__}&quot;)
               io.rewind
               formatter.dump_pending
               io.string.should =~ /Pending\:\nExampleGroup example \(reason\)\n/</diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/formatter/specdoc_formatter_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -61,6 +61,54 @@ module Spec
 EOF
           end
           
+          it 'should document additional givens using And' do
+            # when
+            @reporter.step_succeeded :given, 'step 1'
+            @reporter.step_succeeded :given, 'step 2'
+            @reporter.scenario_ended
+            @reporter.story_ended '', ''
+
+            # then
+            @out.string.should include(&quot;Given step 1&quot;)
+            @out.string.should include(&quot;And step 2&quot;)
+          end
+
+          it 'should document additional events using And' do
+            # when
+            @reporter.step_succeeded :when, 'step 1'
+            @reporter.step_succeeded :when, 'step 2'
+            @reporter.scenario_ended
+            @reporter.story_ended '', ''
+
+            # then
+            @out.string.should include(&quot;When step 1&quot;)
+            @out.string.should include(&quot;And step 2&quot;)
+          end
+
+          it 'should document additional outcomes using And' do
+            # when
+            @reporter.step_succeeded :then, 'step 1'
+            @reporter.step_succeeded :then, 'step 2'
+            @reporter.scenario_ended
+            @reporter.story_ended '', ''
+
+            # then
+            @out.string.should include(&quot;Then step 1&quot;)
+            @out.string.should include(&quot;And step 2&quot;)
+          end
+
+          it 'should document a GivenScenario followed by a Given using And' do
+            # when
+            @reporter.step_succeeded :'given scenario', 'a scenario'
+            @reporter.step_succeeded :given, 'a context'
+            @reporter.scenario_ended
+            @reporter.story_ended '', ''
+
+            # then
+            @out.string.should include(&quot;Given scenario a scenario&quot;)
+            @out.string.should include(&quot;And a context&quot;)
+          end
+          
           it &quot;should create a failed story if one of its scenarios fails&quot; do
               @reporter.story_started('story_title', 'narrative')
               @reporter.scenario_started('story_title', 'succeeded_scenario_name')</diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/formatter/story/html_formatter_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -159,6 +159,45 @@ module Spec
             @out.string.should include(&quot;3 scenarios: 1 succeeded, 1 failed, 1 pending&quot;)
           end
 
+          it 'should show test summary in red if there were failed scenarios' do
+            # when
+            @out.stub!(:tty?).and_return(true)
+            @options.stub!(:colour).and_return(true)
+
+            @formatter.scenario_started(nil, nil)
+            @formatter.scenario_failed('story', 'scenario', exception_from { raise RuntimeError, 'oops' })
+            @formatter.run_ended
+
+            # then
+            @out.string.should include(&quot;\e[31m scenarios: 0 succeeded, 1 failed, 0 pending\e[0m&quot;)
+          end
+
+          it 'should show test summary in yellow if there are pending scenarios' do
+            # when
+            @out.stub!(:tty?).and_return(true)
+            @options.stub!(:colour).and_return(true)
+
+            @formatter.scenario_started(nil, nil)
+            @formatter.scenario_pending('story', 'scenario', '')
+            @formatter.run_ended
+
+            # then
+            @out.string.should include(&quot;\e[32m scenarios: 0 succeeded, 0 failed, 1 pending\e[0m&quot;)
+          end
+
+          it 'should show test summary in green if all scenarios pass' do
+            # when
+            @out.stub!(:tty?).and_return(true)
+            @options.stub!(:colour).and_return(true)
+
+            @formatter.scenario_started(nil, nil)
+            @formatter.scenario_succeeded('story', 'scenario')
+            @formatter.run_ended
+
+            # then
+            @out.string.should include(&quot;\e[32m scenarios: 1 succeeded, 0 failed, 0 pending\e[0m&quot;)
+          end
+        
           it 'should produce details of the first failure each failed scenario when the run ends' do
             # when
             @formatter.run_started(3)
@@ -180,6 +219,19 @@ module Spec
             @out.string.should include(&quot;RuntimeError: oops3&quot;)
           end
 
+          it 'should produce details of the failures in red when the run ends' do
+            # when
+            @out.stub!(:tty?).and_return(true)
+            @options.stub!(:colour).and_return(true)
+            @formatter.scenario_started(nil, nil)
+            @formatter.scenario_failed('story', 'scenario1', exception_from { raise RuntimeError, 'oops1' })
+            @formatter.run_ended
+
+            # then
+            @out.string.should =~ /\e\[31m[\n\s]*story \(scenario1\) FAILED\e\[0m/m
+            @out.string.should =~ /\e\[31m[\n\s]*RuntimeError: oops1\e\[0m/m
+          end
+
           it 'should produce details of each pending step when the run ends' do
             # when
             @formatter.run_started(2)</diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -21,18 +21,18 @@ unless [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM}
     end
 
     it &quot;should heckle all methods in all classes in a module&quot; do
-      @heckle_class.should_receive(:new).with(&quot;Foo::Bar&quot;, &quot;one&quot;, rspec_options).and_return(@heckle)
-      @heckle_class.should_receive(:new).with(&quot;Foo::Bar&quot;, &quot;two&quot;, rspec_options).and_return(@heckle)
-      @heckle_class.should_receive(:new).with(&quot;Foo::Zap&quot;, &quot;three&quot;, rspec_options).and_return(@heckle)
-      @heckle_class.should_receive(:new).with(&quot;Foo::Zap&quot;, &quot;four&quot;, rspec_options).and_return(@heckle)
+      @heckle_class.should_receive(:new).with(&quot;Foo::Bar&quot;, &quot;one&quot;, Spec::Runner.options).and_return(@heckle)
+      @heckle_class.should_receive(:new).with(&quot;Foo::Bar&quot;, &quot;two&quot;, Spec::Runner.options).and_return(@heckle)
+      @heckle_class.should_receive(:new).with(&quot;Foo::Zap&quot;, &quot;three&quot;, Spec::Runner.options).and_return(@heckle)
+      @heckle_class.should_receive(:new).with(&quot;Foo::Zap&quot;, &quot;four&quot;, Spec::Runner.options).and_return(@heckle)
 
       heckle_runner = Spec::Runner::HeckleRunner.new(&quot;Foo&quot;, @heckle_class)
       heckle_runner.heckle_with
     end
 
     it &quot;should heckle all methods in a class&quot; do
-      @heckle_class.should_receive(:new).with(&quot;Foo::Bar&quot;, &quot;one&quot;, rspec_options).and_return(@heckle)
-      @heckle_class.should_receive(:new).with(&quot;Foo::Bar&quot;, &quot;two&quot;, rspec_options).and_return(@heckle)
+      @heckle_class.should_receive(:new).with(&quot;Foo::Bar&quot;, &quot;one&quot;, Spec::Runner.options).and_return(@heckle)
+      @heckle_class.should_receive(:new).with(&quot;Foo::Bar&quot;, &quot;two&quot;, Spec::Runner.options).and_return(@heckle)
 
       heckle_runner = Spec::Runner::HeckleRunner.new(&quot;Foo::Bar&quot;, @heckle_class)
       heckle_runner.heckle_with
@@ -46,14 +46,14 @@ unless [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM}
     end
 
     it &quot;should heckle specific method in a class (with #)&quot; do
-      @heckle_class.should_receive(:new).with(&quot;Foo::Bar&quot;, &quot;two&quot;, rspec_options).and_return(@heckle)
+      @heckle_class.should_receive(:new).with(&quot;Foo::Bar&quot;, &quot;two&quot;, Spec::Runner.options).and_return(@heckle)
 
       heckle_runner = Spec::Runner::HeckleRunner.new(&quot;Foo::Bar#two&quot;, @heckle_class)
       heckle_runner.heckle_with
     end
 
     it &quot;should heckle specific method in a class (with .)&quot; do
-      @heckle_class.should_receive(:new).with(&quot;Foo::Bar&quot;, &quot;two&quot;, rspec_options).and_return(@heckle)
+      @heckle_class.should_receive(:new).with(&quot;Foo::Bar&quot;, &quot;two&quot;, Spec::Runner.options).and_return(@heckle)
 
       heckle_runner = Spec::Runner::HeckleRunner.new(&quot;Foo::Bar.two&quot;, @heckle_class)
       heckle_runner.heckle_with</diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/heckle_runner_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,21 @@
 require File.dirname(__FILE__) + '/../../spec_helper.rb'
 require 'fileutils'
 
+module Custom
+  class ExampleGroupRunner
+    attr_reader :options, :arg
+    def initialize(options, arg)
+      @options, @arg = options, arg
+    end
+
+    def load_files(files)
+    end
+
+    def run
+    end
+  end  
+end
+
 describe &quot;OptionParser&quot; do
   before(:each) do
     @out = StringIO.new
@@ -231,19 +246,19 @@ describe &quot;OptionParser&quot; do
   
   describe &quot;when attempting a focussed spec&quot; do
     attr_reader :file, :dir
-    before do
-      @original_rspec_options = $rspec_options
+    before(:each) do
+      @original_rspec_options = Spec::Runner.options
       @file = &quot;#{File.dirname(__FILE__)}/spec_parser/spec_parser_fixture.rb&quot;
       @dir = File.dirname(file)
     end
   
-    after do
-      $rspec_options = @original_rspec_options
+    after(:each) do
+      Spec::Runner.use @original_rspec_options
     end
   
     def parse(args)
       options = super
-      $rspec_options = options
+      Spec::Runner.use options
       options.filename_pattern = &quot;*_fixture.rb&quot;
       options
     end</diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/option_parser_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 dir = File.dirname(__FILE__)
 require &quot;#{dir}/../../spec_helper&quot;
 
-triggering_double_output = rspec_options
+triggering_double_output = Spec::Runner.options
 options = Spec::Runner::OptionParser.parse(
   [&quot;#{dir}/output_one_time_fixture.rb&quot;], $stderr, $stdout
 )</diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/output_one_time_fixture_runner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -51,6 +51,12 @@ module Spec
         @tweaker.tweak_backtrace(@error)
         @error.backtrace.should include(&quot;/a/b/c/d.rb&quot;)
       end
+
+      it &quot;should gracefully handle backtraces with newlines&quot; do
+        @error.set_backtrace([&quot;we like\nbin/spec:\nnewlines&quot;])
+        @tweaker.tweak_backtrace(@error)
+        @error.backtrace.should include(&quot;we like\nnewlines&quot;)
+      end
     end
   end
 end</diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/quiet_backtrace_tweaker_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -155,26 +155,98 @@ module Spec
       end
 
       describe Reporter, &quot;reporting one pending example (ExamplePendingError)&quot; do
+        before :each do
+          @pending_error = Spec::Example::ExamplePendingError.new(&quot;reason&quot;)
+          @pending_caller = @pending_error.pending_caller
+        end
+        
         it &quot;should tell formatter example is pending&quot; do
           example = ExampleGroup.new(&quot;example&quot;)
-          formatter.should_receive(:example_pending).with(example, &quot;reason&quot;)
+          formatter.should_receive(:example_pending).with(example, &quot;reason&quot;, @pending_caller)
           formatter.should_receive(:add_example_group).with(example_group)
           reporter.add_example_group(example_group)
-          reporter.example_finished(example, Spec::Example::ExamplePendingError.new(&quot;reason&quot;))
+          reporter.example_finished(example, @pending_error)
         end
 
         it &quot;should account for pending example in stats&quot; do
           example = ExampleGroup.new(&quot;example&quot;)
-          formatter.should_receive(:example_pending).with(example, &quot;reason&quot;)
+          formatter.should_receive(:example_pending).with(example, &quot;reason&quot;, @pending_caller)
           formatter.should_receive(:start_dump)
           formatter.should_receive(:dump_pending)
           formatter.should_receive(:dump_summary).with(anything(), 1, 0, 1)
           formatter.should_receive(:close).with(no_args)
           formatter.should_receive(:add_example_group).with(example_group)
           reporter.add_example_group(example_group)
-          reporter.example_finished(example, Spec::Example::ExamplePendingError.new(&quot;reason&quot;))
+          reporter.example_finished(example, @pending_error)
           reporter.dump
         end
+        
+        describe &quot;warning messages for formatters which have example_pending's arity of 2&quot; do
+          before :each do
+            Kernel.stub!(:warn)
+            default_formatter = @formatter
+            
+            @file = __FILE__
+            @line = __LINE__ + 3
+            
+            @deprecated_formatter = Class.new(default_formatter.class) do
+              def example_pending(example_passed_to_method, message_passed_to_method)
+                @example_passed_to_method = example_passed_to_method
+                @message_passed_to_method = message_passed_to_method
+              end
+              
+              attr_reader :example_passed_to_method
+              attr_reader :message_passed_to_method
+              
+            end.new(options, formatter_output)
+            
+            options.formatters &lt;&lt; @deprecated_formatter
+          end
+          
+          it &quot;should not raise an error&quot; do
+            lambda {
+              example = ExampleGroup.new(&quot;example&quot;)
+              reporter.add_example_group(example_group)
+              reporter.example_finished(example, @pending_error)
+            }.should_not raise_error
+          end
+          
+          it &quot;should use correct example&quot; do
+            example = ExampleGroup.new(&quot;example&quot;)
+            reporter.add_example_group(example_group)
+            reporter.example_finished(example, @pending_error)
+            
+            @deprecated_formatter.example_passed_to_method.should == example
+          end
+          
+          it &quot;should use correct pending error message&quot; do
+            example = ExampleGroup.new(&quot;example&quot;)
+            reporter.add_example_group(example_group)
+            reporter.example_finished(example, @pending_error)
+            
+            @deprecated_formatter.message_passed_to_method.should == &quot;reason&quot;
+          end
+          
+          it &quot;should raise a warning (calling Kernel.warn)&quot; do
+            Kernel.should_receive(:warn)
+
+            example = ExampleGroup.new(&quot;example&quot;)
+            reporter.add_example_group(example_group)
+            reporter.example_finished(example, @pending_error)
+          end
+          
+          def warning_message
+            Spec::Runner::Reporter::PENDING_FORMATTER_DEPRECATION_MESSAGE
+          end
+          
+          it &quot;should raise a warning with a warning message of the file and line number of the formatter&quot; do
+            Kernel.should_receive(:warn).with(warning_message)
+            
+            example = ExampleGroup.new(&quot;example&quot;)
+            reporter.add_example_group(example_group)
+            reporter.example_finished(example, @pending_error)
+          end
+        end
       end
 
       describe Reporter, &quot;reporting one pending example (PendingExampleFixedError)&quot; do</diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/reporter_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,15 +3,15 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
 describe &quot;SpecParser&quot; do
   attr_reader :parser, :file
   before(:each) do
-    @original_rspec_options = $rspec_options
-    $rspec_options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new)
+    @original_rspec_options = Spec::Runner.options
+    Spec::Runner.use ::Spec::Runner::Options.new(StringIO.new, StringIO.new)
     @parser = Spec::Runner::SpecParser.new
     @file = &quot;#{File.dirname(__FILE__)}/spec_parser/spec_parser_fixture.rb&quot;
     load file
   end
 
-  after do
-    $rspec_options = @original_rspec_options
+  after(:each) do
+    Spec::Runner.use @original_rspec_options
   end
 
   it &quot;should find spec name for 'specify' at same line&quot; do</diff>
      <filename>vendor/plugins/rspec/spec/spec/runner/spec_parser_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,11 +22,8 @@ module Spec
         
         it &quot;should parse a story file&quot; do
           runner = PlainTextStoryRunner.new(&quot;path&quot;)
-          during {
-            runner.run(mock('runner'))
-          }.expect {
-            @parser.should_receive(:parse).with([&quot;this&quot;, &quot;and that&quot;])
-          }
+          @parser.should_receive(:parse).with([&quot;this&quot;, &quot;and that&quot;])
+          runner.run(mock('runner'))
         end
         
         it &quot;should build up a mediator with its own steps and the singleton story_runner&quot; do</diff>
      <filename>vendor/plugins/rspec/spec/spec/story/runner/plain_text_story_runner_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,9 +8,7 @@ module Spec
         story = StoryBuilder.new.to_story
         
         # when
-        error = exception_from do
-          Scenario.new story, 'name'
-        end
+        error = exception_from { Scenario.new story, 'name' }
         
         # then
         error.should be_nil</diff>
      <filename>vendor/plugins/rspec/spec/spec/story/scenario_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -42,6 +42,18 @@ module Spec
         end.should raise_error(Spec::Example::ExamplePendingError, /Unimplemented/)
       end
       
+      it &quot;should create a default step with it's name stripped&quot; do
+        # given
+        step_mother = StepMother.new
+        
+        # when
+        step = step_mother.find(:given, &quot;doesn't exist\n\n&quot;)
+        
+        # then
+        step.should be_an_instance_of(Step)
+        step.name.should == &quot;doesn't exist&quot;
+      end
+      
       it 'should clear itself' do
         # given
         step_mother = StepMother.new</diff>
      <filename>vendor/plugins/rspec/spec/spec/story/step_mother_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,12 +2,17 @@ require File.dirname(__FILE__) + '/story_helper'
 
 module Spec
   module Story
-    describe Step, &quot;matching&quot; do
+    describe Step, &quot;#matching&quot; do
       it &quot;should match a text string&quot; do
         step = Step.new(&quot;this text&quot;) {}
         step.matches?(&quot;this text&quot;).should be_true
       end
       
+      it &quot;should match a text string that has additional line returns&quot; do
+        step = Step.new(&quot;this text&quot;) {}
+        step.matches?(&quot;this text\n\n&quot;).should be_true
+      end
+      
       it &quot;should not match a text string that does not start the same&quot; do
         step = Step.new(&quot;this text&quot;) {}
         step.matches?(&quot;Xthis text&quot;).should be_false
@@ -32,6 +37,11 @@ module Spec
         step = Step.new(&quot;1 $one 2 $two 3 $three 4&quot;) {}
         step.matches?(&quot;1 a 2 b 3 c 4&quot;).should be_true
       end
+
+      it &quot;should match a text string with two params sharing a prefix&quot; do
+        step = Step.new(&quot;I am cool $n times out of $n_total&quot;)
+        step.matches?(&quot;I am cool 3 times out of 7&quot;).should be_true
+      end
       
       it &quot;should match a text string with a param at the beginning&quot; do
         step = Step.new(&quot;$one 2 3&quot;) {}
@@ -128,7 +138,7 @@ module Spec
       end
       
       it &quot;should match a multiline regex&quot; do
-        step = Step.new(/.* should have text.$text/) {}
+        step = Step.new(/.*should have text.$text/) {}
         step.matches?(&lt;&lt;TEXT).should be_true
           should have text
           this is the text
@@ -153,6 +163,18 @@ TEXT
       end
     end
     
+    describe Step, &quot;#parse_args&quot; do
+      it &quot;should return an empty array for a text string with no parameters&quot; do
+        step = Step.new(&quot;this text&quot;) {}
+        step.parse_args(&quot;this text&quot;).should == []
+      end
+      
+      it &quot;should return an empty array for a text string with additional line returns and no parameters&quot; do
+        step = Step.new(&quot;this text&quot;) {}
+        step.parse_args(&quot;this text\n\n&quot;).should == []
+      end
+    end
+    
     describe Step do
       it &quot;should be pending with no block&quot; do
         step = Step.new(&quot;foo&quot;)</diff>
      <filename>vendor/plugins/rspec/spec/spec/story/step_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -20,9 +20,7 @@ module Spec
       
       it 'should not raise an error if no block is supplied' do
         # when
-        error = exception_from do
-          Story.new 'title', 'narrative'
-        end
+        error = exception_from { Story.new 'title', 'narrative' }
         
         # then
         error.should be_nil</diff>
      <filename>vendor/plugins/rspec/spec/spec/story/story_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -12,7 +12,11 @@ spec_classes_path = File.expand_path(&quot;#{dir}/../spec/spec/spec_classes&quot;)
 require spec_classes_path unless $LOAD_PATH.include?(spec_classes_path)
 require File.dirname(__FILE__) + '/../lib/spec/expectations/differs/default'
 
-module Spec
+module Spec  
+  module Example
+    class NonStandardError &lt; Exception; end
+  end
+
   module Matchers
     def fail
       raise_error(Spec::Expectations::ExpectationNotMetError)
@@ -22,82 +26,31 @@ module Spec
       raise_error(Spec::Expectations::ExpectationNotMetError, message)
     end
 
-    class Pass
-      def matches?(proc, &amp;block)
-        begin
-          proc.call
-          true
-        rescue Exception =&gt; @error
-          false
-        end
-      end
-
-      def failure_message
-        @error.message + &quot;\n&quot; + @error.backtrace.join(&quot;\n&quot;)
-      end
-    end
-
-    def pass
-      Pass.new
-    end
-    
-    class CorrectlyOrderedMockExpectation
-      def initialize(&amp;event)
-        @event = event
-      end
-      
-      def expect(&amp;expectations)
-        expectations.call
-        @event.call
+    def exception_from(&amp;block)
+      exception = nil
+      begin
+        yield
+      rescue StandardError =&gt; e
+        exception = e
       end
-    end
-    
-    def during(&amp;block)
-      CorrectlyOrderedMockExpectation.new(&amp;block) 
+      exception
     end
   end
 end
 
-class NonStandardError &lt; Exception; end
-
-module Custom
-  class ExampleGroupRunner
-    attr_reader :options, :arg
-    def initialize(options, arg)
-      @options, @arg = options, arg
-    end
-
-    def load_files(files)
-    end
-
-    def run
-    end
-  end  
-end
-
-def exception_from(&amp;block)
-  exception = nil
-  begin
-    yield
-  rescue StandardError =&gt; e
-    exception = e
-  end
-  exception
-end
-
-describe &quot;sandboxed rspec_options&quot;, :shared =&gt; true do
+share_as :SandboxedOptions do
   attr_reader :options
 
-  before(:all) do
-    @original_rspec_options = $rspec_options
+  before(:each) do
+    @original_rspec_options = ::Spec::Runner.options
+    ::Spec::Runner.use(@options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new))
   end
 
-  before(:each) do
-    @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new)
-    $rspec_options = options
+  after(:each) do
+    ::Spec::Runner.use(@original_rspec_options)
   end
 
-  after do
-    $rspec_options = @original_rspec_options
+  def run_with(options)
+    ::Spec::Runner::CommandLine.run(options)
   end
-end
\ No newline at end of file
+end unless Object.const_defined?(:SandboxedOptions)</diff>
      <filename>vendor/plugins/rspec/spec/spec_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,8 +13,6 @@ Story: before suite
 		
 	Scenario: running with spec
 
-		Given this scenario fails because before(:suite) doesn't get run with the spec command
-
 		Given the file ../resources/spec/before_blocks_example.rb
 
     When I run it with the spec script</diff>
      <filename>vendor/plugins/rspec/stories/configuration/before_blocks.story</filename>
    </modified>
    <modified>
      <diff>@@ -18,7 +18,8 @@ module RspecOnRailsOnCrack
         describe @controller, &quot;access for #{user.inspect}&quot;, :type =&gt; :controller do
           ControllerAccessGroup.new(self, blocks, filters).instance_eval(&amp;block)
           before do
-            controller.stub!(:current_user).and_return(user == :anon ? :false : users(user))
+            controller.stub!(:current_user).and_return(user == :anon ? nil : users(user))
+            controller.stub!(:logged_in?).and_return(user != :anon)
           end
         end
       end
@@ -420,7 +421,7 @@ module RspecOnRailsOnCrack
         acting do |response|
           asserts_status options[:status]
           asserts_content_type options[:format] || format
-          response.should have_text(instance_eval(&amp;block)) if block
+          response.should have_text(block.call) if block
         end
       end
     end</diff>
      <filename>vendor/plugins/rspec_on_rails_on_crack/lib/rspec_on_rails_on_crack/controller_example_group_methods.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,26 +1,62 @@
-require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
+require 'rubygems'
+begin
+  hanna_dir = '/Users/mislav/Projects/Hanna/lib'
+  $:.unshift hanna_dir if File.exists? hanna_dir
+  require 'hanna/rdoctask'
+rescue LoadError
+  require 'rake'
+  require 'rake/rdoctask'
+end
+load 'test/tasks.rake'
 
 desc 'Default: run unit tests.'
 task :default =&gt; :test
 
-desc 'Test the will_paginate plugin.'
-Rake::TestTask.new(:test) do |t|
-  t.pattern = 'test/**/*_test.rb'
-  t.verbose = true
-end
-
 desc 'Generate RDoc documentation for the will_paginate plugin.'
 Rake::RDocTask.new(:rdoc) do |rdoc|
-  files = ['README', 'LICENSE', 'lib/**/*.rb']
-  rdoc.rdoc_files.add(files)
-  rdoc.main = &quot;README&quot; # page to start on
-  rdoc.title = &quot;will_paginate&quot;
+  rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG.rdoc').
+    include('lib/**/*.rb').
+    exclude('lib/will_paginate/named_scope*').
+    exclude('lib/will_paginate/array.rb').
+    exclude('lib/will_paginate/version.rb')
   
-  templates = %w[/Users/chris/ruby/projects/err/rock/template.rb /var/www/rock/template.rb]
-  rdoc.template = templates.find { |t| File.exists? t }
+  rdoc.main = &quot;README.rdoc&quot; # page to start on
+  rdoc.title = &quot;will_paginate documentation&quot;
   
   rdoc.rdoc_dir = 'doc' # rdoc output folder
-  rdoc.options &lt;&lt; '--inline-source'
+  rdoc.options &lt;&lt; '--inline-source' &lt;&lt; '--charset=UTF-8'
+  rdoc.options &lt;&lt; '--webcvs=http://github.com/mislav/will_paginate/tree/master/'
+end
+
+desc %{Update &quot;.manifest&quot; with the latest list of project filenames. Respect\
+.gitignore by excluding everything that git ignores. Update `files` and\
+`test_files` arrays in &quot;*.gemspec&quot; file if it's present.}
+task :manifest do
+  list = Dir['**/*'].sort
+  spec_file = Dir['*.gemspec'].first
+  list -= [spec_file] if spec_file
+  
+  File.read('.gitignore').each_line do |glob|
+    glob = glob.chomp.sub(/^\//, '')
+    list -= Dir[glob]
+    list -= Dir[&quot;#{glob}/**/*&quot;] if File.directory?(glob) and !File.symlink?(glob)
+    puts &quot;excluding #{glob}&quot;
+  end
+
+  if spec_file
+    spec = File.read spec_file
+    spec.gsub! /^(\s* s.(test_)?files \s* = \s* )( \[ [^\]]* \] | %w\( [^)]* \) )/mx do
+      assignment = $1
+      bunch = $2 ? list.grep(/^test\//) : list
+      '%s%%w(%s)' % [assignment, bunch.join(' ')]
+    end
+      
+    File.open(spec_file,   'w') {|f| f &lt;&lt; spec }
+  end
+  File.open('.manifest', 'w') {|f| f &lt;&lt; list.join(&quot;\n&quot;) }
+end
+
+task :examples do
+  %x(haml examples/index.haml examples/index.html)
+  %x(sass examples/pagination.sass examples/pagination.css)
 end</diff>
      <filename>vendor/plugins/will_paginate/Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1 @@
-unless ActiveRecord::Base.respond_to? :paginate
-  require 'will_paginate'
-  WillPaginate.enable
-end
+require 'will_paginate'</diff>
      <filename>vendor/plugins/will_paginate/init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,44 +9,65 @@ require 'active_support'
 # Happy paginating!
 module WillPaginate
   class &lt;&lt; self
+    # shortcut for &lt;tt&gt;enable_actionpack&lt;/tt&gt; and &lt;tt&gt;enable_activerecord&lt;/tt&gt; combined
     def enable
       enable_actionpack
       enable_activerecord
     end
     
+    # hooks WillPaginate::ViewHelpers into ActionView::Base
     def enable_actionpack
       return if ActionView::Base.instance_methods.include? 'will_paginate'
       require 'will_paginate/view_helpers'
-      ActionView::Base.class_eval { include ViewHelpers }
+      ActionView::Base.send :include, ViewHelpers
+
+      if defined?(ActionController::Base) and ActionController::Base.respond_to? :rescue_responses
+        ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] = :not_found
+      end
     end
     
+    # hooks WillPaginate::Finder into ActiveRecord::Base and classes that deal
+    # with associations
     def enable_activerecord
       return if ActiveRecord::Base.respond_to? :paginate
       require 'will_paginate/finder'
-      ActiveRecord::Base.class_eval { include Finder }
-
-      associations = ActiveRecord::Associations
-      collection = associations::AssociationCollection
-      
-      # to support paginating finders on associations, we have to mix in the
-      # method_missing magic from WillPaginate::Finder::ClassMethods to AssociationProxy
-      # subclasses, but in a different way for Rails 1.2.x and 2.0
-      (collection.instance_methods.include?(:create!) ?
-        collection : collection.subclasses.map(&amp;:constantize)
-      ).push(associations::HasManyThroughAssociation).each do |klass|
-        klass.class_eval do
-          include Finder::ClassMethods
-          alias_method_chain :method_missing, :paginate
+      ActiveRecord::Base.send :include, Finder
+
+      # support pagination on associations
+      a = ActiveRecord::Associations
+      returning([ a::AssociationCollection ]) { |classes|
+        # detect http://dev.rubyonrails.org/changeset/9230
+        unless a::HasManyThroughAssociation.superclass == a::HasManyAssociation
+          classes &lt;&lt; a::HasManyThroughAssociation
         end
+      }.each do |klass|
+        klass.send :include, Finder::ClassMethods
+        klass.class_eval { alias_method_chain :method_missing, :paginate }
       end
     end
+
+    # Enable named_scope, a feature of Rails 2.1, even if you have older Rails
+    # (tested on Rails 2.0.2 and 1.2.6).
+    #
+    # You can pass +false+ for +patch+ parameter to skip monkeypatching
+    # *associations*. Use this if you feel that &lt;tt&gt;named_scope&lt;/tt&gt; broke
+    # has_many, has_many :through or has_and_belongs_to_many associations in
+    # your app. By passing +false+, you can still use &lt;tt&gt;named_scope&lt;/tt&gt; in
+    # your models, but not through associations.
+    def enable_named_scope(patch = true)
+      return if defined? ActiveRecord::NamedScope
+      require 'will_paginate/named_scope'
+      require 'will_paginate/named_scope_patch' if patch
+
+      ActiveRecord::Base.send :include, WillPaginate::NamedScope
+    end
   end
 
-  module Deprecation
+  module Deprecation # :nodoc:
     extend ActiveSupport::Deprecation
 
     def self.warn(message, callstack = caller)
-      message = 'WillPaginate: ' + message.strip.gsub(/ {3,}/, ' ')
+      message = 'WillPaginate: ' + message.strip.gsub(/\s+/, ' ')
       behavior.call(message, callstack) if behavior &amp;&amp; !silenced?
     end
 
@@ -55,3 +76,7 @@ module WillPaginate
     end
   end
 end
+
+if defined?(Rails) and defined?(ActiveRecord) and defined?(ActionController)
+  WillPaginate.enable
+end</diff>
      <filename>vendor/plugins/will_paginate/lib/will_paginate.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,23 +1,56 @@
 module WillPaginate
-  # Arrays returned from paginating finds are, in fact, instances of this.
-  # You may think of WillPaginate::Collection as an ordinary array with some
-  # extra properties. Those properties are used by view helpers to generate
+  # = Invalid page number error
+  # This is an ArgumentError raised in case a page was requested that is either
+  # zero or negative number. You should decide how do deal with such errors in
+  # the controller.
+  #
+  # If you're using Rails 2, then this error will automatically get handled like
+  # 404 Not Found. The hook is in &quot;will_paginate.rb&quot;:
+  #
+  #   ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] = :not_found
+  #
+  # If you don't like this, use your preffered method of rescuing exceptions in
+  # public from your controllers to handle this differently. The +rescue_from+
+  # method is a nice addition to Rails 2.
+  #
+  # This error is *not* raised when a page further than the last page is
+  # requested. Use &lt;tt&gt;WillPaginate::Collection#out_of_bounds?&lt;/tt&gt; method to
+  # check for those cases and manually deal with them as you see fit.
+  class InvalidPage &lt; ArgumentError
+    def initialize(page, page_num)
+      super &quot;#{page.inspect} given as value, which translates to '#{page_num}' as page number&quot;
+    end
+  end
+  
+  # = The key to pagination
+  # Arrays returned from paginating finds are, in fact, instances of this little
+  # class. You may think of WillPaginate::Collection as an ordinary array with
+  # some extra properties. Those properties are used by view helpers to generate
   # correct page links.
   #
   # WillPaginate::Collection also assists in rolling out your own pagination
   # solutions: see +create+.
+  # 
+  # If you are writing a library that provides a collection which you would like
+  # to conform to this API, you don't have to copy these methods over; simply
+  # make your plugin/gem dependant on the &quot;mislav-will_paginate&quot; gem:
   #
+  #   gem 'mislav-will_paginate'
+  #   require 'will_paginate/collection'
+  #   
+  #   # WillPaginate::Collection is now available for use
   class Collection &lt; Array
-    attr_reader :current_page, :per_page, :total_entries
+    attr_reader :current_page, :per_page, :total_entries, :total_pages
 
-    # Arguments to this constructor are the current page number, per-page limit
+    # Arguments to the constructor are the current page number, per-page limit
     # and the total number of entries. The last argument is optional because it
     # is best to do lazy counting; in other words, count *conditionally* after
     # populating the collection using the +replace+ method.
-    #
     def initialize(page, per_page, total = nil)
       @current_page = page.to_i
-      @per_page     = per_page.to_i
+      raise InvalidPage.new(page, @current_page) if @current_page &lt; 1
+      @per_page = per_page.to_i
+      raise ArgumentError, &quot;`per_page` setting cannot be less than 1 (#{@per_page} given)&quot; if @per_page &lt; 1
       
       self.total_entries = total if total
     end
@@ -37,7 +70,7 @@ module WillPaginate
     #   end
     #
     # The possibilities with this are endless. For another example, here is how
-    # WillPaginate defines pagination on Array instances:
+    # WillPaginate used to define pagination for Array instances:
     #
     #   Array.class_eval do
     #     def paginate(page = 1, per_page = 15)
@@ -47,28 +80,25 @@ module WillPaginate
     #     end
     #   end
     #
+    # The Array#paginate API has since then changed, but this still serves as a
+    # fine example of WillPaginate::Collection usage.
     def self.create(page, per_page, total = nil, &amp;block)
       pager = new(page, per_page, total)
       yield pager
       pager
     end
 
-    # The total number of pages.
-    def page_count
-      @total_pages
-    end
-
-    # Helper method that is true when someone tries to fetch a page with a larger
-    # number than the last page or with a number smaller than 1
+    # Helper method that is true when someone tries to fetch a page with a
+    # larger number than the last page. Can be used in combination with flashes
+    # and redirecting.
     def out_of_bounds?
-      current_page &gt; page_count or current_page &lt; 1
+      current_page &gt; total_pages
     end
 
     # Current offset of the paginated collection. If we're on the first page,
     # it is always 0. If we're on the 2nd page and there are 30 entries per page,
     # the offset is 30. This property is useful if you want to render ordinals
-    # besides your records: simply start with offset + 1.
-    #
+    # side by side with records in the view: simply start with offset + 1.
     def offset
       (current_page - 1) * per_page
     end
@@ -80,9 +110,10 @@ module WillPaginate
 
     # current_page + 1 or nil if there is no next page
     def next_page
-      current_page &lt; page_count ? (current_page + 1) : nil
+      current_page &lt; total_pages ? (current_page + 1) : nil
     end
-
+    
+    # sets the &lt;tt&gt;total_entries&lt;/tt&gt; property and calculates &lt;tt&gt;total_pages&lt;/tt&gt;
     def total_entries=(number)
       @total_entries = number.to_i
       @total_pages   = (@total_entries / per_page.to_f).ceil
@@ -101,13 +132,15 @@ module WillPaginate
     # +total_entries+ and set it to a proper value if it's +nil+. See the example
     # in +create+.
     def replace(array)
-      returning super do
-        # The collection is shorter then page limit? Rejoice, because
-        # then we know that we are on the last page!
-        if total_entries.nil? and length &gt; 0 and length &lt; per_page
-          self.total_entries = offset + length
-        end
+      result = super
+      
+      # The collection is shorter then page limit? Rejoice, because
+      # then we know that we are on the last page!
+      if total_entries.nil? and length &lt; per_page and (current_page == 1 or length &gt; 0)
+        self.total_entries = offset + length
       end
+
+      result
     end
   end
 end</diff>
      <filename>vendor/plugins/will_paginate/lib/will_paginate/collection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 require 'set'
+require 'will_paginate/array'
 
 unless Hash.instance_methods.include? 'except'
   Hash.class_eval do
@@ -29,33 +30,3 @@ unless Hash.instance_methods.include? 'slice'
     end
   end
 end
-
-require 'will_paginate/collection'
-
-unless Array.instance_methods.include? 'paginate'
-  # http://www.desimcadam.com/archives/8
-  Array.class_eval do
-    def paginate(options_or_page = {}, per_page = nil)
-      if options_or_page.nil? or Fixnum === options_or_page
-        if defined? WillPaginate::Deprecation
-          WillPaginate::Deprecation.warn &lt;&lt;-DEPR
-            Array#paginate now conforms to the main, ActiveRecord::Base#paginate API.  You should \
-            call it with a parameters hash (:page, :per_page).  The old API (numbers as arguments) \
-            has been deprecated and is going to be unsupported in future versions of will_paginate.
-          DEPR
-        end
-        page = options_or_page
-        options = {}
-      else
-        options = options_or_page
-        page = options[:page] || 1
-        raise ArgumentError, &quot;wrong number of arguments (1 hash or 2 Fixnums expected)&quot; if per_page
-        per_page = options[:per_page]
-      end
-
-      WillPaginate::Collection.create(page || 1, per_page || 30, options[:total_entries] || size) do |pager|
-        pager.replace self[pager.offset, pager.per_page].to_a
-      end
-    end
-  end
-end</diff>
      <filename>vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@ require 'will_paginate/core_ext'
 
 module WillPaginate
   # A mixin for ActiveRecord::Base. Provides +per_page+ class method
-  # and makes +paginate+ finders possible with some method_missing magic.
+  # and hooks things up to provide paginating finders.
   #
   # Find out more in WillPaginate::Finder::ClassMethods
   #
@@ -11,66 +11,143 @@ module WillPaginate
       base.extend ClassMethods
       class &lt;&lt; base
         alias_method_chain :method_missing, :paginate
+        # alias_method_chain :find_every,     :paginate
         define_method(:per_page) { 30 } unless respond_to?(:per_page)
       end
     end
 
     # = Paginating finders for ActiveRecord models
     # 
-    # WillPaginate doesn't really add extra methods to your ActiveRecord models (except +per_page+
-    # unless it's already available). It simply intercepts
-    # the calls to paginating finders such as +paginate+, +paginate_by_user_id+ (and so on) and
-    # translates them to ordinary finders: +find+, +find_by_user_id+, etc. It does so with some
-    # method_missing magic, but you don't need to care for that. You simply use paginating finders
-    # same way you used ordinary ones. You only need to tell them what page you want in options.
+    # WillPaginate adds +paginate+, +per_page+ and other methods to
+    # ActiveRecord::Base class methods and associations. It also hooks into
+    # +method_missing+ to intercept pagination calls to dynamic finders such as
+    # +paginate_by_user_id+ and translate them to ordinary finders
+    # (+find_all_by_user_id+ in this case).
+    # 
+    # In short, paginating finders are equivalent to ActiveRecord finders; the
+    # only difference is that we start with &quot;paginate&quot; instead of &quot;find&quot; and
+    # that &lt;tt&gt;:page&lt;/tt&gt; is required parameter:
     #
-    #   @topics = Topic.paginate :all, :page =&gt; params[:page]
+    #   @posts = Post.paginate :all, :page =&gt; params[:page], :order =&gt; 'created_at DESC'
     # 
-    # In paginating finders, &quot;all&quot; is implicit. No sense in paginating a single record, right? So:
+    # In paginating finders, &quot;all&quot; is implicit. There is no sense in paginating
+    # a single record, right? So, you can drop the &lt;tt&gt;:all&lt;/tt&gt; argument:
     # 
-    #   Post.paginate                  =&gt; Post.find :all
-    #   Post.paginate_all_by_something =&gt; Post.find_all_by_something
-    #   Post.paginate_by_something     =&gt; Post.find_all_by_something
-    #
-    # Knowing that, the above example can be written simply as:
+    #   Post.paginate(...)              =&gt;  Post.find :all
+    #   Post.paginate_all_by_something  =&gt;  Post.find_all_by_something
+    #   Post.paginate_by_something      =&gt;  Post.find_all_by_something
     #
-    #   @topics = Topic.paginate :page =&gt; params[:page]
+    # == The importance of the &lt;tt&gt;:order&lt;/tt&gt; parameter
     #
-    # Don't forget to pass the +page+ parameter! Without it, paginating finders will raise an error.
+    # In ActiveRecord finders, &lt;tt&gt;:order&lt;/tt&gt; parameter specifies columns for
+    # the &lt;tt&gt;ORDER BY&lt;/tt&gt; clause in SQL. It is important to have it, since
+    # pagination only makes sense with ordered sets. Without the &lt;tt&gt;ORDER
+    # BY&lt;/tt&gt; clause, databases aren't required to do consistent ordering when
+    # performing &lt;tt&gt;SELECT&lt;/tt&gt; queries; this is especially true for
+    # PostgreSQL.
     #
-    # == Options
-    # Options for paginating finders are:
-    # 
-    #   page           REQUIRED, but defaults to 1 if false or nil
-    #   per_page       (default is read from the model, which is 30 if not overridden)
-    #   total entries  not needed unless you want to count the records yourself somehow
-    #   count          hash of options that are used only for the call to count
-    # 
+    # Therefore, make sure you are doing ordering on a column that makes the
+    # most sense in the current context. Make that obvious to the user, also.
+    # For perfomance reasons you will also want to add an index to that column.
     module ClassMethods
-      # This methods wraps +find_by_sql+ by simply adding LIMIT and OFFSET to your SQL string
-      # based on the params otherwise used by paginating finds: +page+ and +per_page+.
+      # This is the main paginating finder.
+      #
+      # == Special parameters for paginating finders
+      # * &lt;tt&gt;:page&lt;/tt&gt; -- REQUIRED, but defaults to 1 if false or nil
+      # * &lt;tt&gt;:per_page&lt;/tt&gt; -- defaults to &lt;tt&gt;CurrentModel.per_page&lt;/tt&gt; (which is 30 if not overridden)
+      # * &lt;tt&gt;:total_entries&lt;/tt&gt; -- use only if you manually count total entries
+      # * &lt;tt&gt;:count&lt;/tt&gt; -- additional options that are passed on to +count+
+      # * &lt;tt&gt;:finder&lt;/tt&gt; -- name of the ActiveRecord finder used (default: &quot;find&quot;)
+      #
+      # All other options (+conditions+, +order+, ...) are forwarded to +find+
+      # and +count+ calls.
+      def paginate(*args, &amp;block)
+        options = args.pop
+        page, per_page, total_entries = wp_parse_options(options)
+        finder = (options[:finder] || 'find').to_s
+
+        if finder == 'find'
+          # an array of IDs may have been given:
+          total_entries ||= (Array === args.first and args.first.size)
+          # :all is implicit
+          args.unshift(:all) if args.empty?
+        end
+
+        WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
+          count_options = options.except :page, :per_page, :total_entries, :finder
+          find_options = count_options.except(:count).update(:offset =&gt; pager.offset, :limit =&gt; pager.per_page) 
+          
+          args &lt;&lt; find_options
+          # @options_from_last_find = nil
+          pager.replace send(finder, *args, &amp;block)
+          
+          # magic counting for user convenience:
+          pager.total_entries = wp_count(count_options, args, finder) unless pager.total_entries
+        end
+      end
+
+      # Iterates through all records by loading one page at a time. This is useful
+      # for migrations or any other use case where you don't want to load all the
+      # records in memory at once.
+      #
+      # It uses +paginate+ internally; therefore it accepts all of its options.
+      # You can specify a starting page with &lt;tt&gt;:page&lt;/tt&gt; (default is 1). Default
+      # &lt;tt&gt;:order&lt;/tt&gt; is &lt;tt&gt;&quot;id&quot;&lt;/tt&gt;, override if necessary.
+      #
+      # See {Faking Cursors in ActiveRecord}[http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord]
+      # where Jamis Buck describes this and a more efficient way for MySQL.
+      def paginated_each(options = {}, &amp;block)
+        options = { :order =&gt; 'id', :page =&gt; 1 }.merge options
+        options[:page] = options[:page].to_i
+        options[:total_entries] = 0 # skip the individual count queries
+        total = 0
+        
+        begin 
+          collection = paginate(options)
+          total += collection.each(&amp;block).size
+          options[:page] += 1
+        end until collection.size &lt; collection.per_page
+        
+        total
+      end
+      
+      # Wraps +find_by_sql+ by simply adding LIMIT and OFFSET to your SQL string
+      # based on the params otherwise used by paginating finds: +page+ and
+      # +per_page+.
       #
       # Example:
       # 
       #   @developers = Developer.paginate_by_sql ['select * from developers where salary &gt; ?', 80000],
-      #                           :page =&gt; params[:page], :per_page =&gt; 3
+      #                          :page =&gt; params[:page], :per_page =&gt; 3
+      #
+      # A query for counting rows will automatically be generated if you don't
+      # supply &lt;tt&gt;:total_entries&lt;/tt&gt;. If you experience problems with this
+      # generated SQL, you might want to perform the count manually in your
+      # application.
       # 
       def paginate_by_sql(sql, options)
-        options, page, per_page = wp_parse_options!(options)
-
-        WillPaginate::Collection.create(page, per_page) do |pager|
-          query = sanitize_sql(sql)
-          count_query = &quot;SELECT COUNT(*) FROM (#{query}) AS count_table&quot; unless options[:total_entries]
-          options.update :offset =&gt; pager.offset, :limit =&gt; pager.per_page
-          
-          add_limit! query, options
+        WillPaginate::Collection.create(*wp_parse_options(options)) do |pager|
+          query = sanitize_sql(sql.dup)
+          original_query = query.dup
+          # add limit, offset
+          add_limit! query, :offset =&gt; pager.offset, :limit =&gt; pager.per_page
+          # perfom the find
           pager.replace find_by_sql(query)
           
-          pager.total_entries = options[:total_entries] || count_by_sql(count_query) unless pager.total_entries
+          unless pager.total_entries
+            count_query = original_query.sub /\bORDER\s+BY\s+[\w`,\s]+$/mi, ''
+            count_query = &quot;SELECT COUNT(*) FROM (#{count_query})&quot;
+            
+            unless ['oracle', 'oci'].include?(self.connection.adapter_name.downcase)
+              count_query &lt;&lt; ' AS count_table'
+            end
+            # perform the count query
+            pager.total_entries = count_by_sql(count_query)
+          end
         end
       end
 
-      def respond_to?(method, include_priv = false)
+      def respond_to?(method, include_priv = false) #:nodoc:
         case method.to_sym
         when :paginate, :paginate_by_sql
           true
@@ -81,59 +158,70 @@ module WillPaginate
 
     protected
       
-      def method_missing_with_paginate(method, *args, &amp;block)
+      def method_missing_with_paginate(method, *args, &amp;block) #:nodoc:
         # did somebody tried to paginate? if not, let them be
         unless method.to_s.index('paginate') == 0
           return method_missing_without_paginate(method, *args, &amp;block) 
         end
-
-        options, page, per_page, total_entries = wp_parse_options!(args.pop)
-        # an array of IDs may have been given:
-        total_entries ||= (Array === args.first and args.first.size)
         
         # paginate finders are really just find_* with limit and offset
-        finder = method.to_s.sub /^paginate/, 'find'
+        finder = method.to_s.sub('paginate', 'find')
+        finder.sub!('find', 'find_all') if finder.index('find_by_') == 0
+        
+        options = args.pop
+        raise ArgumentError, 'parameter hash expected' unless options.respond_to? :symbolize_keys
+        options = options.dup
+        options[:finder] = finder
+        args &lt;&lt; options
+        
+        paginate(*args, &amp;block)
+      end
 
-        # :all is implicit
-        if finder == 'find'
-          args.unshift(:all) if args.empty?
-        elsif finder.index('find_by_') == 0
-          finder.sub! /^find/, 'find_all'
-        end
+      # Does the not-so-trivial job of finding out the total number of entries
+      # in the database. It relies on the ActiveRecord +count+ method.
+      def wp_count(options, args, finder)
+        excludees = [:count, :order, :limit, :offset, :readonly]
 
-        WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
-          args &lt;&lt; options.except(:count).merge(:offset =&gt; pager.offset, :limit =&gt; pager.per_page)
-          pager.replace send(finder, *args)
-          
-          # magic counting for user convenience:
-          pager.total_entries = wp_count!(options, args, finder) unless pager.total_entries
-        end
-      end
+        # we may be in a model or an association proxy
+        klass = (@owner and @reflection) ? @reflection.klass : self
+
+        # Use :select from scope if it isn't already present.
+        options[:select] = scope(:find, :select) unless options[:select]
 
-      def wp_count!(options, args, finder)
-        excludees = [:count, :order, :limit, :offset]
-        unless options[:select] and options[:select] =~ /^\s*DISTINCT/i
+        if options[:select] and options[:select] =~ /^\s*DISTINCT\b/i
+          # Remove quoting and check for table_name.*-like statement.
+          if options[:select].gsub('`', '') =~ /\w+\.\*/
+            options[:select] = &quot;DISTINCT #{klass.table_name}.#{klass.primary_key}&quot;
+          end
+        else
           excludees &lt;&lt; :select # only exclude the select param if it doesn't begin with DISTINCT
         end
+
         # count expects (almost) the same options as find
         count_options = options.except *excludees
 
         # merge the hash found in :count
         # this allows you to specify :select, :order, or anything else just for the count query
-        count_options.update(options.delete(:count) || {}) if options.key? :count
+        count_options.update options[:count] if options[:count]
+
+        # forget about includes if they are irrelevant (Rails 2.1)
+        if count_options[:include] and
+            klass.private_methods.include?('references_eager_loaded_tables?') and
+            !klass.send(:references_eager_loaded_tables?, count_options)
+          count_options.delete :include
+        end
 
         # we may have to scope ...
         counter = Proc.new { count(count_options) }
 
-        # we may be in a model or an association proxy!
-        klass = (@owner and @reflection) ? @reflection.klass : self
-
-        count = if finder =~ /^find_/ and klass.respond_to?(scoper = finder.sub(/^find_/, 'with_'))
+        count = if finder.index('find_') == 0 and klass.respond_to?(scoper = finder.sub('find', 'with'))
                   # scope_out adds a 'with_finder' method which acts like with_scope, if it's present
-                  # then execute the count with the scoping provided by the with_finder  
+                  # then execute the count with the scoping provided by the with_finder
                   send(scoper, &amp;counter)
-                elsif conditions = wp_extract_finder_conditions(finder, args)
-                  # extracted the conditions from calls like &quot;paginate_by_foo_and_bar&quot;
+                elsif match = /^find_(all_by|by)_([_a-zA-Z]\w*)$/.match(finder)
+                  # extract conditions from calls like &quot;paginate_by_foo_and_bar&quot;
+                  attribute_names = extract_attribute_names_from_match(match)
+                  conditions = construct_attributes_from_arguments(attribute_names, args)
                   with_scope(:find =&gt; { :conditions =&gt; conditions }, &amp;counter)
                 else
                   counter.call
@@ -142,33 +230,27 @@ module WillPaginate
         count.respond_to?(:length) ? count.length : count
       end
 
-      def wp_parse_options!(options)
-        raise ArgumentError, 'hash parameters expected' unless options.respond_to? :symbolize_keys!
-        options.symbolize_keys!
+      def wp_parse_options(options) #:nodoc:
+        raise ArgumentError, 'parameter hash expected' unless options.respond_to? :symbolize_keys
+        options = options.symbolize_keys
         raise ArgumentError, ':page parameter required' unless options.key? :page
         
         if options[:count] and options[:total_entries]
-          raise ArgumentError, ':count and :total_entries are mutually exclusive parameters'
+          raise ArgumentError, ':count and :total_entries are mutually exclusive'
         end
 
-        page     = options.delete(:page) || 1
-        per_page = options.delete(:per_page) || self.per_page
-        total    = options.delete(:total_entries)
-        [options, page, per_page, total]
+        page     = options[:page] || 1
+        per_page = options[:per_page] || self.per_page
+        total    = options[:total_entries]
+        [page, per_page, total]
       end
 
     private
 
-      # thanks to active record for making us duplicate this code
-      def wp_extract_finder_conditions(finder, arguments)
-        return unless match = /^find_(all_by|by)_([_a-zA-Z]\w*)$/.match(finder.to_s)
-
-        attribute_names = extract_attribute_names_from_match(match)
-        unless all_attributes_exists?(attribute_names)
-          raise &quot;I can't make sense of `#{finder}`. Try doing the count manually&quot;
-        end
-        construct_attributes_from_arguments(attribute_names, arguments)
-      end
+      # def find_every_with_paginate(options)
+      #   @options_from_last_find = options
+      #   find_every_without_paginate(options)
+      # end
     end
   end
 end</diff>
      <filename>vendor/plugins/will_paginate/lib/will_paginate/finder.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,136 +1,383 @@
 require 'will_paginate/core_ext'
 
 module WillPaginate
-  # = Global options for pagination helpers
+  # = Will Paginate view helpers
+  #
+  # The main view helper, #will_paginate, renders
+  # pagination links for the given collection. The helper itself is lightweight
+  # and serves only as a wrapper around LinkRenderer instantiation; the
+  # renderer then does all the hard work of generating the HTML.
+  # 
+  # == Global options for helpers
   #
   # Options for pagination helpers are optional and get their default values from the
-  # WillPaginate::ViewHelpers.pagination_options hash. You can write to this hash to
+  # &lt;tt&gt;WillPaginate::ViewHelpers.pagination_options&lt;/tt&gt; hash. You can write to this hash to
   # override default options on the global level:
   #
-  #   WillPaginate::ViewHelpers.pagination_options[:prev_label] = 'Previous page'
+  #   WillPaginate::ViewHelpers.pagination_options[:previous_label] = 'Previous page'
   #
-  # By putting this into your environment.rb you can easily translate link texts to previous
+  # By putting this into &quot;config/initializers/will_paginate.rb&quot; (or simply environment.rb in
+  # older versions of Rails) you can easily translate link texts to previous
   # and next pages, as well as override some other defaults to your liking.
   module ViewHelpers
     # default options that can be overridden on the global level
-    @@pagination_options = { :class =&gt; 'pagination',
-          :prev_label   =&gt; '&amp;laquo; Previous',
-          :next_label   =&gt; 'Next &amp;raquo;',
-          :inner_window =&gt; 4, # links around the current page
-          :outer_window =&gt; 1, # links around beginning and end
-          :separator    =&gt; ' ', # single space is friendly to spiders and non-graphic browsers
-          :param_name   =&gt; :page
-          }
+    @@pagination_options = {
+      :class          =&gt; 'pagination',
+      :previous_label =&gt; '&amp;laquo; Previous',
+      :next_label     =&gt; 'Next &amp;raquo;',
+      :inner_window   =&gt; 4, # links around the current page
+      :outer_window   =&gt; 1, # links around beginning and end
+      :separator      =&gt; ' ', # single space is friendly to spiders and non-graphic browsers
+      :param_name     =&gt; :page,
+      :params         =&gt; nil,
+      :renderer       =&gt; 'WillPaginate::LinkRenderer',
+      :page_links     =&gt; true,
+      :container      =&gt; true
+    }
     mattr_reader :pagination_options
 
-    # Renders Digg-style pagination. (We know you wanna!)
-    # Returns nil if there is only one page in total (can't paginate that).
+    # Renders Digg/Flickr-style pagination for a WillPaginate::Collection
+    # object. Nil is returned if there is only one page in total; no point in
+    # rendering the pagination in that case...
     # 
-    # Options for will_paginate view helper:
+    # ==== Options
+    # Display options:
+    # * &lt;tt&gt;:previous_label&lt;/tt&gt; -- default: &quot;&#171; Previous&quot; (this parameter is called &lt;tt&gt;:prev_label&lt;/tt&gt; in versions &lt;b&gt;2.3.2&lt;/b&gt; and older!)
+    # * &lt;tt&gt;:next_label&lt;/tt&gt; -- default: &quot;Next &#187;&quot;
+    # * &lt;tt&gt;:page_links&lt;/tt&gt; -- when false, only previous/next links are rendered (default: true)
+    # * &lt;tt&gt;:inner_window&lt;/tt&gt; -- how many links are shown around the current page (default: 4)
+    # * &lt;tt&gt;:outer_window&lt;/tt&gt; -- how many links are around the first and the last page (default: 1)
+    # * &lt;tt&gt;:separator&lt;/tt&gt; -- string separator for page HTML elements (default: single space)
     # 
-    #   class:        CSS class name for the generated DIV (default &quot;pagination&quot;)
-    #   prev_label:   default '&amp;laquo; Previous',
-    #   next_label:   default 'Next &amp;raquo;',
-    #   inner_window: how many links are shown around the current page, defaults to 4
-    #   outer_window: how many links are around the first and the last page, defaults to 1
-    #   separator:    string separator for page HTML elements, default &quot; &quot; (single space)
-    #   param_name:   parameter name for page number in URLs, defaults to &quot;page&quot;
-    #
-    # All extra options are passed to the generated container DIV, so eventually
-    # they become its HTML attributes.
-    #
-    def will_paginate(entries = @entries, options = {})
-      total_pages = 
-
-      if entries.page_count &gt; 1
-        renderer = WillPaginate::LinkRenderer.new entries, options, self
-        links = renderer.items
-        
-        content_tag :div, links, renderer.html_options
+    # HTML options:
+    # * &lt;tt&gt;:class&lt;/tt&gt; -- CSS class name for the generated DIV (default: &quot;pagination&quot;)
+    # * &lt;tt&gt;:container&lt;/tt&gt; -- toggles rendering of the DIV container for pagination links, set to
+    #   false only when you are rendering your own pagination markup (default: true)
+    # * &lt;tt&gt;:id&lt;/tt&gt; -- HTML ID for the container (default: nil). Pass +true+ to have the ID
+    #   automatically generated from the class name of objects in collection: for example, paginating
+    #   ArticleComment models would yield an ID of &quot;article_comments_pagination&quot;.
+    #
+    # Advanced options:
+    # * &lt;tt&gt;:param_name&lt;/tt&gt; -- parameter name for page number in URLs (default: &lt;tt&gt;:page&lt;/tt&gt;)
+    # * &lt;tt&gt;:params&lt;/tt&gt; -- additional parameters when generating pagination links
+    #   (eg. &lt;tt&gt;:controller =&gt; &quot;foo&quot;, :action =&gt; nil&lt;/tt&gt;)
+    # * &lt;tt&gt;:renderer&lt;/tt&gt; -- class name, class or instance of a link renderer (default:
+    #   &lt;tt&gt;WillPaginate::LinkRenderer&lt;/tt&gt;)
+    #
+    # All options not recognized by will_paginate will become HTML attributes on the container
+    # element for pagination links (the DIV). For example:
+    # 
+    #   &lt;%= will_paginate @posts, :style =&gt; 'font-size: small' %&gt;
+    #
+    # ... will result in:
+    #
+    #   &lt;div class=&quot;pagination&quot; style=&quot;font-size: small&quot;&gt; ... &lt;/div&gt;
+    #
+    # ==== Using the helper without arguments
+    # If the helper is called without passing in the collection object, it will
+    # try to read from the instance variable inferred by the controller name.
+    # For example, calling +will_paginate+ while the current controller is
+    # PostsController will result in trying to read from the &lt;tt&gt;@posts&lt;/tt&gt;
+    # variable. Example:
+    #
+    #   &lt;%= will_paginate :id =&gt; true %&gt;
+    #
+    # ... will result in &lt;tt&gt;@post&lt;/tt&gt; collection getting paginated:
+    #
+    #   &lt;div class=&quot;pagination&quot; id=&quot;posts_pagination&quot;&gt; ... &lt;/div&gt;
+    #
+    def will_paginate(collection = nil, options = {})
+      options, collection = collection, nil if collection.is_a? Hash
+      unless collection or !controller
+        collection_name = &quot;@#{controller.controller_name}&quot;
+        collection = instance_variable_get(collection_name)
+        raise ArgumentError, &quot;The #{collection_name} variable appears to be empty. Did you &quot; +
+          &quot;forget to pass the collection object for will_paginate?&quot; unless collection
+      end
+      # early exit if there is nothing to render
+      return nil unless WillPaginate::ViewHelpers.total_pages_for_collection(collection) &gt; 1
+      
+      options = options.symbolize_keys.reverse_merge WillPaginate::ViewHelpers.pagination_options
+      if options[:prev_label]
+        WillPaginate::Deprecation::warn(&quot;:prev_label view parameter is now :previous_label; the old name has been deprecated.&quot;)
+        options[:previous_label] = options.delete(:prev_label)
+      end
+      
+      # get the renderer instance
+      renderer = case options[:renderer]
+      when String
+        options[:renderer].to_s.constantize.new
+      when Class
+        options[:renderer].new
+      else
+        options[:renderer]
+      end
+      # render HTML for pagination
+      renderer.prepare collection, options, self
+      renderer.to_html
+    end
+    
+    # Wrapper for rendering pagination links at both top and bottom of a block
+    # of content.
+    # 
+    #   &lt;% paginated_section @posts do %&gt;
+    #     &lt;ol id=&quot;posts&quot;&gt;
+    #       &lt;% for post in @posts %&gt;
+    #         &lt;li&gt; ... &lt;/li&gt;
+    #       &lt;% end %&gt;
+    #     &lt;/ol&gt;
+    #   &lt;% end %&gt;
+    #
+    # will result in:
+    #
+    #   &lt;div class=&quot;pagination&quot;&gt; ... &lt;/div&gt;
+    #   &lt;ol id=&quot;posts&quot;&gt;
+    #     ...
+    #   &lt;/ol&gt;
+    #   &lt;div class=&quot;pagination&quot;&gt; ... &lt;/div&gt;
+    #
+    # Arguments are passed to a &lt;tt&gt;will_paginate&lt;/tt&gt; call, so the same options
+    # apply. Don't use the &lt;tt&gt;:id&lt;/tt&gt; option; otherwise you'll finish with two
+    # blocks of pagination links sharing the same ID (which is invalid HTML).
+    def paginated_section(*args, &amp;block)
+      pagination = will_paginate(*args).to_s
+      content = pagination + capture(&amp;block) + pagination
+      concat content, block.binding
+    end
+
+    # Renders a helpful message with numbers of displayed vs. total entries.
+    # You can use this as a blueprint for your own, similar helpers.
+    #
+    #   &lt;%= page_entries_info @posts %&gt;
+    #   #-&gt; Displaying posts 6 - 10 of 26 in total
+    #
+    # By default, the message will use the humanized class name of objects
+    # in collection: for instance, &quot;project types&quot; for ProjectType models.
+    # Override this with the &lt;tt&gt;:entry_name&lt;/tt&gt; parameter:
+    #
+    #   &lt;%= page_entries_info @posts, :entry_name =&gt; 'item' %&gt;
+    #   #-&gt; Displaying items 6 - 10 of 26 in total
+    def page_entries_info(collection, options = {})
+      entry_name = options[:entry_name] ||
+        (collection.empty?? 'entry' : collection.first.class.name.underscore.sub('_', ' '))
+      
+      if collection.total_pages &lt; 2
+        case collection.size
+        when 0; &quot;No #{entry_name.pluralize} found&quot;
+        when 1; &quot;Displaying &lt;b&gt;1&lt;/b&gt; #{entry_name}&quot;
+        else;   &quot;Displaying &lt;b&gt;all #{collection.size}&lt;/b&gt; #{entry_name.pluralize}&quot;
+        end
+      else
+        %{Displaying #{entry_name.pluralize} &lt;b&gt;%d&amp;nbsp;-&amp;nbsp;%d&lt;/b&gt; of &lt;b&gt;%d&lt;/b&gt; in total} % [
+          collection.offset + 1,
+          collection.offset + collection.length,
+          collection.total_entries
+        ]
       end
     end
+
+    def self.total_pages_for_collection(collection) #:nodoc:
+      if collection.respond_to?('page_count') and !collection.respond_to?('total_pages')
+        WillPaginate::Deprecation.warn &lt;&lt;-MSG
+          You are using a paginated collection of class #{collection.class.name}
+          which conforms to the old API of WillPaginate::Collection by using
+          `page_count`, while the current method name is `total_pages`. Please
+          upgrade yours or 3rd-party code that provides the paginated collection.
+        MSG
+        class &lt;&lt; collection
+          def total_pages; page_count; end
+        end
+      end
+      collection.total_pages
+    end
   end
 
   # This class does the heavy lifting of actually building the pagination
-  # links. It is used by +will_paginate+ helper internally, but avoid using it
-  # directly (for now) because its API is not set in stone yet.
+  # links. It is used by the &lt;tt&gt;will_paginate&lt;/tt&gt; helper internally.
   class LinkRenderer
 
-    def initialize(collection, options, template)
+    # The gap in page links is represented by:
+    #
+    #   &lt;span class=&quot;gap&quot;&gt;&amp;hellip;&lt;/span&gt;
+    attr_accessor :gap_marker
+    
+    def initialize
+      @gap_marker = '&lt;span class=&quot;gap&quot;&gt;&amp;hellip;&lt;/span&gt;'
+    end
+    
+    # * +collection+ is a WillPaginate::Collection instance or any other object
+    #   that conforms to that API
+    # * +options+ are forwarded from +will_paginate+ view helper
+    # * +template+ is the reference to the template being rendered
+    def prepare(collection, options, template)
       @collection = collection
-      @options = options.symbolize_keys.reverse_merge WillPaginate::ViewHelpers.pagination_options
-      @template = template
+      @options    = options
+      @template   = template
+
+      # reset values in case we're re-using this instance
+      @total_pages = @param_name = @url_string = nil
     end
 
-    def items
-      returning windowed_paginator do |links|
-        # next and previous buttons
-        links.unshift page_link_or_span(@collection.previous_page, 'disabled', @options[:prev_label])
-        links.push    page_link_or_span(@collection.next_page,     'disabled', @options[:next_label])
-      end.join(@options[:separator])
+    # Process it! This method returns the complete HTML string which contains
+    # pagination links. Feel free to subclass LinkRenderer and change this
+    # method as you see fit.
+    def to_html
+      links = @options[:page_links] ? windowed_links : []
+      # previous/next buttons
+      links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:previous_label])
+      links.push    page_link_or_span(@collection.next_page,     'disabled next_page', @options[:next_label])
+      
+      html = links.join(@options[:separator])
+      @options[:container] ? @template.content_tag(:div, html, html_attributes) : html
     end
 
-    def html_options
-      @options.except *(WillPaginate::ViewHelpers.pagination_options.keys - [:class])
+    # Returns the subset of +options+ this instance was initialized with that
+    # represent HTML attributes for the container element of pagination links.
+    def html_attributes
+      return @html_attributes if @html_attributes
+      @html_attributes = @options.except *(WillPaginate::ViewHelpers.pagination_options.keys - [:class])
+      # pagination of Post models will have the ID of &quot;posts_pagination&quot;
+      if @options[:container] and @options[:id] === true
+        @html_attributes[:id] = @collection.first.class.name.underscore.pluralize + '_pagination'
+      end
+      @html_attributes
     end
     
   protected
 
-    def windowed_paginator
+    # Collects link items for visible page numbers.
+    def windowed_links
+      prev = nil
+
+      visible_page_numbers.inject [] do |links, n|
+        # detect gaps:
+        links &lt;&lt; gap_marker if prev and n &gt; prev + 1
+        links &lt;&lt; page_link_or_span(n, 'current')
+        prev = n
+        links
+      end
+    end
+
+    # Calculates visible page numbers using the &lt;tt&gt;:inner_window&lt;/tt&gt; and
+    # &lt;tt&gt;:outer_window&lt;/tt&gt; options.
+    def visible_page_numbers
       inner_window, outer_window = @options[:inner_window].to_i, @options[:outer_window].to_i
-      min = page - inner_window
-      max = page + inner_window
+      window_from = current_page - inner_window
+      window_to = current_page + inner_window
+      
       # adjust lower or upper limit if other is out of bounds
-      if max &gt; total_pages then min -= max - total_pages
-      elsif min &lt; 1 then max += 1 - min
+      if window_to &gt; total_pages
+        window_from -= window_to - total_pages
+        window_to = total_pages
+      end
+      if window_from &lt; 1
+        window_to += 1 - window_from
+        window_from = 1
+        window_to = total_pages if window_to &gt; total_pages
       end
       
-      current   = min..max
-      beginning = 1..(1 + outer_window)
-      tail      = (total_pages - outer_window)..total_pages
-      visible   = [beginning, current, tail].map(&amp;:to_a).flatten.sort.uniq
+      visible   = (1..total_pages).to_a
+      left_gap  = (2 + outer_window)...window_from
+      right_gap = (window_to + 1)...(total_pages - outer_window)
+      visible  -= left_gap.to_a  if left_gap.last - left_gap.first &gt; 1
+      visible  -= right_gap.to_a if right_gap.last - right_gap.first &gt; 1
+
+      visible
+    end
+    
+    def page_link_or_span(page, span_class, text = nil)
+      text ||= page.to_s
       
-      links, prev = [], 0
+      if page and page != current_page
+        classnames = span_class &amp;&amp; span_class.index(' ') &amp;&amp; span_class.split(' ', 2).last
+        page_link page, text, :rel =&gt; rel_value(page), :class =&gt; classnames
+      else
+        page_span page, text, :class =&gt; span_class
+      end
+    end
 
-      visible.each do |n|
-        next  if n &lt; 1
-        break if n &gt; total_pages
+    def page_link(page, text, attributes = {})
+      @template.link_to text, url_for(page), attributes
+    end
 
-        unless n - prev &gt; 1
-          prev = n
-          links &lt;&lt; page_link_or_span((n != page ? n : nil), 'current', n)
+    def page_span(page, text, attributes = {})
+      @template.content_tag :span, text, attributes
+    end
+
+    # Returns URL params for +page_link_or_span+, taking the current GET params
+    # and &lt;tt&gt;:params&lt;/tt&gt; option into account.
+    def url_for(page)
+      page_one = page == 1
+      unless @url_string and !page_one
+        @url_params = {}
+        # page links should preserve GET parameters
+        stringified_merge @url_params, @template.params if @template.request.get?
+        stringified_merge @url_params, @options[:params] if @options[:params]
+        
+        if complex = param_name.index(/[^\w-]/)
+          page_param = (defined?(CGIMethods) ? CGIMethods : ActionController::AbstractRequest).
+            parse_query_parameters(&quot;#{param_name}=#{page}&quot;)
+          
+          stringified_merge @url_params, page_param
         else
-          # ellipsis represents the gap between windows
-          prev = n - 1
-          links &lt;&lt; '...'
-          redo
+          @url_params[param_name] = page_one ? 1 : 2
         end
-      end
-      
-      links
-    end
 
-    def page_link_or_span(page, span_class, text)
-      unless page
-        @template.content_tag :span, text, :class =&gt; span_class
-      else
-        # page links should preserve GET/POST parameters
-        @template.link_to text, @template.params.merge(param =&gt; page != 1 ? page : nil)
+        url = @template.url_for(@url_params)
+        return url if page_one
+        
+        if complex
+          @url_string = url.sub(%r!((?:\?|&amp;amp;)#{CGI.escape param_name}=)#{page}!, '\1@')
+          return url
+        else
+          @url_string = url
+          @url_params[param_name] = 3
+          @template.url_for(@url_params).split(//).each_with_index do |char, i|
+            if char == '3' and url[i, 1] == '2'
+              @url_string[i] = '@'
+              break
+            end
+          end
+        end
       end
+      # finally!
+      @url_string.sub '@', page.to_s
     end
 
   private
 
-    def page
+    def rel_value(page)
+      case page
+      when @collection.previous_page; 'prev' + (page == 1 ? ' start' : '')
+      when @collection.next_page; 'next'
+      when 1; 'start'
+      end
+    end
+
+    def current_page
       @collection.current_page
     end
 
     def total_pages
-      @collection.page_count
+      @total_pages ||= WillPaginate::ViewHelpers.total_pages_for_collection(@collection)
+    end
+
+    def param_name
+      @param_name ||= @options[:param_name].to_s
     end
 
-    def param
-      @options[:param_name].to_sym
+    # Recursively merge into target hash by using stringified keys from the other one
+    def stringified_merge(target, other)
+      other.each do |key, value|
+        key = key.to_s # this line is what it's all about!
+        existing = target[key]
+
+        if value.is_a?(Hash) and (existing.is_a?(Hash) or existing.nil?)
+          stringified_merge(existing || (target[key] = {}), value)
+        else
+          target[key] = value
+        end
+      end
     end
   end
 end</diff>
      <filename>vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,24 +1,21 @@
 plugin_root = File.join(File.dirname(__FILE__), '..')
+version = ENV['RAILS_VERSION']
+version = nil if version and version == &quot;&quot;
 
 # first look for a symlink to a copy of the framework
-if framework_root = [&quot;#{plugin_root}/rails&quot;, &quot;#{plugin_root}/../../rails&quot;].find { |p| File.directory? p }
+if !version and framework_root = [&quot;#{plugin_root}/rails&quot;, &quot;#{plugin_root}/../../rails&quot;].find { |p| File.directory? p }
   puts &quot;found framework root: #{framework_root}&quot;
-  # this allows for a plugin to be tested outside an app
+  # this allows for a plugin to be tested outside of an app and without Rails gems
   $:.unshift &quot;#{framework_root}/activesupport/lib&quot;, &quot;#{framework_root}/activerecord/lib&quot;, &quot;#{framework_root}/actionpack/lib&quot;
 else
-  # is the plugin installed in an application?
-  app_root = plugin_root + '/../../..'
-
-  if File.directory? app_root + '/config'
-    puts 'using config/boot.rb'
-    ENV['RAILS_ENV'] = 'test'
-    require File.expand_path(app_root + '/config/boot')
+  # simply use installed gems if available
+  puts &quot;using Rails#{version ? ' ' + version : nil} gems&quot;
+  require 'rubygems'
+  
+  if version
+    gem 'rails', version
   else
-    # simply use installed gems if available
-    puts 'using rubygems'
-    require 'rubygems'
-    gem 'actionpack'; gem 'activerecord'
+    gem 'actionpack'
+    gem 'activerecord'
   end
 end
-
-$:.unshift &quot;#{plugin_root}/lib&quot;</diff>
      <filename>vendor/plugins/will_paginate/test/boot.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,8 @@
 #!/usr/bin/env ruby
 irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
 libs = []
-dirname = File.dirname(__FILE__)
 
 libs &lt;&lt; 'irb/completion'
-libs &lt;&lt; File.join(dirname, 'lib', 'load_fixtures')
+libs &lt;&lt; File.join('lib', 'load_fixtures')
 
-exec &quot;#{irb}#{libs.map{ |l| &quot; -r #{l}&quot; }.join} --simple-prompt&quot;
+exec &quot;#{irb} -Ilib:test#{libs.map{ |l| &quot; -r #{l}&quot; }.join} --simple-prompt&quot;</diff>
      <filename>vendor/plugins/will_paginate/test/console</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,9 @@
-require File.dirname(__FILE__) + '/helper'
-require File.dirname(__FILE__) + '/lib/activerecord_test_case'
+require 'helper'
+require 'lib/activerecord_test_case'
 
 require 'will_paginate'
 WillPaginate.enable_activerecord
+WillPaginate.enable_named_scope
 
 class FinderTest &lt; ActiveRecordTestCase
   fixtures :topics, :replies, :users, :projects, :developers_projects
@@ -12,18 +13,18 @@ class FinderTest &lt; ActiveRecordTestCase
   end
   
   def test_simple_paginate
-    entries = Topic.paginate :page =&gt; nil
-    assert_equal 1, entries.current_page
-    assert_nil entries.previous_page
-    assert_nil entries.next_page
-    assert_equal 1, entries.page_count
-    assert_equal 4, entries.size
+    assert_queries(1) do
+      entries = Topic.paginate :page =&gt; nil
+      assert_equal 1, entries.current_page
+      assert_equal 1, entries.total_pages
+      assert_equal 4, entries.size
+    end
     
-    entries = Topic.paginate :page =&gt; 2
-    assert_equal 2, entries.current_page
-    assert_equal 1, entries.previous_page
-    assert_equal 1, entries.page_count
-    assert entries.empty?
+    assert_queries(2) do
+      entries = Topic.paginate :page =&gt; 2
+      assert_equal 1, entries.total_pages
+      assert entries.empty?
+    end
   end
 
   def test_parameter_api
@@ -41,31 +42,31 @@ class FinderTest &lt; ActiveRecordTestCase
   def test_paginate_with_per_page
     entries = Topic.paginate :page =&gt; 1, :per_page =&gt; 1
     assert_equal 1, entries.size
-    assert_equal 4, entries.page_count
+    assert_equal 4, entries.total_pages
 
     # Developer class has explicit per_page at 10
     entries = Developer.paginate :page =&gt; 1
     assert_equal 10, entries.size
-    assert_equal 2, entries.page_count
+    assert_equal 2, entries.total_pages
 
     entries = Developer.paginate :page =&gt; 1, :per_page =&gt; 5
     assert_equal 11, entries.total_entries
     assert_equal 5, entries.size
-    assert_equal 3, entries.page_count
+    assert_equal 3, entries.total_pages
   end
   
   def test_paginate_with_order
     entries = Topic.paginate :page =&gt; 1, :order =&gt; 'created_at desc'
     expected = [topics(:futurama), topics(:harvey_birdman), topics(:rails), topics(:ar)].reverse
     assert_equal expected, entries.to_a
-    assert_equal 1, entries.page_count
+    assert_equal 1, entries.total_pages
   end
   
   def test_paginate_with_conditions
     entries = Topic.paginate :page =&gt; 1, :conditions =&gt; [&quot;created_at &gt; ?&quot;, 30.minutes.ago]
     expected = [topics(:rails), topics(:ar)]
     assert_equal expected, entries.to_a
-    assert_equal 1, entries.page_count
+    assert_equal 1, entries.total_pages
   end
 
   def test_paginate_with_include_and_conditions
@@ -85,11 +86,14 @@ class FinderTest &lt; ActiveRecordTestCase
   end
   
   def test_paginate_with_include_and_order
-    entries = Topic.paginate \
-      :page     =&gt; 1, 
-      :include  =&gt; :replies,  
-      :order    =&gt; 'replies.created_at asc, topics.created_at asc', 
-      :per_page =&gt; 10
+    entries = nil
+    assert_queries(2) do
+      entries = Topic.paginate \
+        :page     =&gt; 1, 
+        :include  =&gt; :replies,  
+        :order    =&gt; 'replies.created_at asc, topics.created_at asc', 
+        :per_page =&gt; 10
+    end
 
     expected = Topic.find :all, 
       :include =&gt; 'replies', 
@@ -104,7 +108,7 @@ class FinderTest &lt; ActiveRecordTestCase
     entries, project = nil, projects(:active_record)
 
     assert_nothing_raised &quot;THIS IS A BUG in Rails 1.2.3 that was fixed in [7326]. &quot; +
-        &quot;Please upgrade to the 1-2-stable branch or edge Rails.&quot; do
+        &quot;Please upgrade to a newer version of Rails.&quot; do
       entries = project.topics.paginate \
         :page     =&gt; 1, 
         :include  =&gt; :replies,  
@@ -125,10 +129,12 @@ class FinderTest &lt; ActiveRecordTestCase
     expected_name_ordered = [projects(:action_controller), projects(:active_record)]
     expected_id_ordered   = [projects(:active_record), projects(:action_controller)]
 
-    # with association-specified order
-    entries = dhh.projects.paginate(:page =&gt; 1)
-    assert_equal expected_name_ordered, entries
-    assert_equal 2, entries.total_entries
+    assert_queries(2) do
+      # with association-specified order
+      entries = dhh.projects.paginate(:page =&gt; 1)
+      assert_equal expected_name_ordered, entries
+      assert_equal 2, entries.total_entries
+    end
 
     # with explicit order
     entries = dhh.projects.paginate(:page =&gt; 1, :order =&gt; 'projects.id')
@@ -148,30 +154,45 @@ class FinderTest &lt; ActiveRecordTestCase
 
   def test_paginate_association_extension
     project = Project.find(:first)
-    entries = project.replies.paginate_recent :page =&gt; 1
-    assert_equal [replies(:brave)], entries
+    
+    assert_queries(2) do
+      entries = project.replies.paginate_recent :page =&gt; 1
+      assert_equal [replies(:brave)], entries
+    end
   end
   
   def test_paginate_with_joins
-    entries = Developer.paginate :page =&gt; 1,
-                        :joins =&gt; 'LEFT JOIN developers_projects ON users.id = developers_projects.developer_id',
-                        :conditions =&gt; 'project_id = 1'        
-    assert_equal 2, entries.size
-    developer_names = entries.map { |d| d.name }
-    assert developer_names.include?('David')
-    assert developer_names.include?('Jamis')
-
-    expected = entries.to_a
-    entries = Developer.paginate :page =&gt; 1,
-                        :joins =&gt; 'LEFT JOIN developers_projects ON users.id = developers_projects.developer_id',
-                        :conditions =&gt; 'project_id = 1', :count =&gt; { :select =&gt; &quot;users.id&quot; }
-    assert_equal expected, entries.to_a
+    entries = nil
+    
+    assert_queries(1) do
+      entries = Developer.paginate :page =&gt; 1,
+                          :joins =&gt; 'LEFT JOIN developers_projects ON users.id = developers_projects.developer_id',
+                          :conditions =&gt; 'project_id = 1'        
+      assert_equal 2, entries.size
+      developer_names = entries.map &amp;:name
+      assert developer_names.include?('David')
+      assert developer_names.include?('Jamis')
+    end
+
+    assert_queries(1) do
+      expected = entries.to_a
+      entries = Developer.paginate :page =&gt; 1,
+                          :joins =&gt; 'LEFT JOIN developers_projects ON users.id = developers_projects.developer_id',
+                          :conditions =&gt; 'project_id = 1', :count =&gt; { :select =&gt; &quot;users.id&quot; }
+      assert_equal expected, entries.to_a
+      assert_equal 2, entries.total_entries
+    end
   end
 
   def test_paginate_with_group
-    entries = Developer.paginate :page =&gt; 1, :per_page =&gt; 10, :group =&gt; 'salary'
+    entries = nil
+    assert_queries(1) do
+      entries = Developer.paginate :page =&gt; 1, :per_page =&gt; 10,
+                                   :group =&gt; 'salary', :select =&gt; 'salary', :order =&gt; 'salary'
+    end
+    
     expected = [ users(:david), users(:jamis), users(:dev_10), users(:poor_jamis) ].map(&amp;:salary).sort
-    assert_equal expected, entries.map(&amp;:salary).sort
+    assert_equal expected, entries.map(&amp;:salary)
   end
 
   def test_paginate_with_dynamic_finder
@@ -193,55 +214,95 @@ class FinderTest &lt; ActiveRecordTestCase
     end
   end
 
-  def test_paginate_by_sql
-    assert_respond_to Developer, :paginate_by_sql
-    entries = Developer.paginate_by_sql ['select * from users where salary &gt; ?', 80000],
-      :page =&gt; 2, :per_page =&gt; 3, :total_entries =&gt; 9
+  def test_scoped_paginate
+    entries = Developer.with_poor_ones { Developer.paginate :page =&gt; 1 }
 
-    assert_equal (5..7).to_a, entries.map(&amp;:id)
-    assert_equal 9, entries.total_entries
+    assert_equal 2, entries.size
+    assert_equal 2, entries.total_entries
   end
 
-  def test_count_by_sql
-    entries = Developer.paginate_by_sql ['select * from users where salary &gt; ?', 60000],
-      :page =&gt; 2, :per_page =&gt; 3
+  ## named_scope ##
+  
+  def test_paginate_in_named_scope
+    entries = Developer.poor.paginate :page =&gt; 1, :per_page =&gt; 1
 
-    assert_equal 12, entries.total_entries
+    assert_equal 1, entries.size
+    assert_equal 2, entries.total_entries
   end
+  
+  def test_paginate_in_named_scope_on_habtm_association
+    project = projects(:active_record)
+    assert_queries(2) do
+      entries = project.developers.poor.paginate :page =&gt; 1, :per_page =&gt; 1
 
-  def test_count_distinct
-    entries = Developer.paginate :select =&gt; 'DISTINCT salary', :page =&gt; 1, :per_page =&gt; 4
-    assert_equal 4, entries.size
-    assert_equal 4, entries.total_entries
+      assert_equal 1, entries.size, 'one developer should be found'
+      assert_equal 1, entries.total_entries, 'only one developer should be found'
+    end
   end
 
-  def test_scoped_paginate
-    entries =
-      Developer.with_poor_ones do
-        Developer.paginate :page =&gt; 1
-      end
+  def test_paginate_in_named_scope_on_hmt_association
+    project = projects(:active_record)
+    expected = [replies(:brave)]
+    
+    assert_queries(2) do
+      entries = project.replies.recent.paginate :page =&gt; 1, :per_page =&gt; 1
+      assert_equal expected, entries
+      assert_equal 1, entries.total_entries, 'only one reply should be found'
+    end
+  end
 
-    assert_equal 2, entries.size
-    assert_equal 2, entries.total_entries
+  def test_paginate_in_named_scope_on_has_many_association
+    project = projects(:active_record)
+    expected = [topics(:ar)]
+    
+    assert_queries(2) do
+      entries = project.topics.mentions_activerecord.paginate :page =&gt; 1, :per_page =&gt; 1
+      assert_equal expected, entries
+      assert_equal 1, entries.total_entries, 'only one topic should be found'
+    end
+  end
+
+  ## misc ##
+
+  def test_count_and_total_entries_options_are_mutually_exclusive
+    e = assert_raise ArgumentError do
+      Developer.paginate :page =&gt; 1, :count =&gt; {}, :total_entries =&gt; 1
+    end
+    assert_match /exclusive/, e.to_s
+  end
+  
+  def test_readonly
+    assert_nothing_raised { Developer.paginate :readonly =&gt; true, :page =&gt; 1 }
+  end
+
+  # this functionality is temporarily removed
+  def xtest_pagination_defines_method
+    pager = &quot;paginate_by_created_at&quot;
+    assert !User.methods.include?(pager), &quot;User methods should not include `#{pager}` method&quot;
+    # paginate!
+    assert 0, User.send(pager, nil, :page =&gt; 1).total_entries
+    # the paging finder should now be defined
+    assert User.methods.include?(pager), &quot;`#{pager}` method should be defined on User&quot;
   end
 
-  # Are we on edge? Find out by testing find_all which was removed in [6998]
-  unless Developer.respond_to? :find_all
+  # Is this Rails 2.0? Find out by testing find_all which was removed in [6998]
+  unless ActiveRecord::Base.respond_to? :find_all
     def test_paginate_array_of_ids
       # AR finders also accept arrays of IDs
       # (this was broken in Rails before [6912])
-      entries = Developer.paginate((1..8).to_a, :per_page =&gt; 3, :page =&gt; 2)
-      assert_equal (4..6).to_a, entries.map(&amp;:id)
-      assert_equal 8, entries.total_entries
+      assert_queries(1) do
+        entries = Developer.paginate((1..8).to_a, :per_page =&gt; 3, :page =&gt; 2, :order =&gt; 'id')
+        assert_equal (4..6).to_a, entries.map(&amp;:id)
+        assert_equal 8, entries.total_entries
+      end
     end
   end
 
-  uses_mocha 'parameter' do
+  uses_mocha 'internals' do
     def test_implicit_all_with_dynamic_finders
       Topic.expects(:find_all_by_foo).returns([])
-      Topic.expects(:wp_extract_finder_conditions)
-      Topic.expects(:count)
-      Topic.paginate_by_foo :page =&gt; 1
+      Topic.expects(:count).returns(0)
+      Topic.paginate_by_foo :page =&gt; 2
     end
     
     def test_guessing_the_total_count
@@ -252,18 +313,37 @@ class FinderTest &lt; ActiveRecordTestCase
       assert_equal 6, entries.total_entries
     end
     
+    def test_guessing_that_there_are_no_records
+      Topic.expects(:find).returns([])
+      Topic.expects(:count).never
+      
+      entries = Topic.paginate :page =&gt; 1, :per_page =&gt; 4
+      assert_equal 0, entries.total_entries
+    end
+    
     def test_extra_parameters_stay_untouched
-      Topic.expects(:find).with() { |*args| args.last.key? :foo }.returns(Array.new(5))
-      Topic.expects(:count).with(){ |*args| args.last.key? :foo }.returns(1)
+      Topic.expects(:find).with(:all, {:foo =&gt; 'bar', :limit =&gt; 4, :offset =&gt; 0 }).returns(Array.new(5))
+      Topic.expects(:count).with({:foo =&gt; 'bar'}).returns(1)
 
       Topic.paginate :foo =&gt; 'bar', :page =&gt; 1, :per_page =&gt; 4
     end
 
-    def test_count_doesnt_use_select_options
-      Developer.expects(:find).with() { |*args| args.last.key? :select }.returns(Array.new(5))
-      Developer.expects(:count).with(){ |*args| !args.last.key?(:select) }.returns(1)
-      
-      Developer.paginate :select =&gt; 'users.*', :page =&gt; 1, :per_page =&gt; 4
+    def test_count_skips_select
+      Developer.stubs(:find).returns([])
+      Developer.expects(:count).with({}).returns(0)
+      Developer.paginate :select =&gt; 'salary', :page =&gt; 2
+    end
+
+    def test_count_select_when_distinct
+      Developer.stubs(:find).returns([])
+      Developer.expects(:count).with(:select =&gt; 'DISTINCT salary').returns(0)
+      Developer.paginate :select =&gt; 'DISTINCT salary', :page =&gt; 2
+    end
+
+    def test_count_with_scoped_select_when_distinct
+      Developer.stubs(:find).returns([])
+      Developer.expects(:count).with(:select =&gt; 'DISTINCT users.id').returns(0)
+      Developer.distinct.paginate :page =&gt; 2
     end
 
     def test_should_use_scoped_finders_if_present
@@ -274,12 +354,95 @@ class FinderTest &lt; ActiveRecordTestCase
       Topic.paginate_best :page =&gt; 1, :per_page =&gt; 4
     end
 
+    def test_paginate_by_sql
+      assert_respond_to Developer, :paginate_by_sql
+      Developer.expects(:find_by_sql).with(regexp_matches(/sql LIMIT 3(,| OFFSET) 3/)).returns([])
+      Developer.expects(:count_by_sql).with('SELECT COUNT(*) FROM (sql) AS count_table').returns(0)
+      
+      entries = Developer.paginate_by_sql 'sql', :page =&gt; 2, :per_page =&gt; 3
+    end
+
+    def test_paginate_by_sql_respects_total_entries_setting
+      Developer.expects(:find_by_sql).returns([])
+      Developer.expects(:count_by_sql).never
+      
+      entries = Developer.paginate_by_sql 'sql', :page =&gt; 1, :total_entries =&gt; 999
+      assert_equal 999, entries.total_entries
+    end
+
+    def test_paginate_by_sql_strips_order_by_when_counting
+      Developer.expects(:find_by_sql).returns([])
+      Developer.expects(:count_by_sql).with(&quot;SELECT COUNT(*) FROM (sql\n ) AS count_table&quot;).returns(0)
+      
+      Developer.paginate_by_sql &quot;sql\n ORDER\nby foo, bar, `baz` ASC&quot;, :page =&gt; 2
+    end
+
+    # TODO: counts are still wrong
     def test_ability_to_use_with_custom_finders
-      # acts_as_taggable defines `find_tagged_with(tag, options)`
-      Topic.expects(:find_tagged_with).with('will_paginate', :offset =&gt; 0, :limit =&gt; 5).returns([])
+      # acts_as_taggable defines find_tagged_with(tag, options)
+      Topic.expects(:find_tagged_with).with('will_paginate', :offset =&gt; 5, :limit =&gt; 5).returns([])
       Topic.expects(:count).with({}).returns(0)
       
-      Topic.paginate_tagged_with 'will_paginate', :page =&gt; 1, :per_page =&gt; 5
+      Topic.paginate_tagged_with 'will_paginate', :page =&gt; 2, :per_page =&gt; 5
+    end
+    
+    def test_array_argument_doesnt_eliminate_count
+      ids = (1..8).to_a
+      Developer.expects(:find_all_by_id).returns([])
+      Developer.expects(:count).returns(0)
+      
+      Developer.paginate_by_id(ids, :per_page =&gt; 3, :page =&gt; 2, :order =&gt; 'id')
+    end
+
+    def test_paginating_finder_doesnt_mangle_options
+      Developer.expects(:find).returns([])
+      options = { :page =&gt; 1, :per_page =&gt; 2, :foo =&gt; 'bar' }
+      options_before = options.dup
+      
+      Developer.paginate(options)
+      assert_equal options_before, options
+    end
+    
+    def test_paginate_by_sql_doesnt_change_original_query
+      query = 'SQL QUERY'
+      original_query = query.dup
+      Developer.expects(:find_by_sql).returns([])
+      
+      Developer.paginate_by_sql query, :page =&gt; 1
+      assert_equal original_query, query
+    end
+
+    def test_paginated_each
+      collection = stub('collection', :size =&gt; 5, :empty? =&gt; false, :per_page =&gt; 5)
+      collection.expects(:each).times(2).returns(collection)
+      last_collection = stub('collection', :size =&gt; 4, :empty? =&gt; false, :per_page =&gt; 5)
+      last_collection.expects(:each).returns(last_collection)
+      
+      params = { :order =&gt; 'id', :total_entries =&gt; 0 }
+      
+      Developer.expects(:paginate).with(params.merge(:page =&gt; 2)).returns(collection)
+      Developer.expects(:paginate).with(params.merge(:page =&gt; 3)).returns(collection)
+      Developer.expects(:paginate).with(params.merge(:page =&gt; 4)).returns(last_collection)
+      
+      assert_equal 14, Developer.paginated_each(:page =&gt; '2') { }
+    end
+
+    # detect ActiveRecord 2.1
+    if ActiveRecord::Base.private_methods.include?('references_eager_loaded_tables?')
+      def test_removes_irrelevant_includes_in_count
+        Developer.expects(:find).returns([1])
+        Developer.expects(:count).with({}).returns(0)
+
+        Developer.paginate :page =&gt; 1, :per_page =&gt; 1, :include =&gt; :projects
+      end
+
+      def test_doesnt_remove_referenced_includes_in_count
+        Developer.expects(:find).returns([1])
+        Developer.expects(:count).with({ :include =&gt; :projects, :conditions =&gt; 'projects.id &gt; 2' }).returns(0)
+
+        Developer.paginate :page =&gt; 1, :per_page =&gt; 1,
+          :include =&gt; :projects, :conditions =&gt; 'projects.id &gt; 2'
+      end
     end
   end
 end</diff>
      <filename>vendor/plugins/will_paginate/test/finder_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,5 +7,8 @@ class Developer &lt; User
     end
   end
 
+  named_scope :distinct, :select =&gt; 'DISTINCT `users`.*'
+  named_scope :poor, :conditions =&gt; ['salary &lt;= ?', 80000], :order =&gt; 'salary'
+
   def self.per_page() 10 end
 end</diff>
      <filename>vendor/plugins/will_paginate/test/fixtures/developer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,6 @@
-action_controller:
-  id: 2
-  name: Active Controller
-
 active_record:
   id: 1
   name: Active Record
+action_controller:
+  id: 2
+  name: Active Controller</diff>
      <filename>vendor/plugins/will_paginate/test/fixtures/projects.yml</filename>
    </modified>
    <modified>
      <diff>@@ -3,32 +3,27 @@ witty_retort:
   topic_id: 1
   content: Birdman is better!
   created_at: &lt;%= 6.hours.ago.to_s(:db) %&gt;
-  updated_at: nil
   
 another:
   id: 2
   topic_id: 2
   content: Nuh uh!
   created_at: &lt;%= 1.hour.ago.to_s(:db) %&gt;
-  updated_at: nil
   
 spam:
   id: 3
   topic_id: 1
   content: Nice site!
   created_at: &lt;%= 1.hour.ago.to_s(:db) %&gt;
-  updated_at: nil
 
 decisive:
   id: 4
   topic_id: 4
   content: &quot;I'm getting to the bottom of this&quot;
   created_at: &lt;%= 30.minutes.ago.to_s(:db) %&gt;
-  updated_at: nil
 
 brave:
   id: 5
   topic_id: 4
   content: &quot;AR doesn't scare me a bit&quot;
   created_at: &lt;%= 10.minutes.ago.to_s(:db) %&gt;
-  updated_at: nil</diff>
      <filename>vendor/plugins/will_paginate/test/fixtures/replies.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,7 @@
 class Reply &lt; ActiveRecord::Base
   belongs_to :topic, :include =&gt; [:replies]
+
+  named_scope :recent, :conditions =&gt; ['replies.created_at &gt; ?', 15.minutes.ago]
   
   validates_presence_of :content
 end</diff>
      <filename>vendor/plugins/will_paginate/test/fixtures/reply.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,21 +1,22 @@
 ActiveRecord::Schema.define do
 
-  create_table &quot;developers_projects&quot;, :id =&gt; false, :force =&gt; true do |t|
-    t.column &quot;developer_id&quot;, :integer,                :null =&gt; false
-    t.column &quot;project_id&quot;,   :integer,                :null =&gt; false
-    t.column &quot;joined_on&quot;,    :date
-    t.column &quot;access_level&quot;, :integer, :default =&gt; 1
+  create_table &quot;users&quot;, :force =&gt; true do |t|
+    t.column &quot;name&quot;,       :text
+    t.column &quot;salary&quot;,     :integer,  :default =&gt; 70000
+    t.column &quot;created_at&quot;, :datetime
+    t.column &quot;updated_at&quot;, :datetime
+    t.column &quot;type&quot;,       :text
   end
 
   create_table &quot;projects&quot;, :force =&gt; true do |t|
     t.column &quot;name&quot;, :text
   end
 
-  create_table &quot;replies&quot;, :force =&gt; true do |t|
-    t.column &quot;content&quot;,    :text
-    t.column &quot;created_at&quot;, :datetime
-    t.column &quot;updated_at&quot;, :datetime
-    t.column &quot;topic_id&quot;,   :integer
+  create_table &quot;developers_projects&quot;, :id =&gt; false, :force =&gt; true do |t|
+    t.column &quot;developer_id&quot;, :integer, :null =&gt; false
+    t.column &quot;project_id&quot;,   :integer, :null =&gt; false
+    t.column &quot;joined_on&quot;,    :date
+    t.column &quot;access_level&quot;, :integer, :default =&gt; 1
   end
 
   create_table &quot;topics&quot;, :force =&gt; true do |t|
@@ -27,12 +28,11 @@ ActiveRecord::Schema.define do
     t.column &quot;updated_at&quot;, :datetime
   end
 
-  create_table &quot;users&quot;, :force =&gt; true do |t|
-    t.column &quot;name&quot;,       :text
-    t.column &quot;salary&quot;,     :integer,  :default =&gt; 70000
+  create_table &quot;replies&quot;, :force =&gt; true do |t|
+    t.column &quot;content&quot;,    :text
     t.column &quot;created_at&quot;, :datetime
     t.column &quot;updated_at&quot;, :datetime
-    t.column &quot;type&quot;,       :text
+    t.column &quot;topic_id&quot;,   :integer
   end
 
 end</diff>
      <filename>vendor/plugins/will_paginate/test/fixtures/schema.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,6 @@
 class Topic &lt; ActiveRecord::Base
   has_many :replies, :dependent =&gt; :destroy, :order =&gt; 'replies.created_at DESC'
   belongs_to :project
+
+  named_scope :mentions_activerecord, :conditions =&gt; ['topics.title LIKE ?', '%ActiveRecord%']
 end</diff>
      <filename>vendor/plugins/will_paginate/test/fixtures/topic.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@ require 'rubygems'
 # gem install redgreen for colored test output
 begin require 'redgreen'; rescue LoadError; end
 
-require File.join(File.dirname(__FILE__), 'boot') unless defined?(ActiveRecord)
+require 'boot' unless defined?(ActiveRecord)
 
 class Test::Unit::TestCase
   protected
@@ -13,13 +13,25 @@ class Test::Unit::TestCase
       [method.to_s, method.to_sym].each { |m| assert_respond_to object, m }
     end
   end
+  
+  def collect_deprecations
+    old_behavior = WillPaginate::Deprecation.behavior
+    deprecations = []
+    WillPaginate::Deprecation.behavior = Proc.new do |message, callstack|
+      deprecations &lt;&lt; message
+    end
+    result = yield
+    [result, deprecations]
+  ensure
+    WillPaginate::Deprecation.behavior = old_behavior
+  end
 end
 
 # Wrap tests that use Mocha and skip if unavailable.
 def uses_mocha(test_name)
   require 'mocha' unless Object.const_defined?(:Mocha)
-  yield
 rescue LoadError =&gt; load_error
-  raise unless load_error.message =~ /mocha/i
   $stderr.puts &quot;Skipping #{test_name} tests. `gem install mocha` and try again.&quot;
+else
+  yield
 end</diff>
      <filename>vendor/plugins/will_paginate/test/helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,10 @@
-require File.join(File.dirname(__FILE__), 'activerecord_test_connector')
+require 'lib/activerecord_test_connector'
 
 class ActiveRecordTestCase &lt; Test::Unit::TestCase
   # Set our fixture path
   if ActiveRecordTestConnector.able_to_connect
     self.fixture_path = File.join(File.dirname(__FILE__), '..', 'fixtures')
-    self.use_transactional_fixtures = false
+    self.use_transactional_fixtures = true
   end
 
   def self.fixtures(*args)
@@ -18,6 +18,19 @@ class ActiveRecordTestCase &lt; Test::Unit::TestCase
   # Default so Test::Unit::TestCase doesn't complain
   def test_truth
   end
+
+  protected
+
+    def assert_queries(num = 1)
+      $query_count = 0
+      yield
+    ensure
+      assert_equal num, $query_count, &quot;#{$query_count} instead of #{num} queries were executed.&quot;
+    end
+
+    def assert_no_queries(&amp;block)
+      assert_queries(0, &amp;block)
+    end
 end
 
 ActiveRecordTestConnector.setup</diff>
      <filename>vendor/plugins/will_paginate/test/lib/activerecord_test_case.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,8 @@ class ActiveRecordTestConnector
   cattr_accessor :able_to_connect
   cattr_accessor :connected
 
+  FIXTURES_PATH = File.join(File.dirname(__FILE__), '..', 'fixtures')
+
   # Set our defaults
   self.connected = false
   self.able_to_connect = true
@@ -14,54 +16,58 @@ class ActiveRecordTestConnector
     unless self.connected || !self.able_to_connect
       setup_connection
       load_schema
-      # require_fixture_models
-      Dependencies.load_paths.unshift(File.dirname(__FILE__) + &quot;/../fixtures&quot;)
+      add_load_path FIXTURES_PATH
       self.connected = true
     end
   rescue Exception =&gt; e  # errors from ActiveRecord setup
-    $stderr.puts &quot;\nSkipping ActiveRecord assertion tests: #{e}&quot;
-    #$stderr.puts &quot;  #{e.backtrace.join(&quot;\n  &quot;)}\n&quot;
+    $stderr.puts &quot;\nSkipping ActiveRecord tests: #{e}\n\n&quot;
     self.able_to_connect = false
   end
 
   private
+  
+  def self.add_load_path(path)
+    dep = defined?(ActiveSupport::Dependencies) ? ActiveSupport::Dependencies : ::Dependencies
+    dep.load_paths.unshift path
+  end
 
   def self.setup_connection
-    if Object.const_defined?(:ActiveRecord)
-      defaults = { :database =&gt; ':memory:' }
-      ActiveRecord::Base.logger = Logger.new STDOUT if $0 == 'irb'
-      
-      begin
-        options = defaults.merge :adapter =&gt; 'sqlite3', :timeout =&gt; 500
-        ActiveRecord::Base.establish_connection(options)
-        ActiveRecord::Base.configurations = { 'sqlite3_ar_integration' =&gt; options }
-        ActiveRecord::Base.connection
-      rescue Exception  # errors from establishing a connection
-        $stderr.puts 'SQLite 3 unavailable; trying SQLite 2.'
-        options = defaults.merge :adapter =&gt; 'sqlite'
-        ActiveRecord::Base.establish_connection(options)
-        ActiveRecord::Base.configurations = { 'sqlite2_ar_integration' =&gt; options }
-        ActiveRecord::Base.connection
-      end
+    db = ENV['DB'].blank?? 'sqlite3' : ENV['DB']
+    
+    configurations = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'database.yml'))
+    raise &quot;no configuration for '#{db}'&quot; unless configurations.key? db
+    configuration = configurations[db]
+    
+    ActiveRecord::Base.logger = Logger.new(STDOUT) if $0 == 'irb'
+    puts &quot;using #{configuration['adapter']} adapter&quot; unless ENV['DB'].blank?
+    
+    ActiveRecord::Base.establish_connection(configuration)
+    ActiveRecord::Base.configurations = { db =&gt; configuration }
+    prepare ActiveRecord::Base.connection
 
-      unless Object.const_defined?(:QUOTED_TYPE)
-        Object.send :const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')
-      end
-    else
-      raise &quot;Can't setup connection since ActiveRecord isn't loaded.&quot;
+    unless Object.const_defined?(:QUOTED_TYPE)
+      Object.send :const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')
     end
   end
 
   def self.load_schema
     ActiveRecord::Base.silence do
       ActiveRecord::Migration.verbose = false
-      load File.dirname(__FILE__) + &quot;/../fixtures/schema.rb&quot;
+      load File.join(FIXTURES_PATH, 'schema.rb')
     end
   end
 
-  def self.require_fixture_models
-    models = Dir.glob(File.dirname(__FILE__) + &quot;/../fixtures/*.rb&quot;)
-    models = (models.grep(/user.rb/) + models).uniq
-    models.each { |f| require f }
+  def self.prepare(conn)
+    class &lt;&lt; conn
+      IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SHOW FIELDS /]
+
+      def execute_with_counting(sql, name = nil, &amp;block)
+        $query_count ||= 0
+        $query_count  += 1 unless IGNORED_SQL.any? { |r| sql =~ r }
+        execute_without_counting(sql, name, &amp;block)
+      end
+
+      alias_method_chain :execute, :counting
+    end
   end
 end</diff>
      <filename>vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,11 @@
-dirname = File.dirname(__FILE__)
-require File.join(dirname, '..', 'boot')
-require File.join(dirname, 'activerecord_test_connector')
+require 'boot'
+require 'lib/activerecord_test_connector'
 
 # setup the connection
 ActiveRecordTestConnector.setup
 
 # load all fixtures
-fixture_path = File.join(dirname, '..', 'fixtures')
-Fixtures.create_fixtures(fixture_path, ActiveRecord::Base.connection.tables)
+Fixtures.create_fixtures(ActiveRecordTestConnector::FIXTURES_PATH, ActiveRecord::Base.connection.tables)
 
 require 'will_paginate'
 WillPaginate.enable_activerecord</diff>
      <filename>vendor/plugins/will_paginate/test/lib/load_fixtures.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>vendor/plugins/restful_authentication/README</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/activation.rhtml</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/fixtures.yml</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/functional_spec.rb</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/functional_test.rb</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/login.rhtml</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/mailer_test.rb</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/model_functional_spec.rb</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/model_functional_test.rb</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/signup.rhtml</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/signup_notification.rhtml</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/unit_spec.rb</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/restful_authentication/generators/authenticated/templates/unit_test.rb</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/rspec-rails/spec/rails/autotest/rails_rspec_spec.rb</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/rspec-rails/spec/rails/matchers/render_spec.rb</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/will_paginate/README</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/will_paginate/test/array_pagination_test.rb</filename>
    </removed>
    <removed>
      <filename>vendor/plugins/will_paginate/test/pagination_test.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>ed82a25ebee7761420a493d915237723e9b4a5b2</id>
    </parent>
  </parents>
  <author>
    <name>Nick Quaranto</name>
    <email>nick@quaran.to</email>
  </author>
  <url>http://github.com/courtenay/altered_beast/commit/e6d3af7e6258e346969e2f8be780fbb4ea744bfa</url>
  <id>e6d3af7e6258e346969e2f8be780fbb4ea744bfa</id>
  <committed-date>2008-09-23T17:07:26-07:00</committed-date>
  <authored-date>2008-09-23T17:07:26-07:00</authored-date>
  <message>Trying to update this thing to 2.1</message>
  <tree>e01aee4349c790c2e04422f379661a58a85ddef1</tree>
  <committer>
    <name>Nick Quaranto</name>
    <email>nick@quaran.to</email>
  </committer>
</commit>
