Skip to content

Commit

Permalink
Provide some ecukes tests
Browse files Browse the repository at this point in the history
These are the first tests that define changes from ert to ecukes. We
intend to use ecukes from now on and also try to set up virtual
environments for these tests. (Related: #16)
  • Loading branch information
anachronic committed May 18, 2018
1 parent cb5fc59 commit f8a5068
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Cask
Expand Up @@ -4,4 +4,5 @@
(package-file "importmagic.el")

(development
(depends-on "ert-runner"))
(depends-on "ert-runner")
(depends-on "ecukes"))
27 changes: 27 additions & 0 deletions features/importmagic.feature
@@ -0,0 +1,27 @@
Feature: Importmagic can start

Scenario: importmagic-mode can start
When I turn on python-mode
And I turn on importmagic-mode
Then importmagic-server should be up

Scenario: importmagic uses python as interpreter and starts correctly
Given I set importmagic-python-interpreter to "python"
When I turn on python-mode
And I turn on importmagic-mode
Then importmagic-server should be up

Scenario: importmagic does not start on fundamental-mode
Given buffer is in fundamental-mode
When I try to turn on importmagic-mode
Then importmagic-server should not be up

Scenario: importmagic doesn't start in c-mode
Given buffer is in c-mode
When I try to turn on importmagic-mode
Then importmagic-server should not be up


Scenario: importmagic can't start without importmagic-mode off but python-mode on
When I turn on python-mode
Then importmagic-server should not be up
30 changes: 30 additions & 0 deletions features/step-definitions/importmagic-steps.el
@@ -0,0 +1,30 @@
;; This file contains your project specific step definitions. All
;; files in this directory whose names end with "-steps.el" will be
;; loaded automatically by Ecukes.

(When "^I try to turn on importmagic-mode$"
(lambda ()
(ignore-errors
(importmagic-mode))))

(Given "^buffer is in \\(.+\\)$"
(lambda (mode)
(ignore-errors
(importmagic-mode))))
(Given "^buffer is in \\(.+\\)$"
"Turns on some mode."
(lambda (mode)
(let ((v (vconcat [?\C-u ?\M-x] (string-to-vector mode))))
(execute-kbd-macro v))))

(Then "^importmagic-server should be up$"
"Asserts that importmagic-server is not nil"
(lambda ()
(let ((message "Expected `importmagic-server' to be non-nil, but it was nil."))
(cl-assert importmagic-server nil message))))

(Then "^importmagic-server should not be up$"
"Asserts that importmagic-server is nil"
(lambda ()
(let ((message "Expected `importmagic-server' to be nil, but it was not nil."))
(cl-assert (not importmagic-server) nil message))))
34 changes: 34 additions & 0 deletions features/support/env.el
@@ -0,0 +1,34 @@
(require 'f)

(defvar importmagic.el-support-path
(f-dirname load-file-name))

(defvar importmagic.el-features-path
(f-parent importmagic.el-support-path))

(defvar importmagic.el-root-path
(f-parent importmagic.el-features-path))

(add-to-list 'load-path importmagic.el-root-path)

;; Ensure that we don't load old byte-compiled versions
(let ((load-prefer-newer t))
(require 'importmagic)
(require 'espuds)
(require 'ert))

(Setup)

(Before
(switch-to-buffer
(get-buffer-create "*importmagic*"))
(erase-buffer)
(fundamental-mode)
(cua-mode 0)
(transient-mark-mode t)
(deactivate-mark)
)

(After)

(Teardown)

0 comments on commit f8a5068

Please sign in to comment.