Permalink
Browse files

`C-c C-b tf`: Toggle focus rocket for test.

  • Loading branch information...
magnars committed Jun 16, 2012
1 parent bf7fd38 commit f5af5d31fb788364c06f77eec5736a5f29282873
Showing with 64 additions and 10 deletions.
  1. +1 −0 README.md
  2. +15 −5 buster-mode.el
  3. +5 −5 features/toggle-deferred.feature
  4. +43 −0 features/toggle-focus-rocket.feature
View
@@ -8,6 +8,7 @@ with [Buster.js](http://busterjs.org).
All keybindings in buster-mode start with `C-c C-b` and then a two-letter mnemonic shortcut.
* `td`: toggle-deferred will toggle // in the name of the current test.
+* `tf`: toggle-focus-rocket will toggle => in the name of the current test.
## Development
View
@@ -1,20 +1,30 @@
(defun buster-goto-current-test ()
(search-backward-regexp "[\"'][^ ]* .+[\"']: function" nil t))
-(defun buster-toggle-deffered ()
- (interactive)
+(defun buster-toggle-test-name-prefix (prefix)
(save-excursion
(buster-goto-current-test)
(forward-char 1)
- (if (looking-at "//")
- (delete-char 2)
- (insert "//"))))
+ (if (not (looking-at prefix))
+ (insert prefix " ")
+ (delete-char (length prefix))
+ (while (looking-at " ") (delete-char 1)))))
+
+(defun buster-toggle-deffered ()
+ (interactive)
+ (buster-toggle-test-name-prefix "//"))
+
+(defun buster-toggle-focus-rocket ()
+ (interactive)
+ (buster-toggle-test-name-prefix "=>"))
(defvar buster-mode-map (make-sparse-keymap)
"buster-mode keymap")
(define-key buster-mode-map
(kbd "C-c C-b td") 'buster-toggle-deffered)
+(define-key buster-mode-map
+ (kbd "C-c C-b tf") 'buster-toggle-focus-rocket)
(define-minor-mode buster-mode
"Buster mode"
@@ -11,7 +11,7 @@ Feature: Toggle deferred
"""
And I go to the front of the word "assert"
And I press "C-c C-b td"
- Then I should not see "//contains"
+ Then I should not see "// contains"
Scenario: Deferring a test
When I insert:
@@ -25,22 +25,22 @@ Feature: Toggle deferred
And I turn on buster-mode
And I go to the front of the word "assert"
And I press "C-c C-b td"
- Then I should see "//contains"
+ Then I should see "// contains"
And the cursor should be before "assert"
Scenario: Undeferring a test
When I insert:
"""
buster.testCase('Building Page', {
- "//contains title after loading page": function () {
+ "// contains title after loading page": function () {
assert.match(document.body.innerHTML, "Zombie TDD");
}
});
"""
And I turn on buster-mode
And I go to the front of the word "assert"
And I press "C-c C-b td"
- Then I should not see "//contains"
+ Then I should not see "// contains"
Scenario: Deferring a single quoted test
When I insert:
@@ -54,4 +54,4 @@ Feature: Toggle deferred
And I turn on buster-mode
And I go to the front of the word "assert"
And I press "C-c C-b td"
- Then I should see "'//contains"
+ Then I should see "'// contains"
@@ -0,0 +1,43 @@
+Feature: Toggle focus rocket
+
+ Scenario: Focus test
+ When I insert:
+ """
+ buster.testCase('Building Page', {
+ "contains title after loading page": function () {
+ assert.match(document.body.innerHTML, "Zombie TDD");
+ }
+ });
+ """
+ And I turn on buster-mode
+ And I go to the front of the word "assert"
+ And I press "C-c C-b tf"
+ Then I should see "=> contains"
+
+ Scenario: Blur test
+ When I insert:
+ """
+ buster.testCase('Building Page', {
+ "=> contains title after loading page": function () {
+ assert.match(document.body.innerHTML, "Zombie TDD");
+ }
+ });
+ """
+ And I turn on buster-mode
+ And I go to the front of the word "assert"
+ And I press "C-c C-b tf"
+ Then I should not see "=> contains"
+
+ Scenario: Blur test even when user hasn't added a space at the end
+ When I insert:
+ """
+ buster.testCase('Building Page', {
+ "=>contains title after loading page": function () {
+ assert.match(document.body.innerHTML, "Zombie TDD");
+ }
+ });
+ """
+ And I turn on buster-mode
+ And I go to the front of the word "assert"
+ And I press "C-c C-b tf"
+ Then I should not see "=>contains"

0 comments on commit f5af5d3

Please sign in to comment.