ruby: replace ruby-use-ruby-test by ruby-test-runner
Also cleanup configuration.
This commit is contained in:
parent
cf5bc0a634
commit
7e0d8f2d32
|
@ -8,12 +8,13 @@
|
|||
- [[Install][Install]]
|
||||
- [[Prerequisites][Prerequisites]]
|
||||
- [[Ruby version management][Ruby version management]]
|
||||
- [[Testing frameworks][Testing frameworks]]
|
||||
- [[Test runner][Test runner]]
|
||||
- [[Key bindings][Key bindings]]
|
||||
- [[Ruby (enh-ruby-mode, robe, inf-ruby, ruby-tools)][Ruby (enh-ruby-mode, robe, inf-ruby, ruby-tools)]]
|
||||
- [[RSpec-mode][RSpec-mode]]
|
||||
- [[Ruby-test-mode][Ruby-test-mode]]
|
||||
- [[RuboCop][RuboCop]]
|
||||
- [[Tests][Tests]]
|
||||
- [[RSpec-mode][RSpec-mode]]
|
||||
- [[Ruby-test-mode][Ruby-test-mode]]
|
||||
|
||||
* Description
|
||||
This layer provides support for the Ruby language with [[https://github.com/zenspider/enhanced-ruby-mode][enh-ruby-mode]] and [[https://github.com/dgutov/robe][robe-mode]].
|
||||
|
@ -63,24 +64,27 @@ This layer supports the use of [[https://rvm.io/][RVM]] and [[https://github.com
|
|||
To enable it, set the =ruby-version-manager= var in your =~/.spacemacs=:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun dotspacemacs/user-init ()
|
||||
(setq-default ruby-version-manager 'rbenv)
|
||||
)
|
||||
(defun dotspacemacs-configuration-layers ()
|
||||
'((ruby :variables ruby-version-manager 'rbenv)))
|
||||
#+END_SRC
|
||||
|
||||
Possible values are =rbenv= and =rvm=.
|
||||
|
||||
** Testing frameworks
|
||||
This layer supports both RSpec and ruby-test.
|
||||
By default RSpec is used, this is a change in the old behaviour.
|
||||
To switch to using ruby-test set =ruby-use-ruby-test= to t:
|
||||
** Test runner
|
||||
This layer supports both =RSpec= and =ruby-test= test runners (frameworks).
|
||||
By default =ruby-test= is used, to change to another frameworks set
|
||||
the layer variable =ruby-test-runner=.
|
||||
|
||||
Example to set the test runner to =RSpec=:
|
||||
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun dotspacemacs/user-init ()
|
||||
(setq-default ruby-use-ruby-test t)
|
||||
)
|
||||
(defun dotspacemacs-configuration-layers ()
|
||||
'((ruby :variables ruby-test-runner 'rspec)))
|
||||
#+END_SRC
|
||||
|
||||
=Tip:= You can enable different test runners for different projects by using
|
||||
directory local variables.
|
||||
|
||||
* Key bindings
|
||||
** Ruby (enh-ruby-mode, robe, inf-ruby, ruby-tools)
|
||||
|
||||
|
@ -101,22 +105,6 @@ To switch to using ruby-test set =ruby-use-ruby-test= to t:
|
|||
| ~SPC m x :~ | Change string to symbol |
|
||||
| ~%~ | [[https://github.com/redguardtoo/evil-matchit][evil-matchit]] jumps between blocks |
|
||||
|
||||
** RSpec-mode
|
||||
|
||||
| Key binding | Description |
|
||||
|-------------+----------------------|
|
||||
| ~SPC m t a~ | run all specs |
|
||||
| ~SPC m t f~ | run last failed spec |
|
||||
| ~SPC m t r~ | re-run last spec |
|
||||
| ~SPC m t t~ | run spec at pointer |
|
||||
|
||||
** Ruby-test-mode
|
||||
|
||||
| Key binding | Description |
|
||||
|-------------+---------------------|
|
||||
| ~SPC m t b~ | run test file |
|
||||
| ~SPC m t t~ | run test at pointer |
|
||||
|
||||
** RuboCop
|
||||
|
||||
| Key binding | Description |
|
||||
|
@ -127,3 +115,22 @@ To switch to using ruby-test set =ruby-use-ruby-test= to t:
|
|||
| ~SPC m r r D~ | Prompts for a directory on which to run auto-correct |
|
||||
| ~SPC m r r p~ | Runs RuboCop on the entire project |
|
||||
| ~SPC m r r P~ | Runs auto-correct on the project |
|
||||
|
||||
** Tests
|
||||
*** RSpec-mode
|
||||
When =ruby-test-runner= equals =rspec=.
|
||||
|
||||
| Key binding | Description |
|
||||
|-------------+----------------------|
|
||||
| ~SPC m t a~ | run all specs |
|
||||
| ~SPC m t l~ | run last failed spec |
|
||||
| ~SPC m t r~ | re-run last spec |
|
||||
| ~SPC m t t~ | run spec at pointer |
|
||||
|
||||
*** Ruby-test-mode
|
||||
When =ruby-test-runner= equals =ruby-test=.
|
||||
|
||||
| Key binding | Description |
|
||||
|-------------+---------------------|
|
||||
| ~SPC m t b~ | run test file |
|
||||
| ~SPC m t t~ | run test at pointer |
|
||||
|
|
|
@ -16,12 +16,17 @@
|
|||
(spacemacs|defvar-company-backends ruby-mode)
|
||||
|
||||
(defvar ruby-enable-enh-ruby-mode nil
|
||||
"If non-nil, use `enh-ruby-mode' package insted of the built-in Ruby Mode.
|
||||
|
||||
Otherwise use Enh Ruby Mode, which is the default.")
|
||||
"If non-nil, use `enh-ruby-mode' package instead of the built-in Ruby Mode.")
|
||||
|
||||
(defvar ruby-version-manager nil
|
||||
"If non nil defines the Ruby version manager (i.e. rbenv, rvm)")
|
||||
"If non nil, defines the Ruby version manager (i.e. rbenv, rvm)")
|
||||
|
||||
(defvar ruby-use-ruby-test nil
|
||||
"If non-nil, use `ruby-test-mode' package instead of `rspec-mode'.")
|
||||
|
||||
(defvar ruby-test-runner 'ruby-test
|
||||
"Test runner to use. Possible values are `ruby-test' or `rspec'.")
|
||||
|
||||
;; Command prefixes
|
||||
|
||||
(spacemacs/declare-prefix-for-mode mode "mt" "ruby/test")
|
||||
|
|
|
@ -27,10 +27,6 @@
|
|||
(add-to-list 'ruby-packages 'enh-ruby-mode)
|
||||
(add-to-list 'ruby-packages 'ruby-mode))
|
||||
|
||||
(if ruby-use-ruby-test
|
||||
(add-to-list 'ruby-packages 'ruby-test-mode)
|
||||
(add-to-list 'ruby-packages 'rspec-mode))
|
||||
|
||||
(when ruby-version-manager
|
||||
(add-to-list 'ruby-packages ruby-version-manager))
|
||||
|
||||
|
@ -157,17 +153,23 @@
|
|||
"Define keybindings for rspec mode"
|
||||
(use-package rspec-mode
|
||||
:defer t
|
||||
:init (dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
||||
(add-hook hook 'rspec-mode))
|
||||
:init
|
||||
(progn
|
||||
(defun spacemacs//ruby-enable-rspec-mode ()
|
||||
"Conditionally enable `rspec-mode'"
|
||||
(when (eq 'rspec ruby-test-runner)
|
||||
(rspec-mode)))
|
||||
(spacemacs/add-to-hooks
|
||||
'spacemacs//ruby-enable-rspec-mode '(ruby-mode-hook
|
||||
enh-ruby-mode-hook)))
|
||||
:config
|
||||
(progn
|
||||
(spacemacs|hide-lighter rspec-mode)
|
||||
(dolist (mode '(ruby-mode enh-ruby-mode))
|
||||
(spacemacs/declare-prefix-for-mode mode "mt" "ruby/test")
|
||||
(spacemacs/set-leader-keys-for-major-mode mode
|
||||
"ta" 'rspec-verify-all
|
||||
"tc" 'rspec-verify-matching
|
||||
"tf" 'rspec-run-last-failed
|
||||
"tl" 'rspec-run-last-failed
|
||||
"tr" 'rspec-rerun
|
||||
"tt" 'rspec-verify-single)))))
|
||||
|
||||
|
@ -192,15 +194,22 @@
|
|||
"Define keybindings for ruby test mode"
|
||||
(use-package ruby-test-mode)
|
||||
:defer t
|
||||
:init (dolist (hook '(ruby-mode-hook enh-ruby-mode-hook))
|
||||
(add-hook hook 'ruby-test-mode))
|
||||
:init
|
||||
(progn
|
||||
(defun spacemacs//ruby-enable-ruby-test-mode ()
|
||||
"Conditionally enable `ruby-test-mode'"
|
||||
(when (eq 'ruby-test ruby-test-runner)
|
||||
(ruby-test-mode)))
|
||||
(spacemacs/add-to-hooks
|
||||
'spacemacs//ruby-enable-ruby-test-mode '(ruby-mode-hook
|
||||
enh-ruby-mode-hook)))
|
||||
:config
|
||||
(progn
|
||||
(spacemacs|hide-lighter ruby-test-mode)
|
||||
(dolist (mode '(ruby-mode enh-ruby-mode))
|
||||
(spacemacs/declare-prefix-for-mode mode "mt" "ruby/test")
|
||||
(evil-leader/set-key-for-mode mode "mtb" 'ruby-test-run)
|
||||
(evil-leader/set-key-for-mode mode "mtt" 'ruby-test-run-at-point))))
|
||||
(spacemacs/set-leader-keys-for-major-mode mode
|
||||
"tb" 'ruby-test-run
|
||||
"tt" 'ruby-test-run-at-point))))
|
||||
|
||||
(when (configuration-layer/layer-usedp 'auto-completion)
|
||||
(defun ruby/post-init-company ()
|
||||
|
|
Loading…
Reference in a new issue