1
0
Fork 0
mirror of synced 2024-07-02 13:31:09 -04:00
ultimate-vim/sources_non_forked/vim-ruby/spec/spec_helper.rb
Maksim Pecherskiy 2deb035254 Cleaning deps.
2014-08-07 19:42:41 -04:00

45 lines
880 B
Ruby

require 'tmpdir'
require 'vimrunner'
module Support
def assert_correct_indenting(string)
whitespace = string.scan(/^\s*/).first
string = string.split("\n").map { |line| line.gsub /^#{whitespace}/, '' }.join("\n").strip
File.open 'test.rb', 'w' do |f|
f.write string
end
@vim.edit 'test.rb'
@vim.normal 'gg=G'
@vim.write
IO.read('test.rb').strip.should eq string
end
end
RSpec.configure do |config|
include Support
config.before(:suite) do
VIM = Vimrunner.start_gvim
VIM.prepend_runtimepath(File.expand_path('../..', __FILE__))
end
config.after(:suite) do
VIM.kill
end
config.around(:each) do |example|
@vim = VIM
# cd into a temporary directory for every example.
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
@vim.command("cd #{dir}")
example.call
end
end
end
end