Sha256: 246259a4d7a3559c127a63cd3c88fb9b8ad99500ed6b4bec9b37867ecbcfbe18

Contents?: true

Size: 1.5 KB

Versions: 2

Compression:

Stored size: 1.5 KB

Contents

module RSpec
  module ExampleSteps
    module DocumentationFormatter
      def self.included(base)
        base.class_eval do
          include InstanceMethods

          alias :example_started_without_steps :example_started
          alias :example_started :example_started_with_steps

          alias :example_passed_without_steps :example_passed
          alias :example_passed :example_passed_with_steps
        end
      end

      module InstanceMethods
        def example_started_with_steps(example)
          example_started_without_steps(example)

          if example.options[:with_steps]
            full_message = "#{current_indentation}#{example.description}"
            output.puts white(full_message)
          end
        end

        def example_passed_with_steps(example)
          example_passed_without_steps(example) unless example.options[:with_steps]
        end

        def example_step_passed(example_group, type, message, options)
          full_message = "#{current_indentation}  #{type.to_s.capitalize} #{message}"
          output.puts green(full_message)
        end

        def example_step_pending(example_group, type, message, options)
          full_message = "#{current_indentation}  #{type.to_s.capitalize} #{message}"

          if options[:pending] && options[:pending] != true
            full_message << " (PENDING: #{options[:pending]})"
          else
            full_message << " (PENDING)"
          end

          output.puts yellow(full_message)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec-example_steps-0.1.2 lib/rspec/example_steps/documentation_formatter.rb
rspec-example_steps-0.1.1 lib/rspec/example_steps/documentation_formatter.rb