Sha256: 16bd6b6a00b4f2b2a7fb64e00d5b0336aceb410c0a4ce610181acccf567ae2a0

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require "rspec/core"
require "rspec/core/formatters/documentation_formatter"

# monkey patching rspec
module RSpec::Core
  class Reporter
    if defined?(NOTIFICATIONS)
      NOTIFICATIONS.push("by_started", "by_finished")
    end

    def by_started(message)
      notify :by_started, message
    end

    def by_ended(message = '')
      notify :by_ended, message
    end
  end

  unless defined?(Reporter::NOTIFICATIONS)
    class Formatters::DocumentationFormatter
      def by_started(message)
      end
      def by_ended(message = '')
      end
    end
  end

  class ExampleGroup
    def by message, level=0
      pending(message) unless block_given?
      begin
        @by_reporter.by_started(message)
        yield
      ensure
        @by_reporter.by_ended
      end
    end

    alias and_by by
  end

  class Example
    private

    alias :start_without_reporter :start

    def start(reporter)
      start_without_reporter(reporter)
      if @example_group_instance
        @example_group_instance.instance_variable_set(:@by_reporter, reporter)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-by-0.0.7 lib/rspec/by/core_ext.rb