Permalink
Browse files

Refactor features.

  • Loading branch information...
1 parent b25935e commit e0a302108b06a501ef051859a51563084c124cd2 @rejeep committed Jan 17, 2012
@@ -3,51 +3,46 @@ Feature: Drag Stuff
As an Emacs user
I want to drag them
- Background:
- Given I am in buffer "*drag-stuff*"
- And the buffer is empty
- And there is no region selected
-
Scenario: Global mode
When I open temp file "global"
- And I insert:
- """
- line 1
- line 2
- """
- And I load the following:
- """
- (drag-stuff-global-mode t)
- """
- And I go to line "1"
- And I press "<M-down>"
+ And I insert:
+ """
+ line 1
+ line 2
+ """
+ And I load the following:
+ """
+ (drag-stuff-global-mode t)
+ """
+ And I go to line "1"
+ And I press "<M-down>"
Then I should see:
"""
line 2
line 1
"""
-
+
Scenario: Global mode except
When I load the following:
"""
(setq drag-stuff-except-modes '(text-mode))
(drag-stuff-global-mode t)
"""
- And major mode is text-mode
+ And major mode is text-mode
When I insert:
"""
line 1
line 2
"""
- And I go to line "1"
- And I press "<M-down>"
+ And I go to line "1"
+ And I press "<M-down>"
Then I should see:
"""
line 1
line 2
"""
- And I should not see:
- """
- line 2
- line 1
- """
+ And I should not see:
+ """
+ line 2
+ line 1
+ """
View
@@ -4,19 +4,16 @@ Feature: Drag line
I want to drag it
Background:
- Given I am in buffer "*drag-stuff*"
- And the buffer is empty
- And I insert:
+ Given I insert:
"""
line 1
line 2
"""
- And there is no region selected
- And I enable drag-stuff
+ And I enable drag-stuff
Scenario: Drag line up
When I go to line "2"
- And I press "<M-up>"
+ And I press "<M-up>"
Then I should see:
"""
line 2
@@ -25,7 +22,7 @@ Feature: Drag line
Scenario: Drag line down
When I go to line "1"
- And I press "<M-down>"
+ And I press "<M-down>"
Then I should see:
"""
line 2
@@ -34,20 +31,20 @@ Feature: Drag line
Scenario: Drag line down out of scope
When I go to line "2"
- And I press "<M-down>"
+ And I press "<M-down>"
Then I should see:
"""
line 1
line 2
"""
- And I should see message "Can not move line further down"
+ And I should see message "Can not move line further down"
Scenario: Drag line up out of scope
When I go to line "1"
- And I press "<M-up>"
+ And I press "<M-up>"
Then I should see:
"""
line 1
line 2
"""
- And I should see message "Can not move line further up"
+ And I should see message "Can not move line further up"
@@ -4,83 +4,80 @@ Feature: Drag lines
I want to drag them
Background:
- Given I am in buffer "*drag-stuff*"
- And the buffer is empty
- And I insert:
+ Given I insert:
"""
line 1
line 2
line 3
"""
- And there is no region selected
And I enable drag-stuff
Scenario: Drag lines up
When I go to point "10"
- And I set the mark
- And I go to point "17"
+ And I set the mark
+ And I go to point "17"
When I press "<M-up>"
Then I should see:
"""
line 2
line 3
line 1
"""
- And the region should be:
- """
- ne 2
- li
- """
+ And the region should be:
+ """
+ ne 2
+ li
+ """
Scenario: Drag lines down
When I go to point "3"
- And I set the mark
- And I go to point "10"
+ And I set the mark
+ And I go to point "10"
When I press "<M-down>"
Then I should see:
"""
line 3
line 1
line 2
"""
- And the region should be:
- """
- ne 1
- li
- """
+ And the region should be:
+ """
+ ne 1
+ li
+ """
Scenario: Drag lines up out of scope
When I go to point "3"
- And I set the mark
- And I go to point "10"
+ And I set the mark
+ And I go to point "10"
When I press "<M-up>"
Then I should see:
"""
line 1
line 2
line 3
"""
- And I should see message "Can not move lines further up"
- And the region should be:
- """
- ne 1
- li
- """
+ And I should see message "Can not move lines further up"
+ And the region should be:
+ """
+ ne 1
+ li
+ """
Scenario: Drag lines down out of scope
When I go to point "10"
- And I set the mark
- And I go to point "17"
+ And I set the mark
+ And I go to point "17"
When I press "<M-down>"
Then I should see:
"""
line 1
line 2
line 3
"""
- And I should see message "Can not move lines further down"
- And the region should be:
- """
- ne 2
- li
- """
+ And I should see message "Can not move lines further down"
+ And the region should be:
+ """
+ ne 2
+ li
+ """
@@ -2,42 +2,39 @@ Feature: Modifier
In order to change prefix key
As a drag stuff user
I want to change the modifier key
-
+
Background:
- Given I am in buffer "*drag-stuff*"
- And the buffer is empty
- And I insert:
- """
- line 1
- line 2
- """
- And there is no region selected
- And I go to line "1"
-
+ Given I insert:
+ """
+ line 1
+ line 2
+ """
+ And I go to line "1"
+
Scenario: Change modifier key
When I load the following:
"""
(setq drag-stuff-modifier 'control)
"""
- And I enable drag-stuff
- And I press "<M-down>"
+ And I enable drag-stuff
+ And I press "<M-down>"
Then I should not see:
"""
line 2
line 1
"""
- But I should see:
- """
- line 1
- line 2
- """
-
+ But I should see:
+ """
+ line 1
+ line 2
+ """
+
Scenario: Single modifier key
When I load the following:
"""
(setq drag-stuff-modifier 'control)
"""
- And I enable drag-stuff
+ And I enable drag-stuff
When I press "<C-down>"
Then I should see:
"""
@@ -50,7 +47,7 @@ Feature: Modifier
"""
(setq drag-stuff-modifier '(meta shift))
"""
- And I enable drag-stuff
+ And I enable drag-stuff
When I press "<M-S-down>"
Then I should see:
"""
@@ -4,34 +4,31 @@ Feature: Drag region
I want to drag it
Background:
- Given I am in buffer "*drag-stuff*"
- And the buffer is empty
- And I insert "beforeREGIONafter"
- And there is no region selected
- And I enable drag-stuff
+ Given I insert "beforeREGIONafter"
+ And I enable drag-stuff
Scenario: Drag region left
When I select "REGION"
- And I press "<M-left>"
+ And I press "<M-left>"
Then I should see "beforREGIONeafter"
- And the region should be "REGION"
+ And the region should be "REGION"
Scenario: Drag region right
When I select "REGION"
- And I press "<M-right>"
+ And I press "<M-right>"
Then I should see "beforeaREGIONfter"
- And the region should be "REGION"
+ And the region should be "REGION"
Scenario: Drag word left out of scope
When I select "before"
- And I press "<M-left>"
+ And I press "<M-left>"
Then I should see "beforeREGIONafter"
- And I should see message "Can not move region further to the left"
- And the region should be "before"
+ And I should see message "Can not move region further to the left"
+ And the region should be "before"
Scenario: Drag word right out of scope
When I select "after"
- And I press "<M-right>"
+ And I press "<M-right>"
Then I should see "beforeREGIONafter"
- And I should see message "Can not move region further to the right"
- And the region should be "after"
+ And I should see message "Can not move region further to the right"
+ And the region should be "after"
@@ -1,9 +1,22 @@
(Given "^I \\(enable\\|disable\\) drag-stuff$"
(lambda (status)
(if (string= status "enable")
- (turn-on-drag-stuff-mode)
- (turn-off-drag-stuff-mode))))
+ (drag-stuff-mode 1)
+ (drag-stuff-mode -1))))
+
+(Given "^I enable drag-stuff$"
+ (lambda ()
+ (drag-stuff-mode 1)))
+
+(Given "^I disable drag-stuff$"
+ (lambda ()
+ (drag-stuff-mode -1)))
(Given "^major mode is text-mode$"
(lambda ()
(text-mode)))
+
+(When "I place cursor on word \"\\(.+\\)\""
+ (lambda (word)
+ (When "I go to word \"%s\"" word)
+ (forward-char (/ (length word) 2))))
Oops, something went wrong.

0 comments on commit e0a3021

Please sign in to comment.