Sha256: ed55da89ce616d23967c9da15742ed25780f128a9a275037a04bf09bf7e6ecb1

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

require 'cucumber'
require 'cucumber/formatter/console'
require File.dirname(__FILE__) + '/rspactor/growl'

module CucumberGrowler
  include RSpactor::Growl

  def self.included(base)
    base.class_eval do
      alias original_print_stats print_stats
      include InstanceMethods

      def print_stats(features, profiles = [])
        title, icon, messages = '', '', []
        [:failed, :skipped, :undefined, :pending, :passed].reverse.each do |status|
          if step_mother.steps(status).any?
            icon = icon_for(status)
            # title = title_for(status)
            messages << dump_count(step_mother.steps(status).length, "step", status.to_s)
          end
        end

        notify "Cucumber Results", messages.reverse.join(", "), icon
        original_print_stats(features, profiles = [])
      end
    end
  end

  module InstanceMethods
    def icon_for(status)
      case status
      when :passed
        'success'
      when :pending, :undefined, :skipped
        'pending'
      when :failed
        'failed'
      end
    end

    def title_for(status)
      case status
      when :passed
        'Features passed!'
      when :pending
        'Some steps are pending...'
      when :undefined
        'Some undefined steps...'
      when :skipped
        'Some steps skipped...'
      when :failed
        'Failures occurred!'
      end
    end
  end

end

module Cucumber::Formatter::Console
  include CucumberGrowler
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rspactor-0.6.4 lib/cucumber_growler.rb
rspactor-0.6.3 lib/cucumber_growler.rb
rspactor-0.6.2 lib/cucumber_growler.rb