Skip to content

Run RSpec tests. View failure messages as diagnostic entries in Neovim

License

Notifications You must be signed in to change notification settings

ilvez/rspec-integrated.nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rspec-integrated.nvim

rspec-integrated.nvim

RSpec part

It runs _spec.rb files with bundle exec rspec.

Integrated part

It integrates the test results back into neovim. So you don't have to take your attention away from coding.

It uses the built-in neovim features to integrate seamlessly into your existing workflow.

  • RSpec execution
    • Started/completed notifications: vim.notify
    • Asynchronous run: vim.fn.jobstart
  • Test result presentation: vim.diagnostics

Features

  • Runs RSpec test files.
  • Executes a single test example determined by the cursor position.
  • Remembers the last spec file and can re-run it while in the production code buffer.
    Ideal during TDD and/or refactoring.
  • Saves the current buffer before execution. One less action to keep in mind.

Installation

Neovim version 0.7.0 or higher is required.

Please refer to your plugin manager's usage guide.

Example installation with packer.nvim
use { "melopilosyan/rspec-integrated.nvim" }

Usage

By default rspec-integrated.nvim doesn't add any mappings or create user commands. In fact, it will be auto-loaded only on the first invocation.

Add mappings in your neovim configuration to invoke the exposed function.

-- Lua API
vim.keymap.set("n", "<leader>tI", "<cmd>lua require('rspec.integrated').run_spec_file()<cr>", { silent = true, noremap = true })
vim.keymap.set("n", "<leader>ti", "<cmd>lua require('rspec.integrated').run_spec_file({only_current_example = true})<cr>", { silent = true, noremap = true })
" VimL
nnoremap <leader>tI <cmd>lua require('rspec.integrated').run_spec_file()<cr>
nnoremap <leader>ti <cmd>lua require('rspec.integrated').run_spec_file({only_current_example = true})<cr>

Configuration

The plugin has no configuration. You should be able to just say “RSpec run” and see the notifications as you have configured them, or open/jump to diagnostic entries as you normally do with LSP or linter messages.

Credits

Big shout-out to @tjdevries for the initial idea. Watch his video tutorial, which was the inspiration for rspec-integrated.nvim.

About

Run RSpec tests. View failure messages as diagnostic entries in Neovim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%