ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Test​RSpec

by astrauka ALL

RSpec plugin for Sublime Text 3

Labels ruby, testing, rspec, spec

Details

Installs

  • Total 4K
  • Win 506
  • Mac 3K
  • Linux 851
Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4 Sep 3 Sep 2 Sep 1 Aug 31 Aug 30 Aug 29 Aug 28 Aug 27 Aug 26 Aug 25 Aug 24 Aug 23 Aug 22 Aug 21 Aug 20 Aug 19 Aug 18 Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12 Aug 11
Windows 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0
Mac 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 1 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Sublime TestRSpec

RSpec plugin for Sublime Text 3.

Run, navigate and create specs from Sublime Text.

Features

Installation

Using Package Control:

  1. Run “Package Control: Install Package” command, find and install TestRspec.
  2. Define key bindings (see Configuration section below).
  3. Restart Sublime Text.

Manually:

  1. Clone this repository into your packages folder (in Sublime Text: Preferences -> Browse Packages).
  2. Define key bindings (see Configuration section below).
  3. Restart Sublime Text.

Configuration

TestRSpec tries its best to autodetect how to run RSpec. However, you might need to make adjustments to plugin's configuration if you have an uncommon setup.

There are no key bindings enabled by default. Go to Preferences -> Package Settings -> TestRSpec -> Key Bindings to define key bindings.

Find settings in Preferences -> Package Settings -> TestRSpec.

Default settings

Features

Run RSpec

Launch RSpec for:

  • Current file
  • Current line
  • Rerun last run spec

Switch between code and spec

Jumps from code to spec and vice versa. If there multiple matches, it shows a list with matches.

Create a spec file

Creates a spec file when run in a source file.

Uses code snippet defined in settings (create_spec_snippet).

Copy last ran RSpec command

Copies the command of the last run spec. It can be useful e.g. when you want to debug your application within a 'real' terminal.

Tips

Ignore binding.pry when running specs

Sublime does not allow input in the output panel, so if you add binding.pry, tests get stuck waiting on input.

To work around this, you can disable the debugger by modifying TestRSpec configuration:

{
  "env": {
    "DISABLE_PRY": "true"
  }
}

Alternatively, use pry-remote.

Troubleshooting

Ruby not found or wrong ruby version used

Example error:

/usr/bin/env: ruby: No such file or directory

Override PATH variable in your shell configuration (~/.bashrc or ~/.bash_profile). Make sure ruby command runs the right Ruby version in bash.

Alternatively, update package settings with path to ruby, e.g.:

{
  "rspec_add_to_path": "$HOME/.rbenv/shims"
}

Spring is not used

Make sure you have both spring and spring-commands-rspec in your Gemfile.

If you use binstubs, you also need to run

bundle exec spring binstub rspec

Acknowledgments

Inspired by and uses code from https://github.com/maltize/sublime-text-2-ruby-tests

Contribution

Help is always welcome. Create an issue if you need help.

Copyright and license

Copyright © 2016 @astrauka

Licensed under the MIT license.