Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
back-fill vimrunner specs small bugfix
- Loading branch information
Andrew Bruce
committed
Apr 1, 2012
1 parent
85b7932
commit faf0677
Showing
9 changed files
with
282 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--color | ||
--debugger | ||
--order random | ||
-fd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This is an RVM Project .rvmrc file, used to automatically load the ruby | ||
# development environment upon cd'ing into the directory | ||
|
||
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional. | ||
environment_id="ruby-1.9.2-p290@test_server" | ||
|
||
# | ||
# Uncomment the following lines if you want to verify rvm version per project | ||
# | ||
# rvmrc_rvm_version="1.10.2" # 1.10.1 seams as a safe start | ||
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || { | ||
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading." | ||
# return 1 | ||
# } | ||
# | ||
|
||
# | ||
# Uncomment following line if you want options to be set only for given project. | ||
# | ||
# PROJECT_JRUBY_OPTS=( --1.9 ) | ||
# | ||
# The variable PROJECT_JRUBY_OPTS requires the following to be run in shell: | ||
# | ||
# chmod +x ${rvm_path}/hooks/after_use_jruby_opts | ||
# | ||
|
||
# | ||
# First we attempt to load the desired environment directly from the environment | ||
# file. This is very fast and efficient compared to running through the entire | ||
# CLI and selector. If you want feedback on which environment was used then | ||
# insert the word 'use' after --create as this triggers verbose mode. | ||
# | ||
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \ | ||
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] | ||
then | ||
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id" | ||
|
||
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] | ||
then | ||
. "${rvm_path:-$HOME/.rvm}/hooks/after_use" | ||
fi | ||
else | ||
# If the environment file has not yet been created, use the RVM CLI to select. | ||
if ! rvm --create use "$environment_id" | ||
then | ||
echo "Failed to create RVM environment '${environment_id}'." | ||
return 1 | ||
fi | ||
fi | ||
|
||
# | ||
# If you use an RVM gemset file to install a list of gems (*.gems), you can have | ||
# it be automatically loaded. Uncomment the following and adjust the filename if | ||
# necessary. | ||
# | ||
# filename=".gems" | ||
# if [[ -s "$filename" ]] | ||
# then | ||
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d' | ||
# fi | ||
|
||
# If you use bundler, this might be useful to you: | ||
# if [[ -s Gemfile ]] && ! command -v bundle >/dev/null | ||
# then | ||
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n" | ||
# gem install bundler | ||
# fi | ||
# if [[ -s Gemfile ]] && command -v bundle | ||
# then | ||
# bundle install | ||
# fi | ||
|
||
if [[ $- == *i* ]] # check for interactive shells | ||
then | ||
echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green | ||
else | ||
echo "Using: $GEM_HOME" # don't use colors in interactive shells | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source "http://rubygems.org" | ||
|
||
gem 'rspec' | ||
gem 'vimrunner', git: "https://github.com/camelpunch/vimrunner" | ||
gem 'ruby-debug19' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
GIT | ||
remote: https://github.com/camelpunch/vimrunner | ||
revision: 9e1ebfc1026f8d24f93c5fe8f3db526dc8299557 | ||
specs: | ||
vimrunner (0.0.2) | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
archive-tar-minitar (0.5.2) | ||
columnize (0.3.6) | ||
diff-lcs (1.1.3) | ||
linecache19 (0.5.12) | ||
ruby_core_source (>= 0.1.4) | ||
rspec (2.9.0) | ||
rspec-core (~> 2.9.0) | ||
rspec-expectations (~> 2.9.0) | ||
rspec-mocks (~> 2.9.0) | ||
rspec-core (2.9.0) | ||
rspec-expectations (2.9.0) | ||
diff-lcs (~> 1.1.3) | ||
rspec-mocks (2.9.0) | ||
ruby-debug-base19 (0.11.25) | ||
columnize (>= 0.3.1) | ||
linecache19 (>= 0.5.11) | ||
ruby_core_source (>= 0.1.4) | ||
ruby-debug19 (0.11.6) | ||
columnize (>= 0.3.1) | ||
linecache19 (>= 0.5.11) | ||
ruby-debug-base19 (>= 0.11.19) | ||
ruby_core_source (0.1.5) | ||
archive-tar-minitar (>= 0.5.2) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
rspec | ||
ruby-debug19 | ||
vimrunner! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
require 'tempfile' | ||
require 'vimrunner' | ||
|
||
# NB: don't type / move mouse while spec is running! | ||
describe "test_client.vim" do | ||
let!(:vim) do | ||
Vimrunner::Runner.start_vim.tap do |vim| | ||
vim.normal ":let g:test_server_pipe = '#{file.path}'<CR>" | ||
vim.command "source plugin/test_client.vim" | ||
end | ||
end | ||
|
||
after do | ||
vim.normal ":q!<CR>" | ||
FileUtils.rm_f ".#{filename}.swp" if defined? filename | ||
end | ||
|
||
let(:file) { Tempfile.new('test_client_spec_pipe') } | ||
let(:spec_filename) { 'example_spec.rb' } | ||
|
||
def run_test | ||
vim.command 'call RunTest()' | ||
end | ||
|
||
def run_line | ||
vim.command 'call RunTestLine()' | ||
end | ||
|
||
def edit(path) | ||
vim.edit path | ||
end | ||
|
||
def pipe | ||
file.read | ||
end | ||
|
||
describe "running when there is no file open" do | ||
it "does not send anything to the pipe" do | ||
run_test | ||
pipe.should be_empty | ||
end | ||
end | ||
|
||
shared_examples_for "the whole spec is run" do | ||
context "(shared)" do | ||
before { edit filename } | ||
|
||
it "sends the spec file path to the pipe" do | ||
run_test | ||
pipe.should =~ /#{spec_filename}$/ | ||
end | ||
|
||
it "shows an appropriate message" do | ||
run_test.should =~ /#{spec_filename}/ | ||
end | ||
end | ||
end | ||
|
||
describe "running a whole spec from the spec file" do | ||
let(:filename) { 'example_spec.rb' } | ||
it_behaves_like "the whole spec is run" | ||
end | ||
|
||
describe "running a whole spec from the source file" do | ||
let(:filename) { 'example.rb' } | ||
it_behaves_like "the whole spec is run" | ||
end | ||
|
||
describe "running a line spec focused to a line from the spec file" do | ||
let(:filename) { 'example_spec.rb' } | ||
|
||
before do | ||
edit filename | ||
vim.insert((['some text'] * 10).join("\n")) | ||
vim.normal "5gg" | ||
end | ||
|
||
it "sends the spec file path to the pipe, with the line number" do | ||
run_line | ||
pipe.should =~ /#{spec_filename}:5$/ | ||
end | ||
|
||
it "shows an appropriate message" do | ||
run_line.should =~ /#{spec_filename}:5/ | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
call writefile([''], 'fakepipe') | ||
|
||
let g:dir = expand('<sfile>:p:h') | ||
let g:spec_filename = [g:dir . '/example_spec.rb'] | ||
SpecBegin 'title': 'test client', | ||
\ 'sfile': g:dir . '/../plugin/test_client.vim', | ||
\ 'file': g:spec_filename, | ||
\ 'before': 'call RunTest()' | ||
|
||
It should be able to run the whole test file. | ||
Should be equal readfile('fakepipe'), g:spec_filename |