rspec 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +78 -1
 - data/EXAMPLES.rd +8 -5
 - data/README +1 -0
 - data/Rakefile +1 -1
 - data/examples/pending_example.rb +20 -0
 - data/lib/autotest/rspec.rb +46 -18
 - data/lib/spec/dsl.rb +1 -0
 - data/lib/spec/dsl/behaviour.rb +37 -27
 - data/lib/spec/dsl/behaviour_callbacks.rb +4 -0
 - data/lib/spec/dsl/behaviour_eval.rb +27 -16
 - data/lib/spec/dsl/behaviour_factory.rb +2 -2
 - data/lib/spec/dsl/composite_proc_builder.rb +9 -4
 - data/lib/spec/dsl/configuration.rb +20 -4
 - data/lib/spec/dsl/description.rb +7 -0
 - data/lib/spec/dsl/errors.rb +9 -0
 - data/lib/spec/dsl/example.rb +18 -10
 - data/lib/spec/matchers/have.rb +10 -13
 - data/lib/spec/matchers/operator_matcher.rb +3 -3
 - data/lib/spec/matchers/raise_error.rb +8 -3
 - data/lib/spec/mocks/error_generator.rb +1 -1
 - data/lib/spec/mocks/message_expectation.rb +11 -0
 - data/lib/spec/mocks/methods.rb +9 -5
 - data/lib/spec/mocks/proxy.rb +13 -9
 - data/lib/spec/rake/spectask.rb +80 -38
 - data/lib/spec/runner/backtrace_tweaker.rb +2 -1
 - data/lib/spec/runner/behaviour_runner.rb +37 -16
 - data/lib/spec/runner/formatter/base_formatter.rb +23 -15
 - data/lib/spec/runner/formatter/base_text_formatter.rb +39 -11
 - data/lib/spec/runner/formatter/failing_behaviours_formatter.rb +7 -3
 - data/lib/spec/runner/formatter/failing_examples_formatter.rb +3 -3
 - data/lib/spec/runner/formatter/html_formatter.rb +32 -25
 - data/lib/spec/runner/formatter/progress_bar_formatter.rb +6 -5
 - data/lib/spec/runner/formatter/rdoc_formatter.rb +6 -6
 - data/lib/spec/runner/formatter/specdoc_formatter.rb +7 -6
 - data/lib/spec/runner/option_parser.rb +6 -5
 - data/lib/spec/runner/options.rb +60 -43
 - data/lib/spec/runner/reporter.rb +17 -6
 - data/lib/spec/runner/spec_parser.rb +1 -1
 - data/lib/spec/translator.rb +8 -0
 - data/lib/spec/version.rb +3 -3
 - data/plugins/mock_frameworks/flexmock.rb +14 -18
 - data/plugins/mock_frameworks/mocha.rb +0 -2
 - data/plugins/mock_frameworks/rr.rb +21 -0
 - data/spec/autotest/discover_spec.rb +19 -0
 - data/spec/autotest/rspec_spec.rb +257 -0
 - data/spec/autotest_helper.rb +4 -0
 - data/spec/spec/dsl/behaviour_eval_spec.rb +30 -0
 - data/spec/spec/dsl/behaviour_factory_spec.rb +18 -0
 - data/spec/spec/dsl/behaviour_spec.rb +95 -58
 - data/spec/spec/dsl/composite_proc_builder_spec.rb +0 -13
 - data/spec/spec/dsl/configuration_spec.rb +6 -1
 - data/spec/spec/dsl/description_spec.rb +9 -1
 - data/spec/spec/dsl/example_class_spec.rb +3 -3
 - data/spec/spec/dsl/example_instance_spec.rb +26 -28
 - data/spec/spec/dsl/example_matcher_spec.rb +91 -0
 - data/spec/spec/dsl/shared_behaviour_spec.rb +24 -0
 - data/spec/spec/expectations/extensions/object_spec.rb +2 -2
 - data/spec/spec/expectations/fail_with_spec.rb +2 -2
 - data/spec/spec/matchers/have_spec.rb +1 -1
 - data/spec/spec/matchers/operator_matcher_spec.rb +10 -10
 - data/spec/spec/matchers/raise_error_spec.rb +38 -0
 - data/spec/spec/mocks/argument_expectation_spec.rb +18 -14
 - data/spec/spec/mocks/at_most_spec.rb +1 -1
 - data/spec/spec/mocks/bug_report_11545_spec.rb +31 -0
 - data/spec/spec/mocks/partial_mock_spec.rb +33 -1
 - data/spec/spec/runner/behaviour_runner_spec.rb +72 -49
 - data/spec/spec/runner/command_line_spec.rb +1 -1
 - data/spec/spec/runner/context_matching_spec.rb +10 -10
 - data/spec/spec/runner/drb_command_line_spec.rb +62 -59
 - data/spec/spec/runner/extensions/bug_report_10577_spec.rb +35 -0
 - data/spec/spec/runner/formatter/failing_behaviours_formatter_spec.rb +15 -2
 - data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +3 -3
 - data/spec/spec/runner/formatter/html_formatter_spec.rb +1 -1
 - data/spec/spec/runner/formatter/progress_bar_formatter_dry_run_spec.rb +14 -15
 - data/spec/spec/runner/formatter/progress_bar_formatter_failure_dump_spec.rb +1 -1
 - data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +42 -9
 - data/spec/spec/runner/formatter/rdoc_formatter_spec.rb +40 -40
 - data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +55 -49
 - data/spec/spec/runner/option_parser_spec.rb +16 -15
 - data/spec/spec/runner/options_spec.rb +64 -31
 - data/spec/spec/runner/reporter_spec.rb +67 -15
 - data/spec/spec/spec_classes.rb +9 -1
 - data/spec/spec/translator_spec.rb +48 -0
 - data/spec/spec_helper.rb +5 -2
 - metadata +13 -6
 - data/examples/not_yet_implemented_spec.rb +0 -12
 - data/spec/spec/runner/example_matcher_spec.rb +0 -127
 
| 
         @@ -2,34 +2,28 @@ module Spec 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Runner
         
     | 
| 
       3 
3 
     | 
    
         
             
                class BehaviourRunner
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
                  def initialize(options)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  def initialize(options, arg=nil)
         
     | 
| 
       6 
6 
     | 
    
         
             
                    @behaviours = []
         
     | 
| 
       7 
7 
     | 
    
         
             
                    @options = options
         
     | 
| 
       8 
8 
     | 
    
         
             
                  end
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                  def add_behaviour(behaviour)
         
     | 
| 
       11 
     | 
    
         
            -
                    if !specified_examples.nil? && !specified_examples.empty? 
     | 
| 
       12 
     | 
    
         
            -
                      behaviour.retain_examples_matching!(specified_examples) 
     | 
| 
      
 11 
     | 
    
         
            +
                    if !specified_examples.nil? && !specified_examples.empty?
         
     | 
| 
      
 12 
     | 
    
         
            +
                      behaviour.retain_examples_matching!(specified_examples)
         
     | 
| 
       13 
13 
     | 
    
         
             
                    end
         
     | 
| 
       14 
14 
     | 
    
         
             
                    @behaviours << behaviour if behaviour.number_of_examples != 0 && !behaviour.shared?
         
     | 
| 
       15 
15 
     | 
    
         
             
                  end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
                  # Runs all  
     | 
| 
      
 17 
     | 
    
         
            +
                  # Runs all behaviours and returns the number of failures.
         
     | 
| 
       18 
18 
     | 
    
         
             
                  def run(paths, exit_when_done)
         
     | 
| 
       19 
     | 
    
         
            -
                     
     | 
| 
       20 
     | 
    
         
            -
                      paths = find_paths(paths)
         
     | 
| 
       21 
     | 
    
         
            -
                      sorted_paths = sort_paths(paths)
         
     | 
| 
       22 
     | 
    
         
            -
                      load_specs(sorted_paths) 
         
     | 
| 
       23 
     | 
    
         
            -
                    end
         
     | 
| 
       24 
     | 
    
         
            -
                    @options.reporter.start(number_of_examples)
         
     | 
| 
       25 
     | 
    
         
            -
                    behaviours = @options.reverse ? @behaviours.reverse : @behaviours
         
     | 
| 
      
 19 
     | 
    
         
            +
                    prepare!(paths)
         
     | 
| 
       26 
20 
     | 
    
         
             
                    begin
         
     | 
| 
       27 
     | 
    
         
            -
                      run_behaviours 
     | 
| 
      
 21 
     | 
    
         
            +
                      run_behaviours
         
     | 
| 
       28 
22 
     | 
    
         
             
                    rescue Interrupt
         
     | 
| 
       29 
23 
     | 
    
         
             
                    ensure
         
     | 
| 
       30 
     | 
    
         
            -
                       
     | 
| 
      
 24 
     | 
    
         
            +
                      report_end
         
     | 
| 
       31 
25 
     | 
    
         
             
                    end
         
     | 
| 
       32 
     | 
    
         
            -
                    failure_count =  
     | 
| 
      
 26 
     | 
    
         
            +
                    failure_count = report_dump
         
     | 
| 
       33 
27 
     | 
    
         | 
| 
       34 
28 
     | 
    
         
             
                    heckle if(failure_count == 0 && !@options.heckle_runner.nil?)
         
     | 
| 
       35 
29 
     | 
    
         | 
| 
         @@ -39,9 +33,28 @@ module Spec 
     | 
|
| 
       39 
33 
     | 
    
         
             
                    end
         
     | 
| 
       40 
34 
     | 
    
         
             
                    failure_count
         
     | 
| 
       41 
35 
     | 
    
         
             
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
                  
         
     | 
| 
      
 37 
     | 
    
         
            +
                  def report_end
         
     | 
| 
      
 38 
     | 
    
         
            +
                    @options.reporter.end
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
                  
         
     | 
| 
      
 41 
     | 
    
         
            +
                  def report_dump
         
     | 
| 
      
 42 
     | 
    
         
            +
                    @options.reporter.dump
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
                  
         
     | 
| 
      
 45 
     | 
    
         
            +
                  def prepare!(paths)
         
     | 
| 
      
 46 
     | 
    
         
            +
                    unless paths.nil? # It's nil when running single specs with ruby
         
     | 
| 
      
 47 
     | 
    
         
            +
                      paths = find_paths(paths)
         
     | 
| 
      
 48 
     | 
    
         
            +
                      sorted_paths = sort_paths(paths)
         
     | 
| 
      
 49 
     | 
    
         
            +
                      load_specs(sorted_paths) # This will populate @behaviours via callbacks to add_behaviour
         
     | 
| 
      
 50 
     | 
    
         
            +
                    end
         
     | 
| 
      
 51 
     | 
    
         
            +
                    @options.reporter.start(number_of_examples)
         
     | 
| 
      
 52 
     | 
    
         
            +
                    @behaviours.reverse! if @options.reverse
         
     | 
| 
      
 53 
     | 
    
         
            +
                    set_sequence_numbers
         
     | 
| 
      
 54 
     | 
    
         
            +
                  end
         
     | 
| 
       42 
55 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
                  def run_behaviours 
     | 
| 
       44 
     | 
    
         
            -
                    behaviours.each do |behaviour|
         
     | 
| 
      
 56 
     | 
    
         
            +
                  def run_behaviours
         
     | 
| 
      
 57 
     | 
    
         
            +
                    @behaviours.each do |behaviour|
         
     | 
| 
       45 
58 
     | 
    
         
             
                      behaviour.run(@options.reporter, @options.dry_run, @options.reverse, @options.timeout)
         
     | 
| 
       46 
59 
     | 
    
         
             
                    end
         
     | 
| 
       47 
60 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -66,6 +79,14 @@ module Spec 
     | 
|
| 
       66 
79 
     | 
    
         | 
| 
       67 
80 
     | 
    
         
             
                private
         
     | 
| 
       68 
81 
     | 
    
         | 
| 
      
 82 
     | 
    
         
            +
                  # Sets the #number on each Example
         
     | 
| 
      
 83 
     | 
    
         
            +
                  def set_sequence_numbers
         
     | 
| 
      
 84 
     | 
    
         
            +
                    number = 0
         
     | 
| 
      
 85 
     | 
    
         
            +
                    @behaviours.each do |behaviour|
         
     | 
| 
      
 86 
     | 
    
         
            +
                      number = behaviour.set_sequence_numbers(number, @options.reverse)
         
     | 
| 
      
 87 
     | 
    
         
            +
                    end
         
     | 
| 
      
 88 
     | 
    
         
            +
                  end
         
     | 
| 
      
 89 
     | 
    
         
            +
                  
         
     | 
| 
       69 
90 
     | 
    
         
             
                  def find_paths(paths)
         
     | 
| 
       70 
91 
     | 
    
         
             
                    result = []
         
     | 
| 
       71 
92 
     | 
    
         
             
                    paths.each do |path|
         
     | 
| 
         @@ -24,26 +24,27 @@ module Spec 
     | 
|
| 
       24 
24 
     | 
    
         
             
                    def add_behaviour(name)
         
     | 
| 
       25 
25 
     | 
    
         
             
                    end
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
                    # This method is invoked when an example starts. 
     | 
| 
       28 
     | 
    
         
            -
                     
     | 
| 
       29 
     | 
    
         
            -
                    def example_started(name)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    # This method is invoked when an +example+ starts.
         
     | 
| 
      
 28 
     | 
    
         
            +
                    def example_started(example)
         
     | 
| 
       30 
29 
     | 
    
         
             
                    end
         
     | 
| 
       31 
30 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
                    # This method is invoked when an example passes. 
     | 
| 
       33 
     | 
    
         
            -
                     
     | 
| 
       34 
     | 
    
         
            -
                    def example_passed(name)
         
     | 
| 
      
 31 
     | 
    
         
            +
                    # This method is invoked when an +example+ passes.
         
     | 
| 
      
 32 
     | 
    
         
            +
                    def example_passed(example)
         
     | 
| 
       35 
33 
     | 
    
         
             
                    end
         
     | 
| 
       36 
34 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
                    # This method is invoked when an example fails, i.e. an exception occurred
         
     | 
| 
       38 
     | 
    
         
            -
                    # inside it (such as a failed should or other exception). + 
     | 
| 
       39 
     | 
    
         
            -
                    # of the  
     | 
| 
       40 
     | 
    
         
            -
                    #  
     | 
| 
       41 
     | 
    
         
            -
                    def example_failed( 
     | 
| 
      
 35 
     | 
    
         
            +
                    # This method is invoked when an +example+ fails, i.e. an exception occurred
         
     | 
| 
      
 36 
     | 
    
         
            +
                    # inside it (such as a failed should or other exception). +counter+ is the 
         
     | 
| 
      
 37 
     | 
    
         
            +
                    # sequence number of the failure (starting at 1) and +failure+ is the associated 
         
     | 
| 
      
 38 
     | 
    
         
            +
                    # Failure object.
         
     | 
| 
      
 39 
     | 
    
         
            +
                    def example_failed(example, counter, failure)
         
     | 
| 
       42 
40 
     | 
    
         
             
                    end
         
     | 
| 
       43 
41 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
                    # This method is invoked when an example is not yet implemented (i.e. has not 
     | 
| 
      
 42 
     | 
    
         
            +
                    # This method is invoked when an example is not yet implemented (i.e. has not
         
     | 
| 
      
 43 
     | 
    
         
            +
                    # been provided a block), or when an ExamplePendingError is raised.
         
     | 
| 
       45 
44 
     | 
    
         
             
                    # +name+ is the name of the example.
         
     | 
| 
       46 
     | 
    
         
            -
                     
     | 
| 
      
 45 
     | 
    
         
            +
                    # +message+ is the message from the ExamplePendingError, if it exists, or the
         
     | 
| 
      
 46 
     | 
    
         
            +
                    # default value of "Not Yet Implemented"
         
     | 
| 
      
 47 
     | 
    
         
            +
                    def example_pending(behaviour_name, example_name, message)
         
     | 
| 
       47 
48 
     | 
    
         
             
                    end
         
     | 
| 
       48 
49 
     | 
    
         | 
| 
       49 
50 
     | 
    
         
             
                    # This method is invoked after all of the examples have executed. The next method
         
     | 
| 
         @@ -58,10 +59,17 @@ module Spec 
     | 
|
| 
       58 
59 
     | 
    
         
             
                    def dump_failure(counter, failure)
         
     | 
| 
       59 
60 
     | 
    
         
             
                    end
         
     | 
| 
       60 
61 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
                    # This method is invoked  
     | 
| 
       62 
     | 
    
         
            -
                    def dump_summary(duration, example_count, failure_count,  
     | 
| 
      
 62 
     | 
    
         
            +
                    # This method is invoked after the dumping of examples and failures.
         
     | 
| 
      
 63 
     | 
    
         
            +
                    def dump_summary(duration, example_count, failure_count, pending_count)
         
     | 
| 
      
 64 
     | 
    
         
            +
                    end
         
     | 
| 
      
 65 
     | 
    
         
            +
                    
         
     | 
| 
      
 66 
     | 
    
         
            +
                    # This gets invoked after the summary if option is set to do so.
         
     | 
| 
      
 67 
     | 
    
         
            +
                    def dump_pending
         
     | 
| 
       63 
68 
     | 
    
         
             
                    end
         
     | 
| 
       64 
69 
     | 
    
         | 
| 
      
 70 
     | 
    
         
            +
                    # This method is invoked at the very end. Allows the formatter to clean up, like closing open streams.
         
     | 
| 
      
 71 
     | 
    
         
            +
                    def close
         
     | 
| 
      
 72 
     | 
    
         
            +
                    end
         
     | 
| 
       65 
73 
     | 
    
         
             
                  end
         
     | 
| 
       66 
74 
     | 
    
         
             
                end
         
     | 
| 
       67 
75 
     | 
    
         
             
              end
         
     | 
| 
         @@ -25,38 +25,47 @@ module Spec 
     | 
|
| 
       25 
25 
     | 
    
         
             
                      @colour = false
         
     | 
| 
       26 
26 
     | 
    
         
             
                      @dry_run = false
         
     | 
| 
       27 
27 
     | 
    
         
             
                      @snippet_extractor = SnippetExtractor.new
         
     | 
| 
      
 28 
     | 
    
         
            +
                      @pending_examples = []
         
     | 
| 
      
 29 
     | 
    
         
            +
                    end
         
     | 
| 
      
 30 
     | 
    
         
            +
                    
         
     | 
| 
      
 31 
     | 
    
         
            +
                    def example_pending(behaviour_name, example_name, message)
         
     | 
| 
      
 32 
     | 
    
         
            +
                      @pending_examples << ["#{behaviour_name} #{example_name}", message]
         
     | 
| 
       28 
33 
     | 
    
         
             
                    end
         
     | 
| 
       29 
34 
     | 
    
         | 
| 
       30 
35 
     | 
    
         
             
                    def colour=(colour)
         
     | 
| 
       31 
36 
     | 
    
         
             
                      @colour = colour
         
     | 
| 
       32 
37 
     | 
    
         
             
                      begin ; require 'Win32/Console/ANSI' if @colour && PLATFORM =~ /win32/ ; rescue LoadError ; raise "You must gem install win32console to use colour on Windows" ; end
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
      
 38 
     | 
    
         
            +
                    end
         
     | 
| 
       34 
39 
     | 
    
         | 
| 
       35 
40 
     | 
    
         
             
                    def dump_failure(counter, failure)
         
     | 
| 
       36 
41 
     | 
    
         
             
                      @output.puts
         
     | 
| 
       37 
42 
     | 
    
         
             
                      @output.puts "#{counter.to_s})"
         
     | 
| 
      
 43 
     | 
    
         
            +
                      @output.puts colourise("#{failure.header}\n#{failure.exception.message}", failure)
         
     | 
| 
      
 44 
     | 
    
         
            +
                      @output.puts format_backtrace(failure.exception.backtrace)
         
     | 
| 
      
 45 
     | 
    
         
            +
                      @output.flush
         
     | 
| 
      
 46 
     | 
    
         
            +
                    end
         
     | 
| 
      
 47 
     | 
    
         
            +
                    
         
     | 
| 
      
 48 
     | 
    
         
            +
                    def colourise(s, failure)
         
     | 
| 
       38 
49 
     | 
    
         
             
                      if(failure.expectation_not_met?)
         
     | 
| 
       39 
     | 
    
         
            -
                         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
      
 50 
     | 
    
         
            +
                        red(s)
         
     | 
| 
      
 51 
     | 
    
         
            +
                      elsif(failure.pending_fixed?)
         
     | 
| 
      
 52 
     | 
    
         
            +
                        blue(s)
         
     | 
| 
       41 
53 
     | 
    
         
             
                      else
         
     | 
| 
       42 
     | 
    
         
            -
                         
     | 
| 
       43 
     | 
    
         
            -
                        @output.puts magenta(failure.exception.message)
         
     | 
| 
      
 54 
     | 
    
         
            +
                        magenta(s)
         
     | 
| 
       44 
55 
     | 
    
         
             
                      end
         
     | 
| 
       45 
     | 
    
         
            -
                      @output.puts format_backtrace(failure.exception.backtrace)
         
     | 
| 
       46 
     | 
    
         
            -
                      @output.flush
         
     | 
| 
       47 
56 
     | 
    
         
             
                    end
         
     | 
| 
       48 
57 
     | 
    
         | 
| 
       49 
     | 
    
         
            -
                    def dump_summary(duration, example_count, failure_count,  
     | 
| 
      
 58 
     | 
    
         
            +
                    def dump_summary(duration, example_count, failure_count, pending_count)
         
     | 
| 
       50 
59 
     | 
    
         
             
                      return if @dry_run
         
     | 
| 
       51 
60 
     | 
    
         
             
                      @output.puts
         
     | 
| 
       52 
61 
     | 
    
         
             
                      @output.puts "Finished in #{duration} seconds"
         
     | 
| 
       53 
62 
     | 
    
         
             
                      @output.puts
         
     | 
| 
       54 
63 
     | 
    
         | 
| 
       55 
64 
     | 
    
         
             
                      summary = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}"
         
     | 
| 
       56 
     | 
    
         
            -
                      summary << ", #{ 
     | 
| 
      
 65 
     | 
    
         
            +
                      summary << ", #{pending_count} pending" if pending_count > 0  
         
     | 
| 
       57 
66 
     | 
    
         | 
| 
       58 
67 
     | 
    
         
             
                      if failure_count == 0
         
     | 
| 
       59 
     | 
    
         
            -
                        if  
     | 
| 
      
 68 
     | 
    
         
            +
                        if pending_count > 0
         
     | 
| 
       60 
69 
     | 
    
         
             
                          @output.puts yellow(summary)
         
     | 
| 
       61 
70 
     | 
    
         
             
                        else
         
     | 
| 
       62 
71 
     | 
    
         
             
                          @output.puts green(summary)
         
     | 
| 
         @@ -65,8 +74,26 @@ module Spec 
     | 
|
| 
       65 
74 
     | 
    
         
             
                        @output.puts red(summary)
         
     | 
| 
       66 
75 
     | 
    
         
             
                      end
         
     | 
| 
       67 
76 
     | 
    
         
             
                      @output.flush
         
     | 
| 
      
 77 
     | 
    
         
            +
                      dump_pending
         
     | 
| 
       68 
78 
     | 
    
         
             
                    end
         
     | 
| 
       69 
79 
     | 
    
         | 
| 
      
 80 
     | 
    
         
            +
                    def dump_pending
         
     | 
| 
      
 81 
     | 
    
         
            +
                      unless @pending_examples.empty?
         
     | 
| 
      
 82 
     | 
    
         
            +
                        @output.puts
         
     | 
| 
      
 83 
     | 
    
         
            +
                        @output.puts "Pending:"
         
     | 
| 
      
 84 
     | 
    
         
            +
                        @pending_examples.each do |pending_example|
         
     | 
| 
      
 85 
     | 
    
         
            +
                          @output.puts "#{pending_example[0]} (#{pending_example[1]})" 
         
     | 
| 
      
 86 
     | 
    
         
            +
                        end
         
     | 
| 
      
 87 
     | 
    
         
            +
                      end
         
     | 
| 
      
 88 
     | 
    
         
            +
                      @output.flush
         
     | 
| 
      
 89 
     | 
    
         
            +
                    end
         
     | 
| 
      
 90 
     | 
    
         
            +
                    
         
     | 
| 
      
 91 
     | 
    
         
            +
                    def close
         
     | 
| 
      
 92 
     | 
    
         
            +
                      if IO === @output
         
     | 
| 
      
 93 
     | 
    
         
            +
                        @output.close 
         
     | 
| 
      
 94 
     | 
    
         
            +
                      end
         
     | 
| 
      
 95 
     | 
    
         
            +
                    end
         
     | 
| 
      
 96 
     | 
    
         
            +
                    
         
     | 
| 
       70 
97 
     | 
    
         
             
                    def format_backtrace(backtrace)
         
     | 
| 
       71 
98 
     | 
    
         
             
                      return "" if backtrace.nil?
         
     | 
| 
       72 
99 
     | 
    
         
             
                      backtrace.map { |line| backtrace_line(line) }.join("\n")
         
     | 
| 
         @@ -91,10 +118,11 @@ module Spec 
     | 
|
| 
       91 
118 
     | 
    
         
             
                      end
         
     | 
| 
       92 
119 
     | 
    
         
             
                    end
         
     | 
| 
       93 
120 
     | 
    
         | 
| 
       94 
     | 
    
         
            -
                    def red(text); colour(text, "\e[31m"); end
         
     | 
| 
       95 
121 
     | 
    
         
             
                    def green(text); colour(text, "\e[32m"); end
         
     | 
| 
      
 122 
     | 
    
         
            +
                    def red(text); colour(text, "\e[31m"); end
         
     | 
| 
       96 
123 
     | 
    
         
             
                    def magenta(text); colour(text, "\e[35m"); end
         
     | 
| 
       97 
124 
     | 
    
         
             
                    def yellow(text); colour(text, "\e[33m"); end
         
     | 
| 
      
 125 
     | 
    
         
            +
                    def blue(text); colour(text, "\e[34m"); end
         
     | 
| 
       98 
126 
     | 
    
         | 
| 
       99 
127 
     | 
    
         
             
                  end
         
     | 
| 
       100 
128 
     | 
    
         
             
                end
         
     | 
| 
         @@ -3,10 +3,14 @@ module Spec 
     | 
|
| 
       3 
3 
     | 
    
         
             
                module Formatter
         
     | 
| 
       4 
4 
     | 
    
         
             
                  class FailingBehavioursFormatter < BaseTextFormatter      
         
     | 
| 
       5 
5 
     | 
    
         
             
                    def add_behaviour(behaviour_name)
         
     | 
| 
       6 
     | 
    
         
            -
                       
     | 
| 
      
 6 
     | 
    
         
            +
                      if behaviour_name =~ /(.*) \(druby.*\)$/
         
     | 
| 
      
 7 
     | 
    
         
            +
                        @behaviour_name = $1
         
     | 
| 
      
 8 
     | 
    
         
            +
                      else
         
     | 
| 
      
 9 
     | 
    
         
            +
                        @behaviour_name = behaviour_name
         
     | 
| 
      
 10 
     | 
    
         
            +
                      end
         
     | 
| 
       7 
11 
     | 
    
         
             
                    end
         
     | 
| 
       8 
12 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                    def example_failed( 
     | 
| 
      
 13 
     | 
    
         
            +
                    def example_failed(example, counter, failure)
         
     | 
| 
       10 
14 
     | 
    
         
             
                      unless @behaviour_name.nil?
         
     | 
| 
       11 
15 
     | 
    
         
             
                        @output.puts @behaviour_name 
         
     | 
| 
       12 
16 
     | 
    
         
             
                        @behaviour_name = nil
         
     | 
| 
         @@ -17,7 +21,7 @@ module Spec 
     | 
|
| 
       17 
21 
     | 
    
         
             
                    def dump_failure(counter, failure)
         
     | 
| 
       18 
22 
     | 
    
         
             
                    end
         
     | 
| 
       19 
23 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
                    def dump_summary(duration, example_count, failure_count,  
     | 
| 
      
 24 
     | 
    
         
            +
                    def dump_summary(duration, example_count, failure_count, pending_count)
         
     | 
| 
       21 
25 
     | 
    
         
             
                    end
         
     | 
| 
       22 
26 
     | 
    
         
             
                  end
         
     | 
| 
       23 
27 
     | 
    
         
             
                end
         
     | 
| 
         @@ -6,15 +6,15 @@ module Spec 
     | 
|
| 
       6 
6 
     | 
    
         
             
                      @behaviour_name = behaviour_name
         
     | 
| 
       7 
7 
     | 
    
         
             
                    end
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                    def example_failed( 
     | 
| 
       10 
     | 
    
         
            -
                      @output.puts "#{@behaviour_name} #{ 
     | 
| 
      
 9 
     | 
    
         
            +
                    def example_failed(example, counter, failure)
         
     | 
| 
      
 10 
     | 
    
         
            +
                      @output.puts "#{@behaviour_name} #{example.description}"
         
     | 
| 
       11 
11 
     | 
    
         
             
                      @output.flush
         
     | 
| 
       12 
12 
     | 
    
         
             
                    end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                    def dump_failure(counter, failure)
         
     | 
| 
       15 
15 
     | 
    
         
             
                    end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
                    def dump_summary(duration, example_count, failure_count,  
     | 
| 
      
 17 
     | 
    
         
            +
                    def dump_summary(duration, example_count, failure_count, pending_count)
         
     | 
| 
       18 
18 
     | 
    
         
             
                    end
         
     | 
| 
       19 
19 
     | 
    
         
             
                  end
         
     | 
| 
       20 
20 
     | 
    
         
             
                end
         
     | 
| 
         @@ -1,7 +1,10 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'erb'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module Spec
         
     | 
| 
       2 
4 
     | 
    
         
             
              module Runner
         
     | 
| 
       3 
5 
     | 
    
         
             
                module Formatter
         
     | 
| 
       4 
6 
     | 
    
         
             
                  class HtmlFormatter < BaseTextFormatter
         
     | 
| 
      
 7 
     | 
    
         
            +
                    include ERB::Util # for the #h method
         
     | 
| 
       5 
8 
     | 
    
         | 
| 
       6 
9 
     | 
    
         
             
                    def initialize(output)
         
     | 
| 
       7 
10 
     | 
    
         
             
                      super
         
     | 
| 
         @@ -14,7 +17,7 @@ module Spec 
     | 
|
| 
       14 
17 
     | 
    
         
             
                      @current_behaviour_number
         
     | 
| 
       15 
18 
     | 
    
         
             
                    end
         
     | 
| 
       16 
19 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
                    # The number of the currently running example
         
     | 
| 
      
 20 
     | 
    
         
            +
                    # The number of the currently running example (a global counter)
         
     | 
| 
       18 
21 
     | 
    
         
             
                    def current_example_number
         
     | 
| 
       19 
22 
     | 
    
         
             
                      @current_example_number
         
     | 
| 
       20 
23 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -37,7 +40,7 @@ module Spec 
     | 
|
| 
       37 
40 
     | 
    
         
             
                      end
         
     | 
| 
       38 
41 
     | 
    
         
             
                      @output.puts "<div class=\"behaviour\">"
         
     | 
| 
       39 
42 
     | 
    
         
             
                      @output.puts "  <dl>"
         
     | 
| 
       40 
     | 
    
         
            -
                      @output.puts "  <dt id=\"behaviour_#{current_behaviour_number}\">#{ 
     | 
| 
      
 43 
     | 
    
         
            +
                      @output.puts "  <dt id=\"behaviour_#{current_behaviour_number}\">#{h(name)}</dt>"
         
     | 
| 
       41 
44 
     | 
    
         
             
                      @output.flush
         
     | 
| 
       42 
45 
     | 
    
         
             
                    end
         
     | 
| 
       43 
46 
     | 
    
         | 
| 
         @@ -47,26 +50,28 @@ module Spec 
     | 
|
| 
       47 
50 
     | 
    
         
             
                      @output.flush
         
     | 
| 
       48 
51 
     | 
    
         
             
                    end
         
     | 
| 
       49 
52 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
                    def  
     | 
| 
       51 
     | 
    
         
            -
                      @current_example_number  
     | 
| 
      
 53 
     | 
    
         
            +
                    def example_started(example)
         
     | 
| 
      
 54 
     | 
    
         
            +
                      @current_example_number = example.number
         
     | 
| 
      
 55 
     | 
    
         
            +
                    end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                    def example_passed(example)
         
     | 
| 
       52 
58 
     | 
    
         
             
                      move_progress
         
     | 
| 
       53 
     | 
    
         
            -
                      @output.puts "    <dd class=\"spec passed\"><span class=\"passed_spec_name\">#{ 
     | 
| 
      
 59 
     | 
    
         
            +
                      @output.puts "    <dd class=\"spec passed\"><span class=\"passed_spec_name\">#{h(example.description)}</span></dd>"
         
     | 
| 
       54 
60 
     | 
    
         
             
                      @output.flush
         
     | 
| 
       55 
61 
     | 
    
         
             
                    end
         
     | 
| 
       56 
62 
     | 
    
         | 
| 
       57 
     | 
    
         
            -
                    def example_failed( 
     | 
| 
      
 63 
     | 
    
         
            +
                    def example_failed(example, counter, failure)
         
     | 
| 
       58 
64 
     | 
    
         
             
                      extra = extra_failure_content(failure)
         
     | 
| 
       59 
     | 
    
         
            -
                      
         
     | 
| 
       60 
     | 
    
         
            -
                      @current_example_number += 1
         
     | 
| 
      
 65 
     | 
    
         
            +
                      failure_style = failure.pending_fixed? ? 'pending_fixed' : 'failed'
         
     | 
| 
       61 
66 
     | 
    
         
             
                      @output.puts "    <script type=\"text/javascript\">makeRed('rspec-header');</script>" unless @header_red
         
     | 
| 
       62 
67 
     | 
    
         
             
                      @header_red = true
         
     | 
| 
       63 
68 
     | 
    
         
             
                      @output.puts "    <script type=\"text/javascript\">makeRed('behaviour_#{current_behaviour_number}');</script>" unless @behaviour_red
         
     | 
| 
       64 
69 
     | 
    
         
             
                      @behaviour_red = true
         
     | 
| 
       65 
70 
     | 
    
         
             
                      move_progress
         
     | 
| 
       66 
     | 
    
         
            -
                      @output.puts "    <dd class=\"spec  
     | 
| 
       67 
     | 
    
         
            -
                      @output.puts "      <span class=\"failed_spec_name\">#{ 
     | 
| 
      
 71 
     | 
    
         
            +
                      @output.puts "    <dd class=\"spec #{failure_style}\">"
         
     | 
| 
      
 72 
     | 
    
         
            +
                      @output.puts "      <span class=\"failed_spec_name\">#{h(example.description)}</span>"
         
     | 
| 
       68 
73 
     | 
    
         
             
                      @output.puts "      <div class=\"failure\" id=\"failure_#{counter}\">"
         
     | 
| 
       69 
     | 
    
         
            -
                      @output.puts "        <div class=\"message\"><pre>#{ 
     | 
| 
      
 74 
     | 
    
         
            +
                      @output.puts "        <div class=\"message\"><pre>#{h(failure.exception.message)}</pre></div>" unless failure.exception.nil?
         
     | 
| 
       70 
75 
     | 
    
         
             
                      @output.puts "        <div class=\"backtrace\"><pre>#{format_backtrace(failure.exception.backtrace)}</pre></div>" unless failure.exception.nil?
         
     | 
| 
       71 
76 
     | 
    
         
             
                      @output.puts extra unless extra == ""
         
     | 
| 
       72 
77 
     | 
    
         
             
                      @output.puts "      </div>"
         
     | 
| 
         @@ -74,14 +79,14 @@ module Spec 
     | 
|
| 
       74 
79 
     | 
    
         
             
                      @output.flush
         
     | 
| 
       75 
80 
     | 
    
         
             
                    end
         
     | 
| 
       76 
81 
     | 
    
         | 
| 
       77 
     | 
    
         
            -
                    def  
     | 
| 
       78 
     | 
    
         
            -
                      @current_example_number += 1
         
     | 
| 
      
 82 
     | 
    
         
            +
                    def example_pending(behaviour_name, example_name, message)
         
     | 
| 
       79 
83 
     | 
    
         
             
                      @output.puts "    <script type=\"text/javascript\">makeYellow('rspec-header');</script>" unless @header_red
         
     | 
| 
       80 
84 
     | 
    
         
             
                      @output.puts "    <script type=\"text/javascript\">makeYellow('behaviour_#{current_behaviour_number}');</script>" unless @behaviour_red
         
     | 
| 
       81 
85 
     | 
    
         
             
                      move_progress
         
     | 
| 
       82 
     | 
    
         
            -
                      @output.puts "    <dd class=\"spec not_implemented\"><span class=\"not_implemented_spec_name\">#{ 
     | 
| 
      
 86 
     | 
    
         
            +
                      @output.puts "    <dd class=\"spec not_implemented\"><span class=\"not_implemented_spec_name\">#{h(example_name)}</span></dd>"
         
     | 
| 
       83 
87 
     | 
    
         
             
                      @output.flush
         
     | 
| 
       84 
88 
     | 
    
         
             
                    end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
       85 
90 
     | 
    
         
             
                    # Override this method if you wish to output extra HTML for a failed spec. For example, you
         
     | 
| 
       86 
91 
     | 
    
         
             
                    # could output links to images or other files produced during the specs.
         
     | 
| 
       87 
92 
     | 
    
         
             
                    #
         
     | 
| 
         @@ -90,24 +95,20 @@ module Spec 
     | 
|
| 
       90 
95 
     | 
    
         
             
                    end
         
     | 
| 
       91 
96 
     | 
    
         | 
| 
       92 
97 
     | 
    
         
             
                    def move_progress
         
     | 
| 
       93 
     | 
    
         
            -
                      percent_done = @example_count == 0 ? 100.0 : (current_example_number.to_f / @example_count.to_f * 1000).to_i / 10.0
         
     | 
| 
      
 98 
     | 
    
         
            +
                      percent_done = @example_count == 0 ? 100.0 : ((current_example_number + 1).to_f / @example_count.to_f * 1000).to_i / 10.0
         
     | 
| 
       94 
99 
     | 
    
         
             
                      @output.puts "    <script type=\"text/javascript\">moveProgressBar('#{percent_done}');</script>"
         
     | 
| 
       95 
100 
     | 
    
         
             
                      @output.flush
         
     | 
| 
       96 
101 
     | 
    
         
             
                    end
         
     | 
| 
       97 
     | 
    
         
            -
                    
         
     | 
| 
       98 
     | 
    
         
            -
                    def escape(string)
         
     | 
| 
       99 
     | 
    
         
            -
                      string.gsub(/&/n, '&').gsub(/\"/n, '"').gsub(/>/n, '>').gsub(/</n, '<')
         
     | 
| 
       100 
     | 
    
         
            -
                    end
         
     | 
| 
       101 
102 
     | 
    
         | 
| 
       102 
103 
     | 
    
         
             
                    def dump_failure(counter, failure)
         
     | 
| 
       103 
104 
     | 
    
         
             
                    end
         
     | 
| 
       104 
105 
     | 
    
         | 
| 
       105 
     | 
    
         
            -
                    def dump_summary(duration, example_count, failure_count,  
     | 
| 
      
 106 
     | 
    
         
            +
                    def dump_summary(duration, example_count, failure_count, pending_count)
         
     | 
| 
       106 
107 
     | 
    
         
             
                      if @dry_run
         
     | 
| 
       107 
108 
     | 
    
         
             
                        totals = "This was a dry-run"
         
     | 
| 
       108 
109 
     | 
    
         
             
                      else
         
     | 
| 
       109 
110 
     | 
    
         
             
                        totals = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}"
         
     | 
| 
       110 
     | 
    
         
            -
                        totals << ", #{ 
     | 
| 
      
 111 
     | 
    
         
            +
                        totals << ", #{pending_count} pending" if pending_count > 0  
         
     | 
| 
       111 
112 
     | 
    
         
             
                      end
         
     | 
| 
       112 
113 
     | 
    
         
             
                      @output.puts "<script type=\"text/javascript\">document.getElementById('duration').innerHTML = \"Finished in <strong>#{duration} seconds</strong>\";</script>"
         
     | 
| 
       113 
114 
     | 
    
         
             
                      @output.puts "<script type=\"text/javascript\">document.getElementById('totals').innerHTML = \"#{totals}\";</script>"
         
     | 
| 
         @@ -264,6 +265,12 @@ dd.spec.not_implemented { 
     | 
|
| 
       264 
265 
     | 
    
         
             
              background: #FCFB98; color: #131313;
         
     | 
| 
       265 
266 
     | 
    
         
             
            }
         
     | 
| 
       266 
267 
     | 
    
         | 
| 
      
 268 
     | 
    
         
            +
            dd.spec.pending_fixed {
         
     | 
| 
      
 269 
     | 
    
         
            +
              border-left: 5px solid #0000C2;
         
     | 
| 
      
 270 
     | 
    
         
            +
              border-bottom: 1px solid #0000C2;
         
     | 
| 
      
 271 
     | 
    
         
            +
              color: #0000C2; background: #D3FBFF;
         
     | 
| 
      
 272 
     | 
    
         
            +
            }
         
     | 
| 
      
 273 
     | 
    
         
            +
             
     | 
| 
       267 
274 
     | 
    
         
             
            .backtrace {
         
     | 
| 
       268 
275 
     | 
    
         
             
              color: #000;
         
     | 
| 
       269 
276 
     | 
    
         
             
              font-size: 12px;
         
     | 
| 
         @@ -303,10 +310,10 @@ a { 
     | 
|
| 
       303 
310 
     | 
    
         | 
| 
       304 
311 
     | 
    
         
             
            .ruby .offending { background-color: gray; }
         
     | 
| 
       305 
312 
     | 
    
         
             
            .ruby .linenum {
         
     | 
| 
       306 
     | 
    
         
            -
             
     | 
| 
       307 
     | 
    
         
            -
             
     | 
| 
       308 
     | 
    
         
            -
             
     | 
| 
       309 
     | 
    
         
            -
             
     | 
| 
      
 313 
     | 
    
         
            +
              width: 75px;
         
     | 
| 
      
 314 
     | 
    
         
            +
              padding: 0.1em 1em 0.2em 0;
         
     | 
| 
      
 315 
     | 
    
         
            +
              color: #000000;
         
     | 
| 
      
 316 
     | 
    
         
            +
              background-color: #FFFBD3;
         
     | 
| 
       310 
317 
     | 
    
         
             
            }
         
     | 
| 
       311 
318 
     | 
    
         
             
            EOF
         
     | 
| 
       312 
319 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -5,18 +5,19 @@ module Spec 
     | 
|
| 
       5 
5 
     | 
    
         
             
                    def add_behaviour(name)
         
     | 
| 
       6 
6 
     | 
    
         
             
                    end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                    def example_failed( 
     | 
| 
       9 
     | 
    
         
            -
                      @output.print  
     | 
| 
      
 8 
     | 
    
         
            +
                    def example_failed(example, counter, failure)
         
     | 
| 
      
 9 
     | 
    
         
            +
                      @output.print colourise('F', failure)
         
     | 
| 
       10 
10 
     | 
    
         
             
                      @output.flush
         
     | 
| 
       11 
11 
     | 
    
         
             
                    end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                    def example_passed( 
     | 
| 
      
 13 
     | 
    
         
            +
                    def example_passed(example)
         
     | 
| 
       14 
14 
     | 
    
         
             
                      @output.print green('.')
         
     | 
| 
       15 
15 
     | 
    
         
             
                      @output.flush
         
     | 
| 
       16 
16 
     | 
    
         
             
                    end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
                    def  
     | 
| 
       19 
     | 
    
         
            -
                       
     | 
| 
      
 18 
     | 
    
         
            +
                    def example_pending(behaviour_name, example_name, message)
         
     | 
| 
      
 19 
     | 
    
         
            +
                      super
         
     | 
| 
      
 20 
     | 
    
         
            +
                      @output.print yellow('P')
         
     | 
| 
       20 
21 
     | 
    
         
             
                      @output.flush
         
     | 
| 
       21 
22 
     | 
    
         
             
                    end
         
     | 
| 
       22 
23 
     | 
    
         |