diff options
author | Thomas Buckley-Houston | 2017-07-25 09:48:43 +0000 |
---|---|---|
committer | Thomas Buckley-Houston | 2017-07-25 09:48:43 +0000 |
commit | e00abb7772d53f118ca8662a0fcca03e2423c25d (patch) | |
tree | 37451b6dffb4fb88ab9aed82cf1e9ad04e365004 /spec/spec_helper.rb | |
parent | 70939c41f37173873096ec7cd5ad45e32f84b0cb (diff) |
Better non-wrapped HOME/END. Use system clipboard.
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r-- | spec/spec_helper.rb | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5b3e0ea..cfe5a51 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,17 +20,24 @@ Vimrunner::RSpec.configure do |config| end end -TEST_FILE = 'test_file.txt'.freeze +RSpec.configure do |config| + config.before :each do + # Default to setting the filetype to shell to enable + # code-like behaviour. + @ext = 'sh' + end +end -def write_file_content(string) +def write_file_content(string, ext = 'sh') + @file = "file.#{ext}" string = normalize_string_indent(string) - File.open(TEST_FILE, 'w') { |f| f.write(string) } - vim.edit TEST_FILE + File.open(@file, 'w') { |f| f.write(string) } + vim.edit @file end def load_file_content vim.write - IO.read(TEST_FILE).strip + IO.read(@file).strip end def type(string) @@ -42,3 +49,17 @@ def type(string) end end end + +def initial(string) + @vim_options.each { |x| vim.command(x) } if @vim_options + write_file_content(string, @ext) +end + +def final(string) + expected = normalize_string_indent(string) + expect(load_file_content).to eq expected +end + +def use_extension(ext) + @ext = ext +end |