rebase on 2015
[Vimrc.git] / bundle / vim-ruby-vim7.4 / spec / spec_helper.rb
bloba11bb6f17ace70285b148d3434a42210f88614fd
1 require 'tmpdir'
2 require 'vimrunner'
4 module Support
5   def assert_correct_indenting(string)
6     whitespace = string.scan(/^\s*/).first
7     string = string.split("\n").map { |line| line.gsub /^#{whitespace}/, '' }.join("\n").strip
9     File.open 'test.rb', 'w' do |f|
10       f.write string
11     end
13     @vim.edit 'test.rb'
14     @vim.normal 'gg=G'
15     @vim.write
17     IO.read('test.rb').strip.should eq string
18   end
19 end
21 RSpec.configure do |config|
22   include Support
24   config.before(:suite) do
25     VIM = Vimrunner.start_gvim
26     VIM.prepend_runtimepath(File.expand_path('../..', __FILE__))
27   end
29   config.after(:suite) do
30     VIM.kill
31   end
33   config.around(:each) do |example|
34     @vim = VIM
36     # cd into a temporary directory for every example.
37     Dir.mktmpdir do |dir|
38       Dir.chdir(dir) do
39         @vim.command("cd #{dir}")
40         example.call
41       end
42     end
43   end
44 end