thoughtbot/vim-rspec — pull request #18 by christoomey (2013-05-29 00:55:49+00:00)
Title: Make writing current buffer optional

I regularly use the "last spec" functionality by executing the plugin from while in the implementation file. In addition, I am usually running within a preloader ([zeus][] in this case), and writing the implementation file causes zeus to reload the file. This introduces an lag in running the spec. The following highlights the relative timing

``` shell
# Running without writing either spec of implementation file
time zeus rspec spec/models/advertiser/elastic_update/keyword_view_spec.rb:87
Finished in 0.38817 seconds
1 example, 0 failures
1.33 real 0.46 user 0.03 sys

# Writing spec file has minimal impact on preloader
touch spec/models/advertiser/elastic_update/keyword_view_spec.rb && time zeus rspec spec/models/advertiser/elastic_update/keyword_view_spec.rb:87
Finished in 0.4218 seconds
1 example, 0 failures
1.29 real 0.46 user 0.03 sys

# Writing the implementation file causes the rails env to be reloaded
touch app/models/advertiser/elastic_update/keyword_view.rb && time zeus rspec spec/models/advertiser/elastic_update/keyword_view_spec.rb:87
Finished in 0.27992 seconds
1 example, 0 failures
8.28 real 0.48 user 0.03 sys
```

This pull makes writing the current buffer optional. This seems like the most straightforward solution, but another option would be to only write when in the spec file:

```vim
function! RunSpecs(spec)
if InSpecFile()
write
endif
execute substitute(g:rspec_command, "{spec}", a:spec, "g")
endfunction
```

[zeus]: https://github.com/burke/zeus