Sha256: 2085d49ce41c60fee672fd51a6daf5c8bffc927c20887a13dd97902c7b994e35

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

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

HydraulicBrake.configure do |c|
end

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

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

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

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

task :hydraulic_brake_not_yet_configured do
  HydraulicBrake.configuration.rescue_rake_exceptions = true
  stub_tty_output(true)
  stub_empty_sender
  raise_exception
end

def stub_empty_sender
  HydraulicBrake.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
hydraulic_brake-0.1.0 features/support/rake/Rakefile
hydraulic_brake-0.0.0 features/support/rake/Rakefile