Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spec-utils.nvim

spec-utils.nvim is a Neovim plugin providing utilities to simplify the creation and execution of tests.

Project Structure

.
├── lua
│   └── spec-utils
│       ├── file.lua
│       ├── init.lua
│       ├── tests
│       │   ├── file_spec.lua
│       │   └── utils_spec.lua
│       └── utils.lua
└── plugin
    └── spec-utils.lua

Features

  • Utils: General-purpose utility functions.
  • File: General-purpose to handle the path functions.
  • Test Support: Compatible with plenary.nvim.

Installation

Using Lazy.nvim:

{
  'ally1002/spec-utils.nvim',
  dependencies = {
    { 'nvim-lua/plenary.nvim', name = 'plenary' },
  },
}

Usage

Example

Add the following configuration to your init.lua or init.vim:

{
  'ally1002/spec-utils.nvim',
  dependencies = {
    { 'nvim-lua/plenary.nvim', name = 'plenary' },
  },
  config = function()
    require('spec-utils').setup()

    local Utils = require 'spec-utils.utils'
    local File = require 'spec-utils.file'

    vim.keymap.set('n', '<leader><C-t>', function()
      Utils.switch_between_test_and_implementation(vim.api.nvim_buf_get_name(0))
    end)

    vim.keymap.set('n', '<leader><C-y>', function()
      File.copy_test_file(vim.api.nvim_buf_get_name(0))
    end)
  end,
}

Commands

Command Description
:SpecUtils copy_test_file Copy the test file path.
:SpecUtils copy_implementation_file Copy the implementation file path.
:SpecUtils copy_current_relative_path Copy the current relative path.

Writing Tests

Refer to the examples in the lua/spec-utils/tests directory to understand how to use each module.

Development

Running Tests

Tests are executed using the plenary.nvim framework. Run the tests with:

:lua require('plenary.test_harness').test_directory('lua/spec-utils/tests')

Test Organization

Tests are organized by module for easy expansion and maintenance:

  • Utils tests: utils_spec.lua
  • File tests: file_spec.lua

Contributing

Contributions are welcome! Follow these steps:

  1. Fork this repository.
  2. Create a new branch: git checkout -b my-feature.
  3. Commit your changes: git commit -m 'Add my feature'.
  4. Push to the branch: git push origin my-feature.
  5. Open a pull request.

License

This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages