Sha256: 291f24c33243898de1d27436f3a16ef95f8c80023f5e59c4dae1a5e778027fef

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'spec'
require 'spec/autorun'

$debug = true

# Customize RSpec with my own extensions
module SpecMacros

  # wrapper for it method that extracts description from example source code, such as:
  # spec { use{    function(arg1 = 4, arg2 = 'string')  }}
  def spec &block
#    p (block.methods-Object.methods).sort; exit
    if RUBY_PLATFORM =~ /java/
      it 'dummy JRuby description', &block
    else
      it description_from(*block.source_location), &block
    end
  end

  # reads description line from source file and drops external brackets (like its{}, use{}
  def description_from(file, line)
    File.open(file) do |f|
      f.lines.to_a[line-1].gsub( /(spec.*?{)|(use.*?{)|}/, '' ).strip
    end
  end
end

Spec::Runner.configure { |config| config.extend(SpecMacros) }

module WinTest

  TEST_KEY_DELAY = 0.001
  TEST_IMPOSSIBLE = 'Impossible'
  TEST_CONVERSION_ERROR = /Can.t convert/
  TEST_SLEEP_DELAY = 0.01
  TEST_APP_PATH = File.join(File.dirname(__FILE__), "test_apps/locknote/LockNote.exe" )
  TEST_APP_START = 'start "" "' + TEST_APP_PATH + '"'
  TEST_WIN_TITLE = 'LockNote - Steganos LockNote'
  TEST_WIN_CLASS = 'ATL:00434098'
  TEST_WIN_RECT = [710, 400, 1210, 800]
  TEST_STATUSBAR_CLASS = 'msctls_statusbar32'
  TEST_TEXTAREA_CLASS = 'ATL:00434310'

  def use
    lambda{yield}.should_not raise_error
  end

  def any_block
    lambda{|*args| args}
  end

  def any_handle
    unless respond_to? :find_window
      require 'win/window'
      include Win::Window
    end
    find_window(nil, nil)
  end

  def not_a_handle
    123
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
win-0.0.6 spec/spec_helper.rb