Ecukes - Cucumber for Emacs

I just finished the first release of a project of mine called Ecukes. Ecukes is a package for Emacs that makes it possible to write Cucumber like tests for Emacs packages.

This release includes the most basic parts of Cucumber and I would consider it usable, but still under development.

To give you an example of what you can do with Ecukes, check out this example:

Feature: Work with text
  In order to work with text
  As an Emacs user
  I want to do freaky stuff with it
    Given I am in the buffer "*Freaky Stuff*"
    And the buffer is empty

  Scenario: Transpose words
    When I insert "word1 word2"
    And I go to point "6"
    And I press "M-t"
    Then I should see "word2 word1"

  # ...

Each step needs to be translated with a step definition. These are the steps for the feature above. All these steps are however already in Espuds, which is a collection of commonly used step definitions.

(require 'edmacro)

(When "^I press \"\\(.+\\)\"$"
      (lambda (keybinding)
        (execute-kbd-macro (edmacro-parse-keys keybinding))))

(Given "I am in the buffer \"\\(.+\\)\""
       (lambda (buffer)
         (switch-to-buffer (get-buffer-create buffer))))

(And "the buffer is empty"
     (lambda ()

(When "I insert \"\\(.+\\)\""
      (lambda (contents)
        (insert contents)))

(And "I go to point \"\\(.+\\)\""
     (lambda (point)
       (goto-char (string-to-number point))))

(Then "I should see \"\\(.+\\)\""
      (lambda (should-see)
        (let ((actual (buffer-substring-no-properties (point-min) (point-max)))
              (expected should-see))
           (search expected actual) nil
           (concat "Expected \"" actual "\" to include \"" expected "\"")))))

This is how running the feature looks like:

Check out Ecukes website and the source code.

You might also want to check out two Emacs packages of mine that are tested with Ecukes:

blog comments powered by Disqus Back to Top

Fork me on GitHub