Skip to content

Commit f5af5d3

Browse files
committed
C-c C-b tf: Toggle focus rocket for test.
1 parent bf7fd38 commit f5af5d3

4 files changed

Lines changed: 64 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ with [Buster.js](http://busterjs.org).
88
All keybindings in buster-mode start with `C-c C-b` and then a two-letter mnemonic shortcut.
99

1010
* `td`: toggle-deferred will toggle // in the name of the current test.
11+
* `tf`: toggle-focus-rocket will toggle => in the name of the current test.
1112

1213
## Development
1314

buster-mode.el

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
(defun buster-goto-current-test ()
22
(search-backward-regexp "[\"'][^ ]* .+[\"']: function" nil t))
33

4-
(defun buster-toggle-deffered ()
5-
(interactive)
4+
(defun buster-toggle-test-name-prefix (prefix)
65
(save-excursion
76
(buster-goto-current-test)
87
(forward-char 1)
9-
(if (looking-at "//")
10-
(delete-char 2)
11-
(insert "//"))))
8+
(if (not (looking-at prefix))
9+
(insert prefix " ")
10+
(delete-char (length prefix))
11+
(while (looking-at " ") (delete-char 1)))))
12+
13+
(defun buster-toggle-deffered ()
14+
(interactive)
15+
(buster-toggle-test-name-prefix "//"))
16+
17+
(defun buster-toggle-focus-rocket ()
18+
(interactive)
19+
(buster-toggle-test-name-prefix "=>"))
1220

1321
(defvar buster-mode-map (make-sparse-keymap)
1422
"buster-mode keymap")
1523

1624
(define-key buster-mode-map
1725
(kbd "C-c C-b td") 'buster-toggle-deffered)
26+
(define-key buster-mode-map
27+
(kbd "C-c C-b tf") 'buster-toggle-focus-rocket)
1828

1929
(define-minor-mode buster-mode
2030
"Buster mode"

features/toggle-deferred.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Feature: Toggle deferred
1111
"""
1212
And I go to the front of the word "assert"
1313
And I press "C-c C-b td"
14-
Then I should not see "//contains"
14+
Then I should not see "// contains"
1515

1616
Scenario: Deferring a test
1717
When I insert:
@@ -25,22 +25,22 @@ Feature: Toggle deferred
2525
And I turn on buster-mode
2626
And I go to the front of the word "assert"
2727
And I press "C-c C-b td"
28-
Then I should see "//contains"
28+
Then I should see "// contains"
2929
And the cursor should be before "assert"
3030

3131
Scenario: Undeferring a test
3232
When I insert:
3333
"""
3434
buster.testCase('Building Page', {
35-
"//contains title after loading page": function () {
35+
"// contains title after loading page": function () {
3636
assert.match(document.body.innerHTML, "Zombie TDD");
3737
}
3838
});
3939
"""
4040
And I turn on buster-mode
4141
And I go to the front of the word "assert"
4242
And I press "C-c C-b td"
43-
Then I should not see "//contains"
43+
Then I should not see "// contains"
4444

4545
Scenario: Deferring a single quoted test
4646
When I insert:
@@ -54,4 +54,4 @@ Feature: Toggle deferred
5454
And I turn on buster-mode
5555
And I go to the front of the word "assert"
5656
And I press "C-c C-b td"
57-
Then I should see "'//contains"
57+
Then I should see "'// contains"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Feature: Toggle focus rocket
2+
3+
Scenario: Focus test
4+
When I insert:
5+
"""
6+
buster.testCase('Building Page', {
7+
"contains title after loading page": function () {
8+
assert.match(document.body.innerHTML, "Zombie TDD");
9+
}
10+
});
11+
"""
12+
And I turn on buster-mode
13+
And I go to the front of the word "assert"
14+
And I press "C-c C-b tf"
15+
Then I should see "=> contains"
16+
17+
Scenario: Blur test
18+
When I insert:
19+
"""
20+
buster.testCase('Building Page', {
21+
"=> contains title after loading page": function () {
22+
assert.match(document.body.innerHTML, "Zombie TDD");
23+
}
24+
});
25+
"""
26+
And I turn on buster-mode
27+
And I go to the front of the word "assert"
28+
And I press "C-c C-b tf"
29+
Then I should not see "=> contains"
30+
31+
Scenario: Blur test even when user hasn't added a space at the end
32+
When I insert:
33+
"""
34+
buster.testCase('Building Page', {
35+
"=>contains title after loading page": function () {
36+
assert.match(document.body.innerHTML, "Zombie TDD");
37+
}
38+
});
39+
"""
40+
And I turn on buster-mode
41+
And I go to the front of the word "assert"
42+
And I press "C-c C-b tf"
43+
Then I should not see "=>contains"

0 commit comments

Comments
 (0)