Changeset 804

Show
Ignore:
Timestamp:
04/18/08 15:46:48 (4 months ago)
Author:
seancribbs
Message:

Merge branch 'master' of git://github.com/jfrench/radiant

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/radiant/vendor/plugins/rspec/CHANGES

    r728 r804  
    11== Version 1.1.4 (trunk) 
    22 
    3 * Applied patch from Coda Hale to get rspec calling autotest's :red hook. Closes #279. 
     3Maintenance release. 
     4Note: we've removed the metaclass method from Object. There were some generated specs that 
     5used it, and they will now break. Just replace the metaclass call with (class << self; self; end) 
     6and all will be well. 
     7 
     8* Fixed bug in which session object in example was not the same instance used in the controller. Closes #331.  
     9* Added stub_model method which creates a real model instance with :id stubbed and data access prohibited. 
     10* Applied patch from Antti Tarvainen to fix bug where heckle runs rspec runs heckle runs rspec etc. Closes #280. 
     11* Applied patch from Zach Dennis to merge :steps functionality to :steps_for. Closes #324. 
     12* Applied patch from Pat Maddox to handle redirect_to w/ SSL. Closes #320. 
     13* Applied patch from Ryan Davis to add eval of block passed to raise_error matcher. Closes #321. 
     14* alias :context :describe in example_group_methods. Closes #312. 
     15* Applied patch from Ben Mabey to make the Story runner exit with a non-0 exit code on failing stories. Closes #228. 
     16* Added #helper and #assigns to helper specs. 
     17* Applied patch from Bryan Helmkamp to tweak format of generated spec.opts to be more obvious. Closes #162. 
     18* Tweaked list of exceptions (ignores) for autotest with rspec_on_rails. 
     19* Applied patch from Coda Hale to get the :red hook called in autotest. Closes #279. 
     20* Applied patch from Patrick Ritchie to support --drb in spec.opts. Closes #274, #293. 
     21* Applied patch from Rick Olson to get rspec_on_rails working with rails edge (>= 8862) 
     22* Moved metaclass method from Object to an internal module which gets included where it is needed. 
     23* Applied patch from Dayo Esho: and_yield clobbers return value from block. Closes #217. 
     24* Applied patch from Bob Cotton:  ExampleGroupFactory.default resets previously registered types. Closes #222. 
     25* Applied patch from Mike Williams to support the lib directory in rails apps with the Textmate Alternate File command. Closes #276. 
     26* ExampleGroupMethods#xspecify aliases #xit 
     27* A SharedExampleGroup can be created within another ExampleGroup. 
     28* Applied patch from Bob Cotton: Nested ExampleGroups do not have a spec_path. Closes #224. 
     29* Applied patch from Wincent Colaiuta to invert sense of "spec --diff". Closes #281. 
     30* Allow any type of render in view specs. Closes #57. 
    431* Applied patch from Ian White to get rspec working with edge rails (8804). Closes #271. 
    532 
  • trunk/radiant/vendor/plugins/rspec/README

    r717 r804  
    6666* The Spec::Rake::SpecTask needs RCov if RCov is enabled in the task. 
    6767 
    68 See http://rspec.rubyforge.org for further documentation. 
     68See http://rspec.info for further documentation. 
    6969 
    7070== Contributing 
  • trunk/radiant/vendor/plugins/rspec/examples/stories/calculator.rb

    r606 r804  
    2828  I want to add numbers 
    2929  So that I can count some beans 
    30 }, :steps => steps do 
     30}, :steps_for => steps do 
    3131  Scenario "2 + 3" do 
    3232    Given "an addend of 2" 
  • trunk/radiant/vendor/plugins/rspec/lib/autotest/rspec.rb

    r728 r804  
    2323    super 
    2424    self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m 
    25     self.completed_re = /\Z/ # FIX: some sort of summary line at the end? 
     25    self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m 
    2626  end 
    2727   
    2828  def consolidate_failures(failed) 
    29     filters = Hash.new { |h,k| h[k] = [] } 
     29    filters = new_hash_of_arrays 
    3030    failed.each do |spec, trace| 
    31       if trace =~ /\n(.*):[\d]+:\Z
    32         filters[$1] << spec 
     31      if trace =~ /\n(\.\/)?(.*\.rb):[\d]+:\Z?
     32        filters[$2] << spec 
    3333      end 
    3434    end 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/example/example_group_factory.rb

    r717 r804  
    2424          old = @example_group_types 
    2525          @example_group_types = Hash.new(example_group_class) 
    26           @example_group_types.merge(old) if old 
     26          @example_group_types.merge!(old) if old 
    2727        end 
    2828 
     
    3737        def create_example_group(*args, &block) 
    3838          opts = Hash === args.last ? args.last : {} 
    39           if opts[:shared] 
    40             SharedExampleGroup.new(*args, &block) 
    41           else 
    42             superclass = determine_superclass(opts) 
    43             superclass.describe(*args, &block) 
    44           end 
     39          superclass = determine_superclass(opts) 
     40          superclass.describe(*args, &block) 
    4541        end 
    4642 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/example/example_group_methods.rb

    r717 r804  
    3535      # 
    3636      def describe(*args, &example_group_block) 
     37        args << {} unless Hash === args.last 
    3738        if example_group_block 
    38           self.subclass("Subclass") do 
    39             describe(*args) 
    40             module_eval(&example_group_block) 
     39          params = args.last 
     40          params[:spec_path] = eval("caller(0)[1]", example_group_block) unless params[:spec_path] 
     41          if params[:shared] 
     42            SharedExampleGroup.new(*args, &example_group_block) 
     43          else 
     44            self.subclass("Subclass") do 
     45              describe(*args) 
     46              module_eval(&example_group_block) 
     47            end 
    4148          end 
    4249        else 
     
    4653        end 
    4754      end 
     55      alias :context :describe 
    4856 
    4957      # Use this to pull in examples from shared example groups. 
     
    108116        Kernel.warn("Example disabled: #{description}") 
    109117      end 
     118      alias_method :xspecify, :xit 
    110119 
    111120      def run 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/example/example_methods.rb

    r717 r804  
    6464        @_defined_description || @_matcher_description || "NO NAME" 
    6565      end 
     66 
     67      def __full_description 
     68        "#{self.class.description} #{self.description}" 
     69      end 
    6670       
    6771      def set_instance_variables_from_hash(ivars) 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/expectations/differs/default.rb

    r606 r804  
    1818 
    1919        # This is snagged from diff/lcs/ldiff.rb (which is a commandline tool) 
    20         def diff_as_string(data_old, data_new
     20        def diff_as_string(data_new, data_old
    2121          data_old = data_old.split(/\n/).map! { |e| e.chomp } 
    2222          data_new = data_new.split(/\n/).map! { |e| e.chomp } 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/extensions.rb

    r717 r804  
    22require 'spec/extensions/class' 
    33require 'spec/extensions/main' 
     4require 'spec/extensions/metaclass' 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/extensions/object.rb

    r606 r804  
    44    return args, options 
    55  end 
    6  
    7   def metaclass 
    8     class << self; self; end 
    9   end 
    106end 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/matchers/has.rb

    r606 r804  
    99       
    1010      def matches?(target) 
    11         @target = target 
    12         begin 
    13           return target.send(predicate, *@args) 
    14         rescue => @error 
    15           # This clause should be empty, but rcov will not report it as covered 
    16           # unless something (anything) is executed within the clause 
    17           rcov_error_report = "http://eigenclass.org/hiki.rb?rcov-0.8.0" 
    18         end 
    19         return false 
     11        target.send(predicate, *@args) 
    2012      end 
    2113       
    2214      def failure_message 
    23         raise @error if @error 
    2415        "expected ##{predicate}(#{@args[0].inspect}) to return true, got false" 
    2516      end 
    2617       
    2718      def negative_failure_message 
    28         raise @error if @error 
    2919        "expected ##{predicate}(#{@args[0].inspect}) to return false, got true" 
    3020      end 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/matchers/raise_error.rb

    r717 r804  
    11module Spec 
    22  module Matchers 
    3      
    43    class RaiseError #:nodoc: 
    5       def initialize(error_or_message=Exception, message=nil) 
    6         if String === error_or_message 
    7           @expected_error = Exception 
    8           @expected_message = error_or_message 
     4      def initialize(error_or_message=Exception, message=nil, &block) 
     5        @block = block 
     6        case error_or_message 
     7        when String, Regexp 
     8          @expected_error, @expected_message = Exception, error_or_message 
    99        else 
    10           @expected_error = error_or_message 
    11           @expected_message = message 
     10          @expected_error, @expected_message = error_or_message, message 
    1211        end 
    1312      end 
    14        
     13 
    1514      def matches?(proc) 
    1615        @raised_expected_error = false 
    17         @raised_other = false 
     16        @with_expected_message = false 
     17        @eval_block = false 
     18        @eval_block_passed = false 
    1819        begin 
    1920          proc.call 
    2021        rescue @expected_error => @actual_error 
    21           if @expected_message.nil? 
    22             @raised_expected_error = true 
    23           else 
    24             verify_message 
    25           end 
     22          @raised_expected_error = true 
     23          @with_expected_message = verify_message 
    2624        rescue Exception => @actual_error 
    27           @raised_other = true 
    28         ensure 
    29           return @raised_expected_error 
     25          # This clause should be empty, but rcov will not report it as covered 
     26          # unless something (anything) is executed within the clause 
     27          rcov_error_report = "http://eigenclass.org/hiki.rb?rcov-0.8.0" 
     28        end 
     29 
     30        unless negative_expectation? 
     31          eval_block if @raised_expected_error && @with_expected_message && @block 
     32        end 
     33      ensure 
     34        return (@raised_expected_error && @with_expected_message) ? (@eval_block ? @eval_block_passed : true) : false 
     35      end 
     36       
     37      def eval_block 
     38        @eval_block = true 
     39        begin 
     40          @block[@actual_error] 
     41          @eval_block_passed = true 
     42        rescue Exception => err 
     43          @actual_error = err 
    3044        end 
    3145      end 
     
    3347      def verify_message 
    3448        case @expected_message 
     49        when nil 
     50          return true 
    3551        when Regexp 
    36           if @expected_message =~ @actual_error.message 
    37             @raised_expected_error = true 
    38           else 
    39             @raised_other = true 
    40           end 
     52          return @expected_message =~ @actual_error.message 
    4153        else 
    42           if @expected_message == @actual_error.message 
    43             @raised_expected_error = true 
    44           else 
    45             @raised_other = true 
    46           end 
     54          return @expected_message == @actual_error.message 
    4755        end 
    4856      end 
    4957       
    5058      def failure_message 
    51         return "expected #{expected_error}#{actual_error}" if @raised_other || !@raised_expected_error 
     59        if @eval_block 
     60          return @actual_error.message 
     61        else 
     62          return "expected #{expected_error}#{actual_error}" 
     63        end 
    5264      end 
    5365 
     
    7587          @actual_error.nil? ? " but nothing was raised" : ", got #{@actual_error.inspect}" 
    7688        end 
     89         
     90        def negative_expectation? 
     91          # YES - I'm a bad person... help me find a better way - ryand 
     92          caller.first(3).find { |s| s =~ /should_not/ } 
     93        end 
    7794    end 
    7895     
     
    8299    #   should raise_error(NamedError, String) 
    83100    #   should raise_error(NamedError, Regexp) 
     101    #   should raise_error() { |error| ... } 
     102    #   should raise_error(NamedError) { |error| ... } 
     103    #   should raise_error(NamedError, String) { |error| ... } 
     104    #   should raise_error(NamedError, Regexp) { |error| ... } 
    84105    #   should_not raise_error() 
    85106    #   should_not raise_error(NamedError) 
     
    91112    # With a named error and messsage specified as a String, matches only if both match. 
    92113    # With a named error and messsage specified as a Regexp, matches only if both match. 
     114    # Pass an optional block to perform extra verifications on the exception matched 
    93115    # 
    94116    # == Examples 
     
    96118    #   lambda { do_something_risky }.should raise_error 
    97119    #   lambda { do_something_risky }.should raise_error(PoorRiskDecisionError) 
     120    #   lambda { do_something_risky }.should raise_error(PoorRiskDecisionError) { |error| error.data.should == 42 } 
    98121    #   lambda { do_something_risky }.should raise_error(PoorRiskDecisionError, "that was too risky") 
    99122    #   lambda { do_something_risky }.should raise_error(PoorRiskDecisionError, /oo ri/) 
     
    103126    #   lambda { do_something_risky }.should_not raise_error(PoorRiskDecisionError, "that was too risky") 
    104127    #   lambda { do_something_risky }.should_not raise_error(PoorRiskDecisionError, /oo ri/) 
    105     def raise_error(error=Exception, message=nil
    106       Matchers::RaiseError.new(error, message
     128    def raise_error(error=Exception, message=nil, &block
     129      Matchers::RaiseError.new(error, message, &block
    107130    end 
    108131  end 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/mocks/argument_constraint_matchers.rb

    r606 r804  
    22  module Mocks 
    33    module ArgumentConstraintMatchers 
    4  
     4       
    55      # Shortcut for creating an instance of Spec::Mocks::DuckTypeArgConstraint 
    66      def duck_type(*args) 
     
    2020      end 
    2121       
     22      def hash_including(expected={}) 
     23        HashIncludingConstraint.new(expected) 
     24      end 
     25       
    2226      def no_args 
    2327        NoArgsConstraint.new 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/mocks/argument_expectation.rb

    r606 r804  
    109109      end 
    110110    end 
     111     
     112    class HashIncludingConstraint 
     113      def initialize(expected) 
     114        @expected = expected 
     115      end 
     116       
     117      def ==(actual) 
     118        @expected.each do | key, value | 
     119          # check key for case that value evaluates to nil 
     120          return false unless actual.has_key?(key) && actual[key] == value 
     121        end 
     122        true 
     123      rescue NoMethodError => ex 
     124        return false 
     125      end 
     126       
     127      def matches?(value) 
     128        self == value 
     129      end 
     130       
     131      def description 
     132        "hash_including(#{@expected.inspect.sub(/^\{/,"").sub(/\}$/,"")})" 
     133      end 
     134       
     135    end 
     136     
    111137 
    112138    class ArgumentExpectation 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/mocks/message_expectation.rb

    r717 r804  
    113113          @error_generator.raise_missing_block_error @args_to_yield 
    114114        end 
     115        value = nil 
    115116        @args_to_yield.each do |args_to_yield_this_time| 
    116117          if block.arity > -1 && args_to_yield_this_time.length != block.arity 
    117118            @error_generator.raise_wrong_arity_error args_to_yield_this_time, block.arity 
    118119          end 
    119           block.call(*args_to_yield_this_time) 
    120         end 
     120          value = block.call(*args_to_yield_this_time) 
     121        end 
     122        value 
    121123      end 
    122124       
  • trunk/radiant/vendor/plugins/rspec/lib/spec/mocks/proxy.rb

    r606 r804  
    8989       
    9090      def define_expected_method(sym) 
    91         if target_responds_to?(sym) && !metaclass.method_defined?(munge(sym)) 
     91        if target_responds_to?(sym) && !target_metaclass.method_defined?(munge(sym)) 
    9292          munged_sym = munge(sym) 
    93           metaclass.instance_eval do 
     93          target_metaclass.instance_eval do 
    9494            alias_method munged_sym, sym if method_defined?(sym.to_s) 
    9595          end 
     
    9797        end 
    9898         
    99         metaclass_eval(<<-EOF, __FILE__, __LINE__) 
     99        target_metaclass.class_eval(<<-EOF, __FILE__, __LINE__) 
    100100          def #{sym}(*args, &block) 
    101101            __mock_proxy.message_received :#{sym}, *args, &block 
     
    126126      end 
    127127 
    128       def metaclass_eval(str, filename, lineno) 
    129         metaclass.class_eval(str, filename, lineno) 
    130       end 
    131        
    132       def metaclass 
    133         (class << @target; self; end) 
     128      def target_metaclass 
     129        class << @target; self; end 
    134130      end 
    135131 
     
    143139        @proxied_methods.each do |sym| 
    144140          munged_sym = munge(sym) 
    145           metaclass.instance_eval do 
     141          target_metaclass.instance_eval do 
    146142            if method_defined?(munged_sym.to_s) 
    147143              alias_method sym, munged_sym 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/runner/formatter/base_formatter.rb

    r717 r804  
    2020 
    2121        # This method is invoked at the beginning of the execution of each example_group. 
    22         # +name+ is the name of the example_group and +first+ is true if it is the 
    23         # first example_group - otherwise it's false. 
     22        # +example_group+ is the example_group. 
    2423        # 
    2524        # The next method to be invoked after this is #example_failed or #example_finished 
     
    4746        # +message+ is the message from the ExamplePendingError, if it exists, or the 
    4847        # default value of "Not Yet Implemented" 
    49         def example_pending(example_group_description, example, message) 
     48        def example_pending(example, message) 
    5049        end 
    5150 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb

    r717 r804  
    2727        end 
    2828         
    29         def example_pending(example_group_description, example, message) 
    30           @pending_examples << ["#{example_group_description} #{example.description}", message] 
     29        def example_pending(example, message) 
     30          @pending_examples << [example.__full_description, message] 
    3131        end 
    3232         
  • trunk/radiant/vendor/plugins/rspec/lib/spec/runner/formatter/failing_example_groups_formatter.rb

    r717 r804  
    55    module Formatter 
    66      class FailingExampleGroupsFormatter < BaseTextFormatter 
     7        attr_reader :example_group 
    78        def add_example_group(example_group) 
    89          super 
    9           @example_group_description_parts = example_group.description_parts 
     10          @example_group = example_group 
    1011        end 
    1112 
    1213        def example_failed(example, counter, failure) 
    13           if @example_group_description_parts 
    14             description_parts = @example_group_description_parts.collect do |description| 
     14          if @example_group 
     15            description_parts = @example_group.description_parts.collect do |description| 
    1516              description =~ /(.*) \(druby.*\)$/ ? $1 : description 
    1617            end 
    1718            @output.puts ::Spec::Example::ExampleGroupMethods.description_text(*description_parts) 
     19 
    1820            @output.flush 
    19             @example_group_description_parts = nil 
     21            @example_group = nil 
    2022          end 
    2123        end 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/runner/formatter/html_formatter.rb

    r717 r804  
    8282        end 
    8383 
    84         def example_pending(example_group_description, example, message) 
     84        def example_pending(example, message) 
    8585          @output.puts "    <script type=\"text/javascript\">makeYellow('rspec-header');</script>" unless @header_red 
    8686          @output.puts "    <script type=\"text/javascript\">makeYellow('example_group_#{current_example_group_number}');</script>" unless @example_group_red 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/runner/formatter/progress_bar_formatter.rb

    r717 r804  
    1515        end 
    1616       
    17         def example_pending(example_group_description, example, message) 
     17        def example_pending(example, message) 
    1818          super 
    1919          @output.print yellow('P') 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/runner/formatter/specdoc_formatter.rb

    r717 r804  
    2929        end 
    3030         
    31         def example_pending(example_group_description, example, message) 
     31        def example_pending(example, message) 
    3232          super 
    3333          output.puts yellow("- #{example.description} (PENDING: #{message})") 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/runner/option_parser.rb

    r717 r804  
    142142        option_file_args = IO.readlines(options_file).map {|l| l.chomp.split " "}.flatten 
    143143        @argv.push(*option_file_args) 
     144        # TODO - this is a brute force solution to http://rspec.lighthouseapp.com/projects/5645/tickets/293. 
     145        # Let's look for a cleaner way. Might not be one. But let's look. If not, perhaps 
     146        # this can be moved to a different method to indicate the special handling for drb? 
     147        parse_drb(@argv) 
    144148      end 
    145149 
     
    171175      end 
    172176 
    173       def parse_drb 
     177      def parse_drb(argv = nil) 
     178        argv ||= @options.argv # TODO - see note about about http://rspec.lighthouseapp.com/projects/5645/tickets/293 
    174179        is_drb = false 
    175         argv = @options.argv 
    176180        is_drb ||= argv.delete(OPTIONS[:drb][0]) 
    177181        is_drb ||= argv.delete(OPTIONS[:drb][1]) 
  • trunk/radiant/vendor/plugins/rspec/lib/spec/runner/options.rb

    r717 r804  
    178178 
    179179      def number_of_examples 
    180         @example_groups.inject(0) do |sum, example_group| 
    181           sum + example_group.number_of_examples 
    182         end 
     180        total = 0 
     181        @example_groups.each do |example_group| 
     182          total += example_group.number_of_examples 
     183        end 
     184        total 
    183185      end 
    184186