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



116
117
118
119
120
121
122
123
# File 'lib/test/test_helper.rb', line 116

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



125
126
127
# File 'lib/test/test_helper.rb', line 125

def fp(path)
  File.expand_path path
end

#new_files(files) ⇒ Object



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

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

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



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/test/test_helper.rb', line 131

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



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

def setup
  new_files( %w{ dir/. dir/.. dir/file1 dir/file2 dir/file3 } )
  @r = RenamerMock.new
end

#test_shutupObject



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

def test_shutup; end