Class: BaseTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/test/test_helper.rb

Instance Method Summary collapse

Instance Method Details

#add_file_eventsObject



121
122
123
124
125
126
127
128
# File 'lib/test/test_helper.rb', line 121

def add_file_events
  @files.extend FileProviderTestEvents
  @files.on_before do |p, f|
    @path = p
    @file = f
    @full_name = fp File.join(p, f)
  end
end

#fp(path) ⇒ Object



130
131
132
# File 'lib/test/test_helper.rb', line 130

def fp(path)
  File.expand_path path
end

#new_files(files) ⇒ Object



116
117
118
119
# File 'lib/test/test_helper.rb', line 116

def new_files(files)
  @files = Provider::File::Array.new(files)
  add_file_events
end

#r(action, name = :rename_replace, expected_yields = nil, options = {}) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/test/test_helper.rb', line 136

def r(action, name = :rename_replace, expected_yields = nil, options = {})
  options[:file_provider] ||= @files
  options[:action] ||= action
  options[:filter] = Filter.add options[:filter], Filter.new(/^\.+$/) unless options[:test_r_nofilter]
  yc = 0
  @r.run name, options do |h|
    yc += 1
    yield h if block_given?
  end
  if options[:test_r_count]
    raise 'exception raised' if expected_yields and expected_yields != yc
  else
    assert_equal expected_yields, yc, 'Expected yields from renamer' if expected_yields
  end
end

#setupObject



105
106
107
108
109
110
# File 'lib/test/test_helper.rb', line 105

def setup
  new_files( %w{ dir/. dir/.. dir/file1 dir/file2 dir/file3 } )
  @r = RenamerMock.new
  @orig_dir = Dir.getwd
  Dir.chdir File.join(File.split(__FILE__).first, '/../../tests')
end

#teardownObject



112
113
114
# File 'lib/test/test_helper.rb', line 112

def teardown
  Dir.chdir @orig_dir
end

#test_shutupObject



134
# File 'lib/test/test_helper.rb', line 134

def test_shutup; end