You are viewing a plain text version of this content. The canonical link for it is here.
Posted to olio-commits@incubator.apache.org by ws...@apache.org on 2008/12/11 01:34:30 UTC

svn commit: r725524 [7/14] - in /incubator/olio/webapp/rails/trunk: app/controllers/ app/models/ app/views/events/ config/ config/environments/ spec/controllers/ spec/models/ vendor/plugins/attachment_fu/ vendor/plugins/attachment_fu/lib/ vendor/plugin...

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/autotest/rspec.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/autotest/rspec.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/autotest/rspec.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/autotest/rspec.rb Wed Dec 10 17:34:18 2008
@@ -4,7 +4,7 @@
   at.clear_mappings
   # watch out: Ruby bug (1.8.6):
   # %r(/) != /\//
-  at.add_mapping(%r%^spec/.*\.rb$%) { |filename, _| 
+  at.add_mapping(%r%^spec/.*_spec.rb$%) { |filename, _| 
     filename 
   }
   at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m| 
@@ -21,14 +21,14 @@
 
   def initialize
     super
-    self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m
+    self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m
     self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m
   end
   
   def consolidate_failures(failed)
     filters = new_hash_of_arrays
     failed.each do |spec, trace|
-      if trace =~ /\n(\.\/)?(.*spec\.rb):[\d]+:\Z?/
+      if trace =~ /\n(\.\/)?(.*spec\.rb):[\d]+:/
         filters[$2] << spec
       end
     end
@@ -36,37 +36,12 @@
   end
 
   def make_test_cmd(files_to_test)
-    return "#{ruby} -S #{spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}"
+    return '' if files_to_test.empty?
+    spec_program = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec'))
+    return "#{ruby} #{spec_program} #{files_to_test.keys.flatten.join(' ')} #{add_options_if_present}"
   end
   
   def add_options_if_present # :nodoc:
     File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
   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, "No spec command could be found!" 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

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec.rb Wed Dec 10 17:34:18 2008
@@ -1,31 +1,34 @@
-require 'spec/version'
 require 'spec/matchers'
 require 'spec/expectations'
 require 'spec/example'
-require 'spec/extensions'
 require 'spec/runner'
 require 'spec/adapters'
-
-if Object.const_defined?(:Test)
-  require 'spec/interop/test'
-end
+require 'spec/version'
+require 'spec/dsl'
 
 module Spec
-  class << self
-    def run?
-      @run || rspec_options.examples_run?
-    end
+  def self.test_unit_defined?
+    Object.const_defined?(:Test) && Test.const_defined?(:Unit) && Test::Unit.respond_to?(:run?)
+  end
+
+  def self.run?
+    Runner.options.examples_run?
+  end
 
-    def run
-      return true if run?
-      result = rspec_options.run_examples
-      @run = true
-      result
-    end
-    attr_writer :run
-    
-    def exit?
-      !Object.const_defined?(:Test) || Test::Unit.run?
-    end
+  def self.run
+    return true if run?
+    Runner.options.run_examples
   end
-end
\ No newline at end of file
+  
+  def self.exit?
+    !test_unit_defined? || Test::Unit.run?
+  end
+
+  def self.spec_command?
+    $0.split('/').last == 'spec'
+  end
+end
+
+if Spec::test_unit_defined?
+  require 'spec/interop/test'
+end

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/adapters/ruby_engine.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/adapters/ruby_engine.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/adapters/ruby_engine.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/adapters/ruby_engine.rb Wed Dec 10 17:34:18 2008
@@ -11,8 +11,8 @@
       }
     
       def self.engine
-        if const_defined?(:RUBY_ENGINE)
-          return RUBY_ENGINE
+        if Object.const_defined?('RUBY_ENGINE')
+          return Object.const_get('RUBY_ENGINE')
         else
           return 'mri'
         end

Added: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/dsl.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/dsl.rb?rev=725524&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/dsl.rb (added)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/dsl.rb Wed Dec 10 17:34:18 2008
@@ -0,0 +1 @@
+require 'spec/dsl/main'
\ No newline at end of file

Added: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/dsl/main.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/dsl/main.rb?rev=725524&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/dsl/main.rb (added)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/dsl/main.rb Wed Dec 10 17:34:18 2008
@@ -0,0 +1,82 @@
+module Spec
+  module DSL
+    module Main
+      # Creates and returns a class that includes the ExampleGroupMethods
+      # module. Which ExampleGroup type is created depends on the directory of the file
+      # calling this method. For example, Spec::Rails will use different
+      # classes for specs living in <tt>spec/models</tt>,
+      # <tt>spec/helpers</tt>, <tt>spec/views</tt> and
+      # <tt>spec/controllers</tt>.
+      #
+      # It is also possible to override autodiscovery of the example group
+      # type with an options Hash as the last argument:
+      #
+      #   describe "name", :type => :something_special do ...
+      #
+      # The reason for using different behaviour classes is to have different
+      # matcher methods available from within the <tt>describe</tt> block.
+      #
+      # See Spec::Example::ExampleGroupFactory#register for details about how to
+      # register special implementations.
+      #
+      def describe(*args, &block)
+        Spec::Example::ExampleGroupFactory.create_example_group(*args, &block)
+      end
+      alias :context :describe
+    
+      # Creates an example group that can be shared by other example groups
+      #
+      # == Examples
+      #
+      #  share_examples_for "All Editions" do
+      #    it "all editions behaviour" ...
+      #  end
+      #
+      #  describe SmallEdition do
+      #    it_should_behave_like "All Editions"
+      #  
+      #    it "should do small edition stuff" do
+      #      ...
+      #    end
+      #  end
+      def share_examples_for(name, &block)
+        Spec::Example::SharedExampleGroup.register(name, &block)
+      end
+      alias :shared_examples_for :share_examples_for
+    
+      # Creates a Shared Example Group and assigns it to a constant
+      #
+      #  share_as :AllEditions do
+      #    it "should do all editions stuff" ...
+      #  end
+      #
+      #  describe SmallEdition do
+      #    it_should_behave_like AllEditions
+      #  
+      #    it "should do small edition stuff" do
+      #      ...
+      #    end
+      #  end
+      #
+      # And, for those of you who prefer to use something more like Ruby, you
+      # can just include the module directly
+      #
+      #  describe SmallEdition do
+      #    include AllEditions
+      #  
+      #    it "should do small edition stuff" do
+      #      ...
+      #    end
+      #  end
+      def share_as(name, &block)
+        begin
+          Object.const_set(name, Spec::Example::SharedExampleGroup.register(name, &block))
+        rescue NameError => e
+          raise NameError.new(e.message + "\nThe first argument to share_as must be a legal name for a constant\n")
+        end
+      end
+    end
+  end
+end
+
+include Spec::DSL::Main

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example.rb Wed Dec 10 17:34:18 2008
@@ -1,7 +1,32 @@
+module Spec
+  module Example
+    def self.args_and_options(*args)
+      with_options_from(args) do |options|
+        return args, options
+      end
+    end
+
+    def self.scope_from(*args)
+      args[0] || :each
+    end
+
+    def self.scope_and_options(*args)
+      args, options = args_and_options(*args)
+      return scope_from(*args), options
+    end
+
+  private
+    
+    def self.with_options_from(args)
+      yield Hash === args.last ? args.pop : {} if block_given?
+    end
+  end
+end
+
 require 'timeout'
+require 'spec/example/before_and_after_hooks'
 require 'spec/example/pending'
 require 'spec/example/module_reopening_fix'
-require 'spec/example/module_inclusion_warnings'
 require 'spec/example/example_group_methods'
 require 'spec/example/example_methods'
 require 'spec/example/example_group'
@@ -10,3 +35,4 @@
 require 'spec/example/errors'
 require 'spec/example/configuration'
 require 'spec/example/example_matcher'
+

Added: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/before_and_after_hooks.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/before_and_after_hooks.rb?rev=725524&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/before_and_after_hooks.rb (added)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/before_and_after_hooks.rb Wed Dec 10 17:34:18 2008
@@ -0,0 +1,81 @@
+module Spec
+  module Example
+    module BeforeAndAfterHooks
+      # Registers a block to be executed before each example.
+      # This method prepends +block+ to existing before blocks.
+      def prepend_before(*args, &block)
+        before_parts(*args).unshift(block)
+      end
+
+      # Registers a block to be executed before each example.
+      # This method appends +block+ to existing before blocks.
+      def append_before(*args, &block)
+        before_parts(*args) << block
+      end
+      alias_method :before, :append_before
+
+      # Registers a block to be executed after each example.
+      # This method prepends +block+ to existing after blocks.
+      def prepend_after(*args, &block)
+        after_parts(*args).unshift(block)
+      end
+      alias_method :after, :prepend_after
+
+      # Registers a block to be executed after each example.
+      # This method appends +block+ to existing after blocks.
+      def append_after(*args, &block)
+        after_parts(*args) << block
+      end
+
+      # TODO - deprecate this unless there is a reason why it exists
+      def remove_after(scope, &block) # :nodoc:
+        after_each_parts.delete(block)
+      end
+
+      # Deprecated. Use before(:each)
+      def setup(&block)
+        before(:each, &block)
+      end
+
+      # Deprecated. Use after(:each)
+      def teardown(&block)
+        after(:each, &block)
+      end
+
+      def before_all_parts # :nodoc:
+        @before_all_parts ||= []
+      end
+
+      def after_all_parts # :nodoc:
+        @after_all_parts ||= []
+      end
+
+      def before_each_parts # :nodoc:
+        @before_each_parts ||= []
+      end
+
+      def after_each_parts # :nodoc:
+        @after_each_parts ||= []
+      end
+      
+    private  
+      
+      def before_parts(*args)
+        case Spec::Example.scope_from(*args)
+        when :each; before_each_parts
+        when :all; before_all_parts
+        when :suite; Spec::Runner.options.before_suite_parts
+        end
+      end
+
+      def after_parts(*args)
+        case Spec::Example.scope_from(*args)
+        when :each; after_each_parts
+        when :all; after_all_parts
+        when :suite; Spec::Runner.options.after_suite_parts
+        end
+      end
+
+    end
+  end
+end
\ No newline at end of file

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/configuration.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/configuration.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/configuration.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/configuration.rb Wed Dec 10 17:34:18 2008
@@ -47,35 +47,48 @@
       #   include(My::Helpers, :type => :key)
       #
       # Declares modules to be included in multiple example groups
-      # (<tt>describe</tt> blocks). With no :type, the modules listed will be
-      # included in all example groups. Use :type to restrict the inclusion to
-      # a subset of example groups. The value assigned to :type should be a
-      # key that maps to a class that is either a subclass of
-      # Spec::Example::ExampleGroup or extends Spec::Example::ExampleGroupMethods
-      # and includes Spec::Example::ExampleMethods
+      # (<tt>describe</tt> blocks). With no <tt>:type</tt>, the modules listed
+      # will be included in all example groups.
       #
-      #   config.include(My::Pony, My::Horse, :type => :farm)
+      # Use <tt>:type</tt> to restrict
+      # the inclusion to a subset of example groups. The value assigned to
+      # <tt>:type</tt> should be a key that maps to a class that is either a
+      # subclass of Spec::Example::ExampleGroup or extends
+      # Spec::Example::ExampleGroupMethods and includes
+      # Spec::Example::ExampleMethods.
+      #
+      # For example, the rspec-rails gem/plugin extends Test::Unit::TestCase
+      # with Spec::Example::ExampleGroupMethods and includes
+      # Spec::Example::ExampleMethods in it. So if you have a module of helper
+      # methods for controller examples, you could do this:
+      #
+      #   config.include(ControllerExampleHelpers, :type => :controller)
       #
       # Only example groups that have that type will get the modules included:
       #
-      #   describe "Downtown", :type => :city do
-      #     # Will *not* get My::Pony and My::Horse included
+      #   describe Account, :type => :model do
+      #     # Will *not* include ControllerExampleHelpers
       #   end
       #
-      #   describe "Old Mac Donald", :type => :farm do
-      #     # *Will* get My::Pony and My::Horse included
+      #   describe AccountsController, :type => :controller do
+      #     # *Will* include ControllerExampleHelpers
       #   end
       #
       def include(*args)
-        args << {} unless Hash === args.last
-        modules, options = args_and_options(*args)
-        required_example_group = get_type_from_options(options)
-        required_example_group = required_example_group.to_sym if required_example_group
-        modules.each do |mod|
-          ExampleGroupFactory.get(required_example_group).send(:include, mod)
-        end
+        include_or_extend(:include, *args)
       end
-
+      
+      # :call-seq:
+      #   extend(Some::Helpers)
+      #   extend(Some::Helpers, More::Helpers)
+      #   extend(My::Helpers, :type => :key)
+      #
+      # Works just like #include, but extends the example groups
+      # with the modules rather than including them.
+      def extend(*args)
+        include_or_extend(:extend, *args)
+      end
+      
       # Defines global predicate matchers. Example:
       #
       #   config.predicate_matchers[:swim] = :can_swim?
@@ -91,11 +104,7 @@
       # Prepends a global <tt>before</tt> block to all example groups.
       # See #append_before for filtering semantics.
       def prepend_before(*args, &proc)
-        scope, options = scope_and_options(*args)
-        example_group = ExampleGroupFactory.get(
-          get_type_from_options(options)
-        )
-        example_group.prepend_before(scope, &proc)
+        add_callback(:prepend_before, *args, &proc)
       end
       
       # Appends a global <tt>before</tt> block to all example groups.
@@ -110,40 +119,40 @@
       #   config.prepend_before(:type => :farm)
       #
       def append_before(*args, &proc)
-        scope, options = scope_and_options(*args)
-        example_group = ExampleGroupFactory.get(
-          get_type_from_options(options)
-        )
-        example_group.append_before(scope, &proc)
+        add_callback(:append_before, *args, &proc)
       end
       alias_method :before, :append_before
 
       # Prepends a global <tt>after</tt> block to all example groups.
       # See #append_before for filtering semantics.
       def prepend_after(*args, &proc)
-        scope, options = scope_and_options(*args)
-        example_group = ExampleGroupFactory.get(
-          get_type_from_options(options)
-        )
-        example_group.prepend_after(scope, &proc)
+        add_callback(:prepend_after, *args, &proc)
       end
       alias_method :after, :prepend_after
       
       # Appends a global <tt>after</tt> block to all example groups.
       # See #append_before for filtering semantics.
       def append_after(*args, &proc)
-        scope, options = scope_and_options(*args)
-        example_group = ExampleGroupFactory.get(
-          get_type_from_options(options)
-        )
-        example_group.append_after(scope, &proc)
+        add_callback(:append_after, *args, &proc)
       end
 
     private
+    
+      def include_or_extend(*args)
+        action = args.shift
+        args << {} unless Hash === args.last
+        modules, options = Spec::Example.args_and_options(*args)
+        required_example_group = get_type_from_options(options)
+        required_example_group = required_example_group.to_sym if required_example_group
+        modules.each do |mod|
+          ExampleGroupFactory.get(required_example_group).__send__(action, mod)
+        end
+      end
 
-      def scope_and_options(*args)
-        args, options = args_and_options(*args)
-        scope = (args[0] || :each), options
+      def add_callback(sym, *args, &proc)
+        scope, options = Spec::Example.scope_and_options(*args)
+        example_group = ExampleGroupFactory.get(get_type_from_options(options))
+        example_group.__send__(sym, scope, &proc)
       end
 
       def get_type_from_options(options)

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/errors.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/errors.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/errors.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/errors.rb Wed Dec 10 17:34:18 2008
@@ -1,9 +1,30 @@
 module Spec
   module Example
     class ExamplePendingError < StandardError
-    end
+      attr_reader :pending_caller
 
-    class PendingExampleFixedError < StandardError
+      def initialize(message=nil)
+        super
+        @pending_caller = caller[2]
+      end
+    end
+    
+    class NotYetImplementedError < ExamplePendingError
+      MESSAGE = "Not Yet Implemented"
+      RSPEC_ROOT_LIB = File.expand_path(File.dirname(__FILE__) + "/../..")
+      
+      def initialize(backtrace)
+        super(MESSAGE)
+        @pending_caller = pending_caller_from(backtrace)
+      end
+      
+    private
+      
+      def pending_caller_from(backtrace)
+        backtrace.detect {|line| !line.include?(RSPEC_ROOT_LIB) }
+      end
     end
+
+    class PendingExampleFixedError < StandardError; end
   end
 end

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_group.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_group.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_group.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_group.rb Wed Dec 10 17:34:18 2008
@@ -6,9 +6,18 @@
       extend Spec::Example::ExampleGroupMethods
       include Spec::Example::ExampleMethods
 
-      def initialize(defined_description, &implementation)
+      def initialize(defined_description, options={}, &implementation)
+        @_options = options
         @_defined_description = defined_description
-        @_implementation = implementation
+        @_implementation = implementation || pending_implementation
+        @_backtrace = caller
+      end
+      
+    private
+      
+      def pending_implementation
+        error = NotYetImplementedError.new(caller)
+        lambda { raise(error) }
       end
     end
   end

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_group_factory.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_group_factory.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_group_factory.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_group_factory.rb Wed Dec 10 17:34:18 2008
@@ -1,12 +1,21 @@
 module Spec
   module Example
     class ExampleGroupFactory
-      class << self
+      module ClassMethods
         def reset
           @example_group_types = nil
           default(ExampleGroup)
         end
 
+        def registered_or_ancestor_of_registered?(example_group_classes) # :nodoc:
+          example_group_classes.each do |example_group_class|
+            return false unless registered_types.any? do |registered_type|
+              registered_type.ancestors.include? example_group_class
+            end
+          end
+          return true
+        end
+
         # Registers an example group class +klass+ with the symbol +type+. For
         # example:
         #
@@ -41,12 +50,15 @@
         end
         
         def create_example_group(*args, &block)
-          opts = Hash === args.last ? args.last : {}
-          superclass = determine_superclass(opts)
+          raise ArgumentError if args.empty?
+          raise ArgumentError unless block
+          args << {} unless Hash === args.last
+          args.last[:spec_path] ||= File.expand_path(caller(0)[2])
+          superclass = determine_superclass(args.last)
           superclass.describe(*args, &block)
         end
-
-        protected
+        
+      protected
 
         def determine_superclass(opts)
           key = if opts[:type]
@@ -56,8 +68,15 @@
           end
           get(key)
         end
+        
+      private
+        
+        def registered_types
+          @example_group_types.values
+        end
 
       end
+      extend ClassMethods
       self.reset
     end
   end

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb Wed Dec 10 17:34:18 2008
@@ -2,22 +2,47 @@
   module Example
 
     module ExampleGroupMethods
-      class << self
-        attr_accessor :matcher_class
+      include Spec::Example::BeforeAndAfterHooks
+      
+      def self.matcher_class
+        @matcher_class
+      end
+      
+      def self.matcher_class=(matcher_class)
+        @matcher_class = matcher_class
+      end
 
-        def description_text(*args)
-          args.inject("") do |result, arg|
-            result << " " unless (result == "" || arg.to_s =~ /^(\s|\.|#)/)
-            result << arg.to_s
-          end
+      def self.description_text(*args)
+        args.inject("") do |description, arg|
+          description << " " unless (description == "" || arg.to_s =~ /^(\s|\.|#)/)
+          description << arg.to_s
         end
       end
 
-      attr_reader :description_text, :description_args, :description_options, :spec_path, :registration_binding_block
+      attr_reader :description_options, :spec_path
+      alias :options :description_options
+      
+      # Provides the backtrace up to where this example_group was declared.
+      def backtrace
+        @backtrace
+      end
+
+      # Deprecated - use +backtrace()+
+      def example_group_backtrace
+        Kernel.warn <<-WARNING
+ExampleGroupMethods#example_group_backtrace is deprecated and will be removed
+from a future version. Please use ExampleGroupMethods#backtrace instead.
+WARNING
+        backtrace
+      end
+      
+      def description_args
+        @description_args ||= []
+      end
 
       def inherited(klass)
         super
-        klass.register {}
+        klass.register
         Spec::Runner.register_at_exit_hook
       end
       
@@ -38,39 +63,55 @@
       def describe(*args, &example_group_block)
         args << {} unless Hash === args.last
         if example_group_block
-          params = args.last
-          params[:spec_path] = eval("caller(0)[1]", example_group_block) unless params[:spec_path]
-          if params[:shared]
-            SharedExampleGroup.new(*args, &example_group_block)
+          options = args.last
+          # Ruby 1.9 - the next line uses example_group_block.binding instead of example_group_block
+          options[:spec_path] = eval("caller(0)[1]", example_group_block.binding) unless options[:spec_path]
+          if options[:shared]
+            create_shared_example_group(*args, &example_group_block)
           else
-            self.subclass("Subclass") do
-              describe(*args)
-              module_eval(&example_group_block)
-            end
+            create_subclass(*args, &example_group_block)
           end
         else
           set_description(*args)
-          before_eval
-          self
         end
       end
       alias :context :describe
-
+      
+      def create_shared_example_group(*args, &example_group_block) # :nodoc:
+        SharedExampleGroup.register(*args, &example_group_block)
+      end
+      
+      def create_subclass(*args, &example_group_block) # :nodoc:
+        subclass("Subclass") do
+          set_description(*args)
+          module_eval(&example_group_block)
+        end
+      end
+      
+      # Creates a new subclass of self, with a name "under" our own name.
+      # Example:
+      #
+      #   x = Foo::Bar.subclass('Zap'){}
+      #   x.name # => Foo::Bar::Zap_1
+      #   x.superclass.name # => Foo::Bar
+      def subclass(base_name, &body) # :nodoc:
+        @class_count ||= 0
+        @class_count += 1
+        klass = Class.new(self)
+        class_name = "#{base_name}_#{@class_count}"
+        const_set(class_name, klass)
+        klass.instance_eval(&body)
+        klass
+      end
+      
       # Use this to pull in examples from shared example groups.
       # See Spec::Runner for information about shared example groups.
-      def it_should_behave_like(shared_example_group)
-        case shared_example_group
-        when SharedExampleGroup
-          include shared_example_group
-        else
-          example_group = SharedExampleGroup.find_shared_example_group(shared_example_group)
-          unless example_group
-            raise RuntimeError.new("Shared Example Group '#{shared_example_group}' can not be found")
-          end
-          include(example_group)
+      def it_should_behave_like(*shared_example_groups)
+        shared_example_groups.each do |group|
+          include_shared_example_group(group)
         end
       end
-
+      
       # :call-seq:
       #   predicate_matchers[matcher_name] = method_on_object
       #   predicate_matchers[matcher_name] = [method1_on_object, method2_on_object]
@@ -103,21 +144,24 @@
         @predicate_matchers ||= {:an_instance_of => :is_a?}
       end
 
-      # Creates an instance of Spec::Example::Example and adds
-      # it to a collection of examples of the current example group.
-      def it(description=nil, &implementation)
-        e = new(description, &implementation)
+      # Creates an instance of the current example group class and adds it to
+      # a collection of examples of the current example group.
+      def example(description=nil, options={}, &implementation)
+        e = new(description, options, &implementation)
         example_objects << e
         e
       end
 
-      alias_method :specify, :it
+      alias_method :it, :example
+      alias_method :specify, :example
 
       # Use this to temporarily disable an example.
-      def xit(description=nil, opts={}, &block)
+      def xexample(description=nil, opts={}, &block)
         Kernel.warn("Example disabled: #{description}")
       end
-      alias_method :xspecify, :xit
+      
+      alias_method :xit, :xexample
+      alias_method :xspecify, :xexample
 
       def run
         examples = examples_to_run
@@ -135,113 +179,61 @@
 
       def description
         result = ExampleGroupMethods.description_text(*description_parts)
-        if result.nil? || result == ""
-          return to_s
-        else
-          result
-        end
+        (result.nil? || result == "") ? to_s : result
       end
-
+      
       def described_type
-        description_parts.find {|part| part.is_a?(Module)}
+        description_parts.reverse.find {|part| part.is_a?(Module)}
       end
-
+      
+      # Defines an explicit subject for an example group which can then be the
+      # implicit receiver (through delegation) of calls to +should+.
+      #
+      # == Examples
+      #
+      #   describe CheckingAccount, "with $50" do
+      #     subject { CheckingAccount.new(:amount => 50, :currency => :USD) }
+      #     it { should have_a_balance_of(50, :USD)}
+      #     it { should_not be_overdrawn}
+      #   end
+      #
+      # See +ExampleMethods#should+ for more information about this approach.
+      def subject(&block)
+        @_subject_block = block
+      end
+      
+      def subject_block
+        @_subject_block || lambda {nil}
+      end
+      
       def description_parts #:nodoc:
         parts = []
-        execute_in_class_hierarchy do |example_group|
-          parts << example_group.description_args
+        each_ancestor_example_group_class do |example_group_class|
+          parts << example_group_class.description_args
         end
         parts.flatten.compact
       end
 
       def set_description(*args)
-        args, options = args_and_options(*args)
+        args, options = Spec::Example.args_and_options(*args)
         @description_args = args
         @description_options = options
         @description_text = ExampleGroupMethods.description_text(*args)
+        @backtrace = caller(1)
         @spec_path = File.expand_path(options[:spec_path]) if options[:spec_path]
-        if described_type.class == Module
-          @described_module = described_type
-        end
         self
       end
       
-      attr_reader :described_module
-
       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:
         examples.length
       end
 
-      # Registers a block to be executed before each example.
-      # This method prepends +block+ to existing before blocks.
-      def prepend_before(*args, &block)
-        scope, options = scope_and_options(*args)
-        parts = before_parts_from_scope(scope)
-        parts.unshift(block)
-      end
-
-      # Registers a block to be executed before each example.
-      # This method appends +block+ to existing before blocks.
-      def append_before(*args, &block)
-        scope, options = scope_and_options(*args)
-        parts = before_parts_from_scope(scope)
-        parts << block
-      end
-      alias_method :before, :append_before
-
-      # Registers a block to be executed after each example.
-      # This method prepends +block+ to existing after blocks.
-      def prepend_after(*args, &block)
-        scope, options = scope_and_options(*args)
-        parts = after_parts_from_scope(scope)
-        parts.unshift(block)
-      end
-      alias_method :after, :prepend_after
-
-      # Registers a block to be executed after each example.
-      # This method appends +block+ to existing after blocks.
-      def append_after(*args, &block)
-        scope, options = scope_and_options(*args)
-        parts = after_parts_from_scope(scope)
-        parts << block
-      end
-
-      def remove_after(scope, &block)
-        after_each_parts.delete(block)
-      end
-
-      # Deprecated. Use before(:each)
-      def setup(&block)
-        before(:each, &block)
-      end
-
-      # Deprecated. Use after(:each)
-      def teardown(&block)
-        after(:each, &block)
-      end
-
-      def before_all_parts # :nodoc:
-        @before_all_parts ||= []
-      end
-
-      def after_all_parts # :nodoc:
-        @after_all_parts ||= []
-      end
-
-      def before_each_parts # :nodoc:
-        @before_each_parts ||= []
-      end
-
-      def after_each_parts # :nodoc:
-        @after_each_parts ||= []
-      end
-
       # Only used from RSpec's own examples
       def reset # :nodoc:
         @before_all_parts = nil
@@ -250,36 +242,31 @@
         @after_each_parts = nil
       end
 
-      def register(&registration_binding_block)
-        @registration_binding_block = registration_binding_block
-        rspec_options.add_example_group self
+      def register
+        Spec::Runner.options.add_example_group self
       end
 
       def unregister #:nodoc:
-        rspec_options.remove_example_group self
-      end
-
-      def registration_backtrace
-        eval("caller", registration_binding_block)
+        Spec::Runner.options.remove_example_group self
       end
 
       def run_before_each(example)
-        execute_in_class_hierarchy do |example_group|
-          example.eval_each_fail_fast(example_group.before_each_parts)
+        each_ancestor_example_group_class do |example_group_class|
+          example.eval_each_fail_fast(example_group_class.before_each_parts)
         end
       end
 
       def run_after_each(example)
-        execute_in_class_hierarchy(:superclass_first) do |example_group|
-          example.eval_each_fail_slow(example_group.after_each_parts)
+        each_ancestor_example_group_class(:superclass_first) do |example_group_class|
+          example.eval_each_fail_slow(example_group_class.after_each_parts)
         end
       end
 
     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
@@ -287,8 +274,8 @@
       def run_before_all
         before_all = new("before(:all)")
         begin
-          execute_in_class_hierarchy do |example_group|
-            before_all.eval_each_fail_fast(example_group.before_all_parts)
+          each_ancestor_example_group_class do |example_group_class|
+            before_all.eval_each_fail_fast(example_group_class.before_all_parts)
           end
           return [true, before_all.instance_variable_hash]
         rescue Exception => e
@@ -302,7 +289,7 @@
 
         after_all_instance_variables = instance_variables
         examples.each do |example_group_instance|
-          success &= example_group_instance.execute(rspec_options, instance_variables)
+          success &= 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]
@@ -311,8 +298,8 @@
       def run_after_all(success, instance_variables)
         after_all = new("after(:all)")
         after_all.set_instance_variables_from_hash(instance_variables)
-        execute_in_class_hierarchy(:superclass_first) do |example_group|
-          after_all.eval_each_fail_slow(example_group.after_all_parts)
+        each_ancestor_example_group_class(:superclass_first) do |example_group_class|
+          after_all.eval_each_fail_slow(example_group_class.after_all_parts)
         end
         return success
       rescue Exception => e
@@ -335,37 +322,36 @@
       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
         @example_objects ||= []
       end
 
-      def execute_in_class_hierarchy(superclass_last=false)
+      def each_ancestor_example_group_class(superclass_last=false)
         classes = []
         current_class = self
-        while is_example_group?(current_class)
+        while is_example_group_class?(current_class)
           superclass_last ? classes << current_class : classes.unshift(current_class)
           current_class = current_class.superclass
         end
-        superclass_last ? classes << ExampleMethods : classes.unshift(ExampleMethods)
-
+        
         classes.each do |example_group|
           yield example_group
         end
       end
 
-      def is_example_group?(klass)
-        Module === klass && klass.kind_of?(ExampleGroupMethods)
+      def is_example_group_class?(klass)
+        klass.kind_of?(ExampleGroupMethods) && klass.included_modules.include?(ExampleMethods)
       end
 
       def plugin_mock_framework
@@ -389,30 +375,6 @@
         end
       end
 
-      def scope_and_options(*args)
-        args, options = args_and_options(*args)
-        scope = (args[0] || :each), options
-      end
-
-      def before_parts_from_scope(scope)
-        case scope
-        when :each; before_each_parts
-        when :all; before_all_parts
-        when :suite; rspec_options.before_suite_parts
-        end
-      end
-
-      def after_parts_from_scope(scope)
-        case scope
-        when :each; after_each_parts
-        when :all; after_all_parts
-        when :suite; rspec_options.after_suite_parts
-        end
-      end
-
-      def before_eval
-      end
-
       def add_method_examples(examples)
         instance_methods.sort.each do |method_name|
           if example_method?(method_name)
@@ -430,10 +392,23 @@
       def should_method?(method_name)
         !(method_name =~ /^should(_not)?$/) &&
         method_name =~ /^should/ && (
-          instance_method(method_name).arity == 0 ||
-          instance_method(method_name).arity == -1
+          [-1,0].include?(instance_method(method_name).arity)
         )
       end
+
+      def include_shared_example_group(shared_example_group)
+        case shared_example_group
+        when SharedExampleGroup
+          include shared_example_group
+        else
+          example_group = SharedExampleGroup.find(shared_example_group)
+          unless example_group
+            raise RuntimeError.new("Shared Example Group '#{shared_example_group}' can not be found")
+          end
+          include(example_group)
+        end
+      end
+
     end
 
   end

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_methods.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_methods.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_methods.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/example_methods.rb Wed Dec 10 17:34:18 2008
@@ -1,14 +1,45 @@
 module Spec
   module Example
     module ExampleMethods
-      extend ExampleGroupMethods
+      
       extend ModuleReopeningFix
-      include ModuleInclusionWarnings
       
+      def subject # :nodoc: this is somewhat experimental
+        @subject ||= ( instance_variable_get(subject_variable_name) ||
+                       instance_eval(&self.class.subject_block) ||
+                       (described_class ? described_class.new : nil) )
+      end
+
+      # When +should+ is called with no explicit receiver, the call is
+      # delegated to the *subject* of the example group. This could be either
+      # an explicit subject generated by calling the block passed to
+      # +ExampleGroupMethods#subject+, or, if the group is describing a class,
+      # an implicitly generated instance of that class.
+      def should(matcher=nil)
+        if matcher
+          subject.should(matcher)
+        else
+          subject.should
+        end
+      end
 
-      PENDING_EXAMPLE_BLOCK = lambda {
-        raise Spec::Example::ExamplePendingError.new("Not Yet Implemented")
-      }
+      # Just like +should+, +should_not+ delegates to the subject (implicit or
+      # explicit) of the example group.
+      def should_not(matcher)
+        subject.should_not(matcher)
+      end
+      
+      def violated(message="")
+        raise Spec::Expectations::ExpectationNotMetError.new(message)
+      end
+
+      def description
+        @_defined_description || ::Spec::Matchers.generated_description || "NO NAME"
+      end
+      
+      def options
+        @_options
+      end
 
       def execute(options, instance_variables)
         options.reporter.example_started(self)
@@ -17,13 +48,13 @@
         execution_error = nil
         Timeout.timeout(options.timeout) do
           begin
-            before_example
-            run_with_description_capturing
+            before_each_example
+            eval_block
           rescue Exception => e
             execution_error ||= e
           end
           begin
-            after_example
+            after_each_example
           rescue Exception => e
             execution_error ||= e
           end
@@ -33,28 +64,24 @@
         success = execution_error.nil? || ExamplePendingError === execution_error
       end
 
-      def instance_variable_hash
+      def instance_variable_hash # :nodoc:
         instance_variables.inject({}) do |variable_hash, variable_name|
           variable_hash[variable_name] = instance_variable_get(variable_name)
           variable_hash
         end
       end
 
-      def violated(message="")
-        raise Spec::Expectations::ExpectationNotMetError.new(message)
-      end
-
-      def eval_each_fail_fast(procs) #:nodoc:
-        procs.each do |proc|
-          instance_eval(&proc)
+      def eval_each_fail_fast(examples) # :nodoc:
+        examples.each do |example|
+          instance_eval(&example)
         end
       end
 
-      def eval_each_fail_slow(procs) #:nodoc:
+      def eval_each_fail_slow(examples) # :nodoc:
         first_exception = nil
-        procs.each do |proc|
+        examples.each do |example|
           begin
-            instance_eval(&proc)
+            instance_eval(&example)
           rescue Exception => e
             first_exception ||= e
           end
@@ -62,15 +89,19 @@
         raise first_exception if first_exception
       end
 
-      def description
-        @_defined_description || @_matcher_description || "NO NAME"
-      end
-
-      def __full_description
+      # Concats the class description with the example description.
+      #
+      #   describe Account do
+      #     it "should start with a balance of 0" do
+      #     ...
+      #
+      #   full_description
+      #   => "Account should start with a balance of 0"
+      def full_description
         "#{self.class.description} #{self.description}"
       end
       
-      def set_instance_variables_from_hash(ivars)
+      def set_instance_variables_from_hash(ivars) # :nodoc:
         ivars.each do |variable_name, value|
           # Ruby 1.9 requires variable.to_s on the next line
           unless ['@_implementation', '@_defined_description', '@_matcher_description', '@method_name'].include?(variable_name.to_s)
@@ -79,34 +110,59 @@
         end
       end
 
-      def run_with_description_capturing
-        begin
-          return instance_eval(&(@_implementation || PENDING_EXAMPLE_BLOCK))
-        ensure
-          @_matcher_description = Spec::Matchers.generated_description
-          Spec::Matchers.clear_generated_description
-        end
+      def eval_block # :nodoc:
+        instance_eval(&@_implementation)
       end
 
-      def implementation_backtrace
-        eval("caller", @_implementation)
+      # Provides the backtrace up to where this example was declared.
+      def backtrace
+        @_backtrace
       end
       
-      protected
+      # Deprecated - use +backtrace()+
+      def implementation_backtrace
+        Kernel.warn <<-WARNING
+ExampleMethods#implementation_backtrace is deprecated and will be removed
+from a future version. Please use ExampleMethods#backtrace instead.
+WARNING
+        backtrace
+      end
+
+      private
       include Matchers
       include Pending
       
-      def before_example
+      def before_each_example
         setup_mocks_for_rspec
         self.class.run_before_each(self)
       end
 
-      def after_example
+      def after_each_example
         self.class.run_after_each(self)
         verify_mocks_for_rspec
       ensure
         teardown_mocks_for_rspec
       end
+
+      def subject_variable_name
+        '@' << (described_class ? underscore(described_class.name) : '__this_does_not_exist')
+      end
+      
+      def described_class
+        Class === described_type ? described_type : nil
+      end
+      
+      def described_type
+        self.class.described_type
+      end
+
+      def underscore(camel_cased_word)
+        camel_cased_word.to_s.gsub(/::/, '_').
+          gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
+          gsub(/([a-z\d])([A-Z])/,'\1_\2').
+          tr("-", "_").
+          downcase
+      end
     end
   end
-end
\ No newline at end of file
+end

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/shared_example_group.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/shared_example_group.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/shared_example_group.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/example/shared_example_group.rb Wed Dec 10 17:34:18 2008
@@ -1,31 +1,40 @@
 module Spec
   module Example
     class SharedExampleGroup < Module
-      class << self
-        def add_shared_example_group(new_example_group)
-          guard_against_redefining_existing_example_group(new_example_group)
-          shared_example_groups << new_example_group
+      module ClassMethods
+        def register(*args, &block)
+          new_example_group = new(*args, &block)
+          shared_example_groups << new_example_group unless already_registered?(new_example_group)
+          new_example_group
+        end
+        
+        def find(example_group_description)
+          shared_example_groups.find {|b| b.description == example_group_description}
         end
 
-        def find_shared_example_group(example_group_description)
-          shared_example_groups.find do |b|
-            b.description == example_group_description
-          end
+        def clear
+          shared_example_groups.clear
+        end
+        
+        def include?(group)
+          shared_example_groups.include?(group)
+        end
+        
+        def count
+          shared_example_groups.length
         end
 
+      private
+      
         def shared_example_groups
-          # TODO - this needs to be global, or at least accessible from
-          # from subclasses of Example in a centralized place. I'm not loving
-          # this as a solution, but it works for now.
-          $shared_example_groups ||= []
+          @shared_example_groups ||= []
         end
-
-        private
-        def guard_against_redefining_existing_example_group(new_example_group)
-          existing_example_group = find_shared_example_group(new_example_group.description)
-          return unless existing_example_group
-          return if new_example_group.equal?(existing_example_group)
-          return if spec_path(new_example_group) == spec_path(existing_example_group)
+      
+        def already_registered?(new_example_group)
+          existing_example_group = find(new_example_group.description)
+          return false unless existing_example_group
+          return true if new_example_group.equal?(existing_example_group)
+          return true if spec_path(new_example_group) == spec_path(existing_example_group)
           raise ArgumentError.new("Shared Example '#{existing_example_group.description}' already exists")
         end
 
@@ -33,25 +42,21 @@
           File.expand_path(example_group.spec_path)
         end
       end
+
+      extend ClassMethods
       include ExampleGroupMethods
-      public :include
 
       def initialize(*args, &example_group_block)
-        describe(*args)
+        set_description(*args)
         @example_group_block = example_group_block
-        self.class.add_shared_example_group(self)
       end
 
       def included(mod) # :nodoc:
         mod.module_eval(&@example_group_block)
       end
 
-      def execute_in_class_hierarchy(superclass_last=false)
-        classes = [self]
-        superclass_last ? classes << ExampleMethods : classes.unshift(ExampleMethods)
-        classes.each do |example_group|
-          yield example_group
-        end
+      def each_ancestor_example_group_class(superclass_last=false)
+        yield self
       end
     end
   end

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations.rb Wed Dec 10 17:34:18 2008
@@ -2,6 +2,7 @@
 require 'spec/expectations/errors'
 require 'spec/expectations/extensions'
 require 'spec/expectations/handler'
+require 'spec/expectations/wrap_expectation'
 
 module Spec
   
@@ -30,27 +31,31 @@
   # RSpec ships with a standard set of useful matchers, and writing your own
   # matchers is quite simple. See Spec::Matchers for details.
   module Expectations
-    class << self
-      attr_accessor :differ
+    def self.differ
+      @differ
+    end
+    
+    def self.differ=(differ)
+      @differ = differ
+    end
 
-      # raises a Spec::Expectations::ExpectationNotMetError with message
-      #
-      # When a differ has been assigned and fail_with is passed
-      # <code>expected</code> and <code>target</code>, passes them
-      # to the differ to append a diff message to the failure message.
-      def fail_with(message, expected=nil, target=nil) # :nodoc:
-        if Array === message && message.length == 3
-          message, expected, target = message[0], message[1], message[2]
-        end
-        unless (differ.nil? || expected.nil? || target.nil?)
-          if expected.is_a?(String)
-            message << "\nDiff:" << self.differ.diff_as_string(target.to_s, expected)
-          elsif !target.is_a?(Proc)
-            message << "\nDiff:" << self.differ.diff_as_object(target, expected)
-          end
+    # raises a Spec::Expectations::ExpectationNotMetError with message
+    #
+    # When a differ has been assigned and fail_with is passed
+    # <code>expected</code> and <code>target</code>, passes them
+    # to the differ to append a diff message to the failure message.
+    def self.fail_with(message, expected=nil, target=nil) # :nodoc:
+      if Array === message && message.length == 3
+        message, expected, target = message[0], message[1], message[2]
+      end
+      unless (differ.nil? || expected.nil? || target.nil?)
+        if expected.is_a?(String)
+          message << "\nDiff:" << self.differ.diff_as_string(target.to_s, expected)
+        elsif !target.is_a?(Proc)
+          message << "\nDiff:" << self.differ.diff_as_object(target, expected)
         end
-        Kernel::raise(Spec::Expectations::ExpectationNotMetError.new(message))
       end
+      Kernel::raise(Spec::Expectations::ExpectationNotMetError.new(message))
     end
   end
 end

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations/extensions/object.rb Wed Dec 10 17:34:18 2008
@@ -27,7 +27,7 @@
       #
       # NOTE that this does NOT support receiver.should != expected.
       # Instead, use receiver.should_not == expected
-      def should(matcher=:use_operator_matcher, &block)
+      def should(matcher=nil, &block)
         ExpectationMatcherHandler.handle_matcher(self, matcher, &block)
       end
 
@@ -50,7 +50,7 @@
       #     => Passes unless (receiver =~ regexp)
       #
       # See Spec::Matchers for more information about matchers
-      def should_not(matcher=:use_operator_matcher, &block)
+      def should_not(matcher=nil, &block)
         NegativeExpectationMatcherHandler.handle_matcher(self, matcher, &block)
       end
 

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations/handler.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations/handler.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations/handler.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations/handler.rb Wed Dec 10 17:34:18 2008
@@ -2,59 +2,46 @@
   module Expectations
     class InvalidMatcherError < ArgumentError; end        
     
-    module MatcherHandlerHelper
-      def describe_matcher(matcher)
-        matcher.respond_to?(:description) ? matcher.description : "[#{matcher.class.name} does not provide a description]"
-      end
-    end
-    
     class ExpectationMatcherHandler        
-      class << self
-        include MatcherHandlerHelper
-        def handle_matcher(actual, matcher, &block)
-          if :use_operator_matcher == matcher
-            return Spec::Matchers::PositiveOperatorMatcher.new(actual)
-          end
+      def self.handle_matcher(actual, matcher, &block)
+        ::Spec::Matchers.last_should = "should"
+        return Spec::Matchers::PositiveOperatorMatcher.new(actual) if matcher.nil?
 
-          unless matcher.respond_to?(:matches?)
-            raise InvalidMatcherError, "Expected a matcher, got #{matcher.inspect}."
-          end
-          
-          match = matcher.matches?(actual, &block)
-          ::Spec::Matchers.generated_description = "should #{describe_matcher(matcher)}"
-          Spec::Expectations.fail_with(matcher.failure_message) unless match
+        unless matcher.respond_to?(:matches?)
+          raise InvalidMatcherError, "Expected a matcher, got #{matcher.inspect}."
         end
+        
+        match = matcher.matches?(actual, &block)
+        ::Spec::Matchers.last_matcher = matcher
+        Spec::Expectations.fail_with(matcher.failure_message) unless match
+        match
       end
     end
 
     class NegativeExpectationMatcherHandler
-      class << self
-        include MatcherHandlerHelper
-        def handle_matcher(actual, matcher, &block)
-          if :use_operator_matcher == matcher
-            return Spec::Matchers::NegativeOperatorMatcher.new(actual)
-          end
-          
-          unless matcher.respond_to?(:matches?)
-            raise InvalidMatcherError, "Expected a matcher, got #{matcher.inspect}."
-          end
+      def self.handle_matcher(actual, matcher, &block)
+        ::Spec::Matchers.last_should = "should not"
+        return Spec::Matchers::NegativeOperatorMatcher.new(actual) if matcher.nil?
+        
+        unless matcher.respond_to?(:matches?)
+          raise InvalidMatcherError, "Expected a matcher, got #{matcher.inspect}."
+        end
 
-          unless matcher.respond_to?(:negative_failure_message)
-            Spec::Expectations.fail_with(
+        unless matcher.respond_to?(:negative_failure_message)
+          Spec::Expectations.fail_with(
 <<-EOF
 Matcher does not support should_not.
 See Spec::Matchers for more information
 about matchers.
 EOF
 )
-          end
-          match = matcher.matches?(actual, &block)
-          ::Spec::Matchers.generated_description = "should not #{describe_matcher(matcher)}"
-          Spec::Expectations.fail_with(matcher.negative_failure_message) if match
         end
+        match = matcher.matches?(actual, &block)
+        ::Spec::Matchers.last_matcher = matcher
+        Spec::Expectations.fail_with(matcher.negative_failure_message) if match
+        match
       end
     end
-
   end
 end
 

Added: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations/wrap_expectation.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations/wrap_expectation.rb?rev=725524&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations/wrap_expectation.rb (added)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/expectations/wrap_expectation.rb Wed Dec 10 17:34:18 2008
@@ -0,0 +1,56 @@
+module Spec
+  module Matchers
+    
+    # wraps an expectation in a block that will return true if the
+    # expectation passes and false if it fails (without bubbling up
+    # the failure).
+    #     
+    # This is intended to be used in the context of a simple matcher,
+    # and is especially useful for wrapping multiple expectations or
+    # one or more assertions from test/unit extensions when running
+    # with test/unit.
+    #
+    # == Examples
+    #
+    #   def eat_cheese(cheese)
+    #     simple_matcher do |mouse, matcher|
+    #       matcher.negative_failure_message = "expected #{mouse} not to eat cheese"
+    #       wrap_expectation do |matcher|
+    #         assert_eats_cheese(mouse)
+    #       end
+    #     end
+    #   end
+    #
+    #   describe Mouse do
+    #     it "eats cheese" do
+    #       Mouse.new.should eat_cheese
+    #     end
+    #   end
+    #
+    # You might be wondering "why would I do this if I could just say"
+    # assert_eats_cheese?", a fair question, indeed. You might prefer
+    # to replace the word assert with something more aligned with the
+    # rest of your code examples. You are using rspec, after all.
+    #
+    # The other benefit you get is that you can use the negative version
+    # of the matcher:
+    #
+    #   describe Cat do
+    #     it "does not eat cheese" do
+    #       Cat.new.should_not eat_cheese
+    #     end
+    #   end
+    #
+    # So in the event there is no assert_does_not_eat_cheese available,
+    # you're all set!
+    def wrap_expectation(matcher, &block)
+      begin
+        block.call(matcher)
+        return true
+      rescue Exception => e
+        matcher.failure_message = e.message
+        return false
+      end
+    end
+  end
+end

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/interop/test/unit/testcase.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/interop/test/unit/testcase.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/interop/test/unit/testcase.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/interop/test/unit/testcase.rb Wed Dec 10 17:34:18 2008
@@ -23,39 +23,51 @@
       extend Spec::Example::ExampleGroupMethods
       include Spec::Example::ExampleMethods
 
-      before(:each) {setup}
-      after(:each) {teardown}
+      def self.suite
+        Test::Unit::TestSuiteAdapter.new(self)
+      end
 
-      class << self
-        def suite
-          Test::Unit::TestSuiteAdapter.new(self)
-        end
-
-        def example_method?(method_name)
-          should_method?(method_name) || test_method?(method_name)
-        end
-
-        def test_method?(method_name)
-          method_name =~ /^test[_A-Z]./ && (
-            instance_method(method_name).arity == 0 ||
-            instance_method(method_name).arity == -1
-          )
-        end
+      def self.example_method?(method_name)
+        should_method?(method_name) || test_method?(method_name)
       end
 
-      def initialize(defined_description, &implementation)
+      def self.test_method?(method_name)
+        method_name =~ /^test[_A-Z]./ && (
+          instance_method(method_name).arity == 0 ||
+          instance_method(method_name).arity == -1
+        )
+      end
+
+      before(:each) {setup}
+      after(:each) {teardown}
+
+      def initialize(defined_description, options={}, &implementation)
         @_defined_description = defined_description
-        @_implementation = implementation
+        
+        # TODO - examples fail in rspec-rails if we remove "|| pending_implementation"
+        #      - find a way to fail without it in rspec's code examples
+        @_implementation = implementation || pending_implementation
 
         @_result = ::Test::Unit::TestResult.new
-        # @method_name is important to set here because it "complies" with Test::Unit's interface.
+        # @method_name is important to set here because it complies with Test::Unit's interface.
         # Some Test::Unit extensions depend on @method_name being present.
         @method_name = @_defined_description
+
+        # TODO - this is necessary to run single examples in rspec-rails, but I haven't
+        # found a good way to write a failing example just within rspec core
+        @_backtrace = caller
       end
 
       def run(ignore_this_argument=nil)
         super()
       end
+
+    private
+
+      def pending_implementation
+        error = Spec::Example::NotYetImplementedError.new(caller)
+        lambda { raise(error) }
+      end
     end
   end
 end

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers.rb Wed Dec 10 17:34:18 2008
@@ -1,7 +1,12 @@
+require 'spec/matchers/operator_matcher'
+require 'spec/matchers/generated_descriptions'
+require 'spec/matchers/errors'
+require 'spec/matchers/method_missing'
 require 'spec/matchers/simple_matcher'
 require 'spec/matchers/be'
 require 'spec/matchers/be_close'
 require 'spec/matchers/change'
+require 'spec/matchers/match_array'
 require 'spec/matchers/eql'
 require 'spec/matchers/equal'
 require 'spec/matchers/exist'
@@ -13,7 +18,6 @@
 require 'spec/matchers/respond_to'
 require 'spec/matchers/satisfy'
 require 'spec/matchers/throw_symbol'
-require 'spec/matchers/operator_matcher'
 
 module Spec
 
@@ -132,25 +136,5 @@
   #     config.include(CustomGameMatchers)
   #   end
   #
-  module Matchers
-    module ModuleMethods
-      attr_accessor :generated_description
-
-      def clear_generated_description
-        self.generated_description = nil
-      end
-    end
-
-    extend ModuleMethods
-
-    def method_missing(sym, *args, &block) # :nodoc:
-      return Matchers::Be.new(sym, *args) if sym.starts_with?("be_")
-      return Matchers::Has.new(sym, *args) if sym.starts_with?("have_")
-      super
-    end
-
-    class MatcherError < StandardError
-    end
-    
-  end
+  module Matchers; end
 end

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/be.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/be.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/be.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/be.rb Wed Dec 10 17:34:18 2008
@@ -3,140 +3,115 @@
     
     class Be #:nodoc:
       def initialize(*args)
-        if args.empty?
-          @expected = :satisfy_if
-        else
-          @expected = parse_expected(args.shift)
-        end
+        @expected = args.empty? ? true : set_expected(args.shift)
         @args = args
-        @comparison = ""
       end
       
       def matches?(actual)
         @actual = actual
-        if handling_predicate?
-          begin
-            return @result = actual.__send__(predicate, *@args)
-          rescue => predicate_error
-            # This clause should be empty, but rcov will not report it as covered
-            # unless something (anything) is executed within the clause
-            rcov_error_report = "http://eigenclass.org/hiki.rb?rcov-0.8.0"
-          end
+        handling_predicate? ? run_predicate_on(actual) : match_or_compare(actual)
+      end
+      
+      def run_predicate_on(actual)
+        begin
+          return @result = actual.__send__(predicate, *@args)
+        rescue NameError => predicate_missing_error
+          "this needs to be here or rcov will not count this branch even though it's executed in a code example"
+        end
 
-          # This supports should_exist > target.exists? in the old world.
-          # We should consider deprecating that ability as in the new world
-          # you can't write "should exist" unless you have your own custom matcher.
-          begin
-            return @result = actual.__send__(present_tense_predicate, *@args)
-          rescue
-            raise predicate_error
-          end
-        else
-          return match_or_compare
+        begin
+          return @result = actual.__send__(present_tense_predicate, *@args)
+        rescue NameError
+          raise predicate_missing_error
         end
       end
       
       def failure_message
-        return "expected #{@comparison}#{expected}, got #{@actual.inspect}" unless handling_predicate?
-        return "expected #{predicate}#{args_to_s} to return true, got #{@result.inspect}"
+        handling_predicate? ?
+          "expected #{predicate}#{args_to_s} to return true, got #{@result.inspect}" :
+          "expected #{@comparison_method} #{expected}, got #{@actual.inspect}".gsub('  ',' ')
       end
       
       def negative_failure_message
-        return "expected not #{expected}, got #{@actual.inspect}" unless handling_predicate?
-        return "expected #{predicate}#{args_to_s} to return false, got #{@result.inspect}"
-      end
-      
-      def expected
-        return "if to be satisfied" if @expected == :satisfy_if
-        return true if @expected == :true
-        return false if @expected == :false
-        return "nil" if @expected == :nil
-        return @expected.inspect
-      end
-      
-      def match_or_compare
-        return @actual ? true : false if @expected == :satisfy_if
-        return @actual == true if @expected == :true
-        return @actual == false if @expected == :false
-        return @actual.nil? if @expected == :nil
-        return @actual < @expected if @less_than
-        return @actual <= @expected if @less_than_or_equal
-        return @actual >= @expected if @greater_than_or_equal
-        return @actual > @expected if @greater_than
-        return @actual == @expected if @double_equal
-        return @actual === @expected if @triple_equal
-        return @actual.equal?(@expected)
-      end
-      
-      def ==(expected)
-        @prefix = "be "
-        @double_equal = true
-        @comparison = "== "
-        @expected = expected
-        self
-      end
-
-      def ===(expected)
-        @prefix = "be "
-        @triple_equal = true
-        @comparison = "=== "
-        @expected = expected
-        self
-      end
-
-      def <(expected)
-        @prefix = "be "
-        @less_than = true
-        @comparison = "< "
-        @expected = expected
-        self
-      end
-
-      def <=(expected)
-        @prefix = "be "
-        @less_than_or_equal = true
-        @comparison = "<= "
-        @expected = expected
-        self
-      end
-
-      def >=(expected)
-        @prefix = "be "
-        @greater_than_or_equal = true
-        @comparison = ">= "
-        @expected = expected
-        self
-      end
-
-      def >(expected)
-        @prefix = "be "
-        @greater_than = true
-        @comparison = "> "
-        @expected = expected
-        self
+        if handling_predicate?
+          "expected #{predicate}#{args_to_s} to return false, got #{@result.inspect}"
+        else
+          message = <<-MESSAGE
+'should_not be #{@comparison_method} #{expected}' not only FAILED,
+it reads really poorly.
+          MESSAGE
+          
+          raise message << ([:===,:==].include?(@comparison_method) ?
+            "Why don't you try expressing it without the \"be\"?" :
+            "Why don't you try expressing it in the positive?")
+        end
       end
       
       def description
-        "#{prefix_to_sentence}#{comparison}#{expected_to_sentence}#{args_to_sentence}"
+        "#{prefix_to_sentence}#{comparison} #{expected_to_sentence}#{args_to_sentence}".gsub(/\s+/,' ')
+      end
+
+      [:==, :<, :<=, :>=, :>, :===].each do |method|
+        define_method method do |expected|
+          compare_to(expected, :using => method)
+          self
+        end
       end
 
       private
+        def match_or_compare(actual)
+          case @expected
+          when TrueClass
+            @actual
+          else
+            @actual.__send__(comparison_method, @expected)
+          end
+        end
+      
+        def comparison_method
+          @comparison_method || :equal?
+        end
+      
+        def expected
+          @expected
+        end
+
+        def compare_to(expected, opts)
+          @expected, @comparison_method = expected, opts[:using]
+        end
+
+        def set_expected(expected)
+          Symbol === expected ? parse_expected(expected) : expected
+        end
+        
         def parse_expected(expected)
-          if Symbol === expected
-            @handling_predicate = true
-            ["be_an_","be_a_","be_"].each do |prefix|
-              if expected.starts_with?(prefix)
-                @prefix = prefix
-                return "#{expected.to_s.sub(@prefix,"")}".to_sym
+          ["be_an_","be_a_","be_"].each do |prefix|
+            handling_predicate!
+            if expected.starts_with?(prefix)
+              set_prefix(prefix)
+              expected = expected.to_s.sub(prefix,"")
+              [true, false, nil].each do |val|
+                return val if val.to_s == expected
               end
+              return expected.to_sym
             end
           end
-          @prefix = ""
-          return expected
+        end
+        
+        def set_prefix(prefix)
+          @prefix = prefix
+        end
+        
+        def prefix
+          @prefix
+        end
+
+        def handling_predicate!
+          @handling_predicate = true
         end
         
         def handling_predicate?
-          return false if [:true, :false, :nil].include?(@expected)
+          return false if [true, false, nil].include?(expected)
           return @handling_predicate
         end
 
@@ -149,21 +124,27 @@
         end
         
         def args_to_s
-          return "" if @args.empty?
-          inspected_args = @args.collect{|a| a.inspect}
-          return "(#{inspected_args.join(', ')})"
+          @args.empty? ? "" : parenthesize(inspected_args.join(', '))
+        end
+        
+        def parenthesize(string)
+          return "(#{string})"
+        end
+        
+        def inspected_args
+          @args.collect{|a| a.inspect}
         end
         
         def comparison
-          @comparison
+          @comparison_method.nil? ? " " : "be #{@comparison_method.to_s} "
         end
         
         def expected_to_sentence
-          split_words(@expected)
+          split_words(expected)
         end
         
         def prefix_to_sentence
-          split_words(@prefix)
+          split_words(prefix)
         end
 
         def split_words(sym)
@@ -184,7 +165,6 @@
     end
  
     # :call-seq:
-    #   should be
     #   should be_true
     #   should be_false
     #   should be_nil
@@ -192,7 +172,7 @@
     #   should_not be_nil
     #   should_not be_arbitrary_predicate(*args)
     #
-    # Given true, false, or nil, will pass if actual is
+    # Given true, false, or nil, will pass if actual value is
     # true, false or nil (respectively). Given no args means
     # the caller should satisfy an if condition (to be or not to be). 
     #
@@ -206,7 +186,6 @@
     #
     # == Examples 
     #
-    #   target.should be
     #   target.should be_true
     #   target.should be_false
     #   target.should be_nil

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/be_close.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/be_close.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/be_close.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/be_close.rb Wed Dec 10 17:34:18 2008
@@ -1,26 +1,6 @@
 module Spec
   module Matchers
 
-    class BeClose #:nodoc:
-      def initialize(expected, delta)
-        @expected = expected
-        @delta = delta
-      end
-      
-      def matches?(actual)
-        @actual = actual
-        (@actual - @expected).abs < @delta
-      end
-      
-      def failure_message
-        "expected #{@expected} +/- (< #{@delta}), got #{@actual}"
-      end
-      
-      def description
-        "be close to #{@expected} (within +- #{@delta})"
-      end
-    end
-    
     # :call-seq:
     #   should be_close(expected, delta)
     #   should_not be_close(expected, delta)
@@ -31,7 +11,11 @@
     #
     #   result.should be_close(3.0, 0.5)
     def be_close(expected, delta)
-      Matchers::BeClose.new(expected, delta)
+      simple_matcher do |actual, matcher|
+        matcher.failure_message = "expected #{expected} +/- (< #{delta}), got #{actual}"
+        matcher.description = "be close to #{expected} (within +- #{delta})"
+        (actual - expected).abs < delta
+      end
     end
   end
 end

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/change.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/change.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/change.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/change.rb Wed Dec 10 17:34:18 2008
@@ -4,60 +4,60 @@
     #Based on patch from Wilson Bilkovich
     class Change #:nodoc:
       def initialize(receiver=nil, message=nil, &block)
-        @receiver = receiver
-        @message = message
-        @block = block
+        @message = message || "result"
+        @value_proc = block || lambda {
+          receiver.__send__(message)
+        }
       end
       
-      def matches?(target, &block)
-        if block
-          raise MatcherError.new(<<-EOF
-block passed to should or should_not change must use {} instead of do/end
-EOF
-)
-        end
-        @target = target
-        execute_change
-        return false if @from && (@from != @before)
-        return false if @to && (@to != @after)
+      def matches?(event_proc)
+        raise_block_syntax_error if block_given?
+        
+        @before = evaluate_value_proc
+        event_proc.call
+        @after = evaluate_value_proc
+        
+        return false if @from unless @from == @before
+        return false if @to unless @to == @after
         return (@before + @amount == @after) if @amount
         return ((@after - @before) >= @minimum) if @minimum
         return ((@after - @before) <= @maximum) if @maximum        
         return @before != @after
       end
       
-      def execute_change
-        @before = @block.nil? ? @receiver.send(@message) : @block.call
-        @target.call
-        @after = @block.nil? ? @receiver.send(@message) : @block.call
+      def raise_block_syntax_error
+        raise MatcherError.new(<<-MESSAGE
+block passed to should or should_not change must use {} instead of do/end
+MESSAGE
+        )
+      end
+      
+      def evaluate_value_proc
+        @value_proc.call
       end
       
       def failure_message
         if @to
-          "#{result} should have been changed to #{@to.inspect}, but is now #{@after.inspect}"
+          "#{@message} should have been changed to #{@to.inspect}, but is now #{@after.inspect}"
         elsif @from
-          "#{result} should have initially been #{@from.inspect}, but was #{@before.inspect}"
+          "#{@message} should have initially been #{@from.inspect}, but was #{@before.inspect}"
         elsif @amount
-          "#{result} should have been changed by #{@amount.inspect}, but was changed by #{actual_delta.inspect}"
+          "#{@message} should have been changed by #{@amount.inspect}, but was changed by #{actual_delta.inspect}"
         elsif @minimum
-          "#{result} should have been changed by at least #{@minimum.inspect}, but was changed by #{actual_delta.inspect}"
+          "#{@message} should have been changed by at least #{@minimum.inspect}, but was changed by #{actual_delta.inspect}"
         elsif @maximum
-          "#{result} should have been changed by at most #{@maximum.inspect}, but was changed by #{actual_delta.inspect}"
+          "#{@message} should have been changed by at most #{@maximum.inspect}, but was changed by #{actual_delta.inspect}"
         else
-          "#{result} should have changed, but is still #{@before.inspect}"
+          "#{@message} should have changed, but is still #{@before.inspect}"
         end
       end
       
-      def result
-        @message || "result"
-      end
-      
       def actual_delta
         @after - @before
       end
       
       def negative_failure_message
-        "#{result} should not have changed, but did change from #{@before.inspect} to #{@after.inspect}"
+        "#{@message} should not have changed, but did change from #{@before.inspect} to #{@after.inspect}"
       end
       
       def by(amount)
@@ -125,20 +125,24 @@
     #     employee.develop_great_new_social_networking_app
     #   }.should change(employee, :title).from("Mail Clerk").to("CEO")
     #
-    # Evaluates +receiver.message+ or +block+ before and
-    # after it evaluates the c object (generated by the lambdas in the examples above).
-    #
-    # Then compares the values before and after the +receiver.message+ and
-    # evaluates the difference compared to the expected difference.
+    # Evaluates <tt>receiver.message</tt> or <tt>block</tt> before and after
+    # it evaluates the c object (generated by the lambdas in the examples
+    # above).
+    #
+    # Then compares the values before and after the <tt>receiver.message</tt>
+    # and evaluates the difference compared to the expected difference.
+    #
+    # == WARNING
+    # <tt>should_not change</tt> only supports the form with no
+    # subsequent calls to <tt>by</tt>, <tt>by_at_least</tt>,
+    # <tt>by_at_most</tt>, <tt>to</tt> or <tt>from</tt>.
+    #
+    # blocks passed to <tt>should</tt> <tt>change</tt> and <tt>should_not</tt>
+    # <tt>change</tt> must use the <tt>{}</tt> form (<tt>do/end</tt> is not
+    # supported).
     #
-    # == Warning
-    # +should_not+ +change+ only supports the form with no subsequent calls to
-    # +by+, +by_at_least+, +by_at_most+, +to+ or +from+.
-    #
-    # blocks passed to +should+ +change+ and +should_not+ +change+
-    # must use the <tt>{}</tt> form (<tt>do/end</tt> is not supported)
-    def change(target=nil, message=nil, &block)
-      Matchers::Change.new(target, message, &block)
+    def change(receiver=nil, message=nil, &block)
+      Matchers::Change.new(receiver, message, &block)
     end
   end
 end

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/eql.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/eql.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/eql.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/eql.rb Wed Dec 10 17:34:18 2008
@@ -1,29 +1,6 @@
 module Spec
   module Matchers
   
-    class Eql #:nodoc:
-      def initialize(expected)
-        @expected = expected
-      end
-  
-      def matches?(actual)
-        @actual = actual
-        @actual.eql?(@expected)
-      end
-
-      def failure_message
-        return "expected #{@expected.inspect}, got #{@actual.inspect} (using .eql?)", @expected, @actual
-      end
-      
-      def negative_failure_message
-        return "expected #{@actual.inspect} not to equal #{@expected.inspect} (using .eql?)", @expected, @actual
-      end
-
-      def description
-        "eql #{@expected.inspect}"
-      end
-    end
-    
     # :call-seq:
     #   should eql(expected)
     #   should_not eql(expected)
@@ -37,7 +14,12 @@
     #   5.should eql(5)
     #   5.should_not eql(3)
     def eql(expected)
-      Matchers::Eql.new(expected)
+      simple_matcher do |actual, matcher|
+        matcher.failure_message          = "expected #{expected.inspect}, got #{actual.inspect} (using .eql?)", expected, actual
+        matcher.negative_failure_message = "expected #{actual.inspect} not to equal #{expected.inspect} (using .eql?)", expected, actual
+        matcher.description              = "eql #{expected.inspect}"
+        actual.eql?(expected)
+      end
     end
   end
 end

Modified: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/equal.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/equal.rb?rev=725524&r1=725523&r2=725524&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/equal.rb (original)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/equal.rb Wed Dec 10 17:34:18 2008
@@ -1,34 +1,11 @@
 module Spec
   module Matchers
   
-    class Equal #:nodoc:
-      def initialize(expected)
-        @expected = expected
-      end
-  
-      def matches?(actual)
-        @actual = actual
-        @actual.equal?(@expected)
-      end
-
-      def failure_message
-        return "expected #{@expected.inspect}, got #{@actual.inspect} (using .equal?)", @expected, @actual
-      end
-
-      def negative_failure_message
-        return "expected #{@actual.inspect} not to equal #{@expected.inspect} (using .equal?)", @expected, @actual
-      end
-      
-      def description
-        "equal #{@expected.inspect}"
-      end
-    end
-    
     # :call-seq:
     #   should equal(expected)
     #   should_not equal(expected)
     #
-    # Passes if actual and expected are the same object (object identity).
+    # Passes if given and expected are the same object (object identity).
     #
     # See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more information about equality in Ruby.
     #
@@ -37,7 +14,12 @@
     #   5.should equal(5) #Fixnums are equal
     #   "5".should_not equal("5") #Strings that look the same are not the same object
     def equal(expected)
-      Matchers::Equal.new(expected)
+      simple_matcher do |actual, matcher|
+        matcher.failure_message          = "expected #{expected.inspect}, got #{actual.inspect} (using .equal?)", expected, actual
+        matcher.negative_failure_message = "expected #{actual.inspect} not to equal #{expected.inspect} (using .equal?)", expected, actual
+        matcher.description              = "equal #{expected.inspect}"
+        actual.equal?(expected)
+      end
     end
   end
 end

Added: incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/errors.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/errors.rb?rev=725524&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/errors.rb (added)
+++ incubator/olio/webapp/rails/trunk/vendor/plugins/rspec/lib/spec/matchers/errors.rb Wed Dec 10 17:34:18 2008
@@ -0,0 +1,5 @@
+module Spec
+  module Matchers
+    class MatcherError < StandardError; end
+  end
+end
\ No newline at end of file