Skip to content
This repository was archived by the owner on Jun 8, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.bundle/
bin/
1 change: 1 addition & 0 deletions tests/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
4 changes: 4 additions & 0 deletions tests/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

gem 'rspec', '~> 3'
gem 'vimrunner', '~> 0.3'
28 changes: 28 additions & 0 deletions tests/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.3)
rspec (3.7.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
vimrunner (0.3.4)

PLATFORMS
ruby

DEPENDENCIES
rspec (~> 3)
vimrunner (~> 0.3)

BUNDLED WITH
1.16.0
23 changes: 23 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Tests #

The motivation at the time of writing is to be able to refactor
`lib/functions.vim` test running functions so that they can be extended. For example
it would be nice to add python/pytest running without hacking in yet more code to this
file.

## Setup ##

Currently the tests depend on [vimrunner](https://github.com/AndrewRadev/vimrunner)
and have only been run against macvim. The reason for macvim is it has a reliable
vim client server implementation that normal vim does not, at least not vim with
xquartz on macos.

### Install macvim ###

brew cask install macvim

## Run tests ##

cd tests
bundle install
bundle exec rspec spec
Empty file.
Empty file.
Empty file.
67 changes: 67 additions & 0 deletions tests/spec/functions.vim/run_tests_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
describe 'running tests with luan vim' do
before do
if vipe_file.exist?
vipe_file.delete
end
end

let(:vim_with_functions) {
vim.source("#{ENV['HOME']}/.vim/plugged/vipe/plugin/vipe.vim")
vim.source("#{ENV['HOME']}/.vim/lib/functions.vim")

dir, filename = test_path.split
vim.command("cd #{dir}")
vim.edit(filename)
vim
}

let(:vipe_file) {
Pathname.new('/tmp')
.join(".vipe_pipe_#{test_path.dirname.to_s.gsub('/', '_')}")
}

let(:last_command) {
vipe_file.readlines.last.chomp
}

let(:fixture_path) {
Pathname.new(ENV['HOME']).join(
'.vim',
'tests',
'spec',
'fixtures'
)
}

def run_test_file(vim)
vim.command('call RunTestFile()')
end

context 'editing an rspec file' do
let(:test_path) {
fixture_path.join(
'ruby',
'rspec_spec.rb'
)
}

it 'runs the rspec command' do
run_test_file(vim_with_functions)
expect(last_command).to eq('rspec --color rspec_spec.rb')
end
end

context 'editing an rspec file in a bundler environment' do
let(:test_path) {
fixture_path.join(
'ruby_with_bundler',
'rspec_spec.rb'
)
}

it 'runs the rspec command in the bundler environment' do
run_test_file(vim_with_functions)
expect(last_command).to eq('bundle exec rspec --color rspec_spec.rb')
end
end
end
23 changes: 23 additions & 0 deletions tests/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'vimrunner'
require 'vimrunner/rspec'

# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end

config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end

config.shared_context_metadata_behavior = :apply_to_host_groups
end

Vimrunner::RSpec.configure do |config|
config.reuse_server = true
config.start_vim do
vim = Vimrunner.start_gvim
vim
end
end