Sha256: 6eb132d8fc567132c8dcd86c66ae1a087c25cf95344e7ac84dee15273dba7e72

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

# A test harness for RakeHandler
#
require 'rake'
require 'rubygems'
require 'projectlocker_pulse'
require 'pulse/rake_handler'

Pulse.configure do |c|
end

# Should catch exception
task :pulse do
  Pulse.configuration.rescue_rake_exceptions = true
  stub_tty_output(true)
  raise_exception 
end

# Should not catch exception
task :pulse_disabled do
  Pulse.configuration.rescue_rake_exceptions = false
  stub_tty_output(true)
  raise_exception 
end

# Should not catch exception as tty_output is true
task :pulse_autodetect_from_terminal do
  Pulse.configuration.rescue_rake_exceptions = nil
  stub_tty_output(true) 
  raise_exception 
end

# Should catch exception as tty_output is false
task :pulse_autodetect_not_from_terminal do
  Pulse.configuration.rescue_rake_exceptions = nil
  stub_tty_output(false) 
  raise_exception 
end

task :pulse_not_yet_configured do
  Pulse.configuration.rescue_rake_exceptions = true
  stub_tty_output(true)
  stub_empty_sender
  raise_exception
end

module Pulse
  def self.notify_or_ignore(*args)
    # TODO if you need to check more params, you'll have to use json.dump or something
    $stderr.puts "pulse #{args[1][:component]}"
  end
end

def stub_empty_sender
  Pulse.sender = nil
end

def stub_tty_output(value)
  Rake.application.instance_eval do
    @tty_output_stub = value
    def tty_output?
      @tty_output_stub
    end
  end
end

def raise_exception
  raise 'TEST'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
projectlocker_pulse-1.0.0 features/support/rake/Rakefile
projectlocker_pulse-0.2.1 features/support/rake/Rakefile