Sha256: a0987100252388f3267f7fdcf8781517f8ac21fdc5e2e47691c782afb45916f6

Contents?: true

Size: 1.75 KB

Versions: 53

Compression:

Stored size: 1.75 KB

Contents

require 'rspec/core/formatters/base_text_formatter'

module RSpec
  module Core
    module Formatters
      class DocumentationFormatter < BaseTextFormatter
        def initialize(output)
          super(output)
          @group_level = 0
        end

        def example_group_started(example_group)
          super(example_group)

          output.puts if @group_level == 0
          output.puts "#{current_indentation}#{example_group.description.strip}"

          @group_level += 1
        end

        def example_group_finished(example_group)
          @group_level -= 1
        end

        def example_passed(example)
          super(example)
          output.puts passed_output(example)
        end

        def example_pending(example)
          super(example)
          output.puts pending_output(example, example.execution_result[:pending_message])
        end

        def example_failed(example)
          super(example)
          output.puts failure_output(example, example.execution_result[:exception])
        end

        def failure_output(example, exception)
          failure_color("#{current_indentation}#{example.description.strip} (FAILED - #{next_failure_index})")
        end

        def next_failure_index
          @next_failure_index ||= 0
          @next_failure_index += 1
        end

        def passed_output(example)
          success_color("#{current_indentation}#{example.description.strip}")
        end

        def pending_output(example, message)
          pending_color("#{current_indentation}#{example.description.strip} (PENDING: #{message})")
        end

        def current_indentation
          '  ' * @group_level
        end

        def example_group_chain
          example_group.parent_groups.reverse
        end
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 14 rubygems

Version Path
rspec-core-2.99.0.rc1 lib/rspec/core/formatters/documentation_formatter.rb
rspec-core-2.14.8 lib/rspec/core/formatters/documentation_formatter.rb
rspec-core-2.99.0.beta2 lib/rspec/core/formatters/documentation_formatter.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-core-2.14.7/lib/rspec/core/formatters/documentation_formatter.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/formatters/documentation_formatter.rb
dxruby_rp5-0.0.3 spec/vendor/rspec-core-2.14.7/lib/rspec/core/formatters/documentation_formatter.rb
tuktuk-rails-0.0.10 vendor/bundle/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/formatters/documentation_formatter.rb
tuktuk-rails-0.0.9 vendor/bundle/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/formatters/documentation_formatter.rb
tuktuk-rails-0.0.8 vendor/bundle/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/formatters/documentation_formatter.rb
tuktuk-rails-0.0.7 vendor/bundle/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/formatters/documentation_formatter.rb
dxruby_rp5-0.0.2 spec/vendor/rspec-core-2.14.7/lib/rspec/core/formatters/documentation_formatter.rb
dxruby_rp5-0.0.1 spec/vendor/rspec-core-2.14.7/lib/rspec/core/formatters/documentation_formatter.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/formatters/documentation_formatter.rb
rspec-core-3.0.0.beta1 lib/rspec/core/formatters/documentation_formatter.rb
rspec-core-2.99.0.beta1 lib/rspec/core/formatters/documentation_formatter.rb
rspec-core-2.14.7 lib/rspec/core/formatters/documentation_formatter.rb
rspec-core-2.14.6 lib/rspec/core/formatters/documentation_formatter.rb
clickable_link-0.0.2 vendor/bundle/ruby/1.9.1/gems/rspec-core-2.14.5/lib/rspec/core/formatters/documentation_formatter.rb
syllable_counter-1.0.0 vendor/bundle/gems/rspec-core-2.14.5/lib/rspec/core/formatters/documentation_formatter.rb
rspec-core-2.14.5 lib/rspec/core/formatters/documentation_formatter.rb