]> git.madduck.net Git - etc/vim.git/blob - spec/spec_helper.rb

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Coverage reporting via covimerage (#107)
[etc/vim.git] / spec / spec_helper.rb
1 require 'vimrunner'
2 require 'vimrunner/rspec'
3 require 'vimrunner/server'
4
5 # Explicitly enable usage of "should".
6 RSpec.configure do |config|
7     config.expect_with(:rspec) { |c| c.syntax = :should }
8 end
9
10 Vimrunner::RSpec.configure do |config|
11   # Use a single Vim instance for the test suite. Set to false to use an
12   # instance per test (slower, but can be easier to manage).
13   # This requires using gvim, otherwise it hangs after a few tests.
14   config.reuse_server = ENV['VIMRUNNER_REUSE_SERVER'] == '1' ? true : false
15
16   config.start_vim do
17     exe = config.reuse_server ? Vimrunner::Platform.gvim : Vimrunner::Platform.vim
18     vimrc = File.expand_path("../vimrc", __FILE__)
19     vim = Vimrunner::Server.new(:executable => exe,
20                                 :vimrc => vimrc).start
21     # More friendly killing.
22     # Otherwise profiling information might not be written.
23     def vim.kill
24       normal(':qall!')
25     end
26
27     plugin_path = File.expand_path('../..', __FILE__)
28     vim.command "set rtp^=#{plugin_path}"
29     vim.command "set filetype=python"
30
31     def shiftwidth
32       @shiftwidth ||= vim.echo("exists('*shiftwidth') ? shiftwidth() : &sw").to_i
33     end
34     def tabstop
35       @tabstop ||= vim.echo("&tabstop").to_i
36     end
37     def indent
38       vim.echo("indent('.')").to_i
39     end
40     def previous_indent
41       pline = vim.echo("line('.')").to_i - 1
42       vim.echo("indent('#{pline}')").to_i
43     end
44     def proposed_indent
45       line = vim.echo("line('.')")
46       col = vim.echo("col('.')")
47       indent_value = vim.echo("GetPythonPEPIndent(#{line})").to_i
48       vim.command("call cursor(#{line}, #{col})")
49       return indent_value
50     end
51     def multiline_indent(prev, default)
52       i = vim.echo("get(g:, 'python_pep8_indent_multiline_string', 0)").to_i
53       return (i == -2 ? default : i), i < 0 ? (i == -1 ? prev : default) : i
54     end
55     def hang_closing
56       i = vim.echo("get(g:, 'python_pep8_indent_hang_closing', 0)").to_i
57       return (i != 0)
58     end
59     def set_hang_closing(value)
60       i = value ? 1 : 0
61       vim.command("let g:python_pep8_indent_hang_closing=#{i}")
62     end
63
64     vim
65   end
66 end