From d3a29a2c6f5648e52f81d8d8c422aef4cfb8058e Mon Sep 17 00:00:00 2001 From: Magnar Sveen Date: Thu, 7 Jun 2012 19:35:15 +0200 Subject: [PATCH] Started working on multiple-cursor core tests. - got a problem with detecting overlays in ecukes. --- features/multiple-cursors-core.feature | 12 ++++++++++++ features/step-definitions/multiple-cursors-steps.el | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 features/multiple-cursors-core.feature diff --git a/features/multiple-cursors-core.feature b/features/multiple-cursors-core.feature new file mode 100644 index 0000000..8c6f2ff --- /dev/null +++ b/features/multiple-cursors-core.feature @@ -0,0 +1,12 @@ +Feature: Multiple cursors core + In order to make efficient changes + As an Emacs user with multiple-cursors + I want to change multiple parts of the buffer at once + + Scenario: Two cursors + Given there is no region selected + When I insert "This text contains the word text twice" + And I select "text" + And I press "C->" + And I press "C-g" + Then I should have 2 cursors diff --git a/features/step-definitions/multiple-cursors-steps.el b/features/step-definitions/multiple-cursors-steps.el index 2836291..486aa32 100644 --- a/features/step-definitions/multiple-cursors-steps.el +++ b/features/step-definitions/multiple-cursors-steps.el @@ -1,3 +1,15 @@ (And "^delete-selection-mode is active$" (lambda () (delete-selection-mode 1))) + +(defun is-extra-cursor-p (o) + (eq (overlay-get o 'type) 'additional-cursor)) + +(defun num-cursors () + (1+ (count-if 'is-extra-cursor-p + (overlays-in (point-min) (point-max))))) + +(Then "^I should have 2 cursors$" + (lambda () + (assert (eq 2 (num-cursors)) nil + "Expected to have 2 cursors, but was %d." (num-cursors))))