Skip to content

Commit

Permalink
Merge pull request #27 from joranvar/introduce-ecukes-for-testing
Browse files Browse the repository at this point in the history
Introduce ecukes for testing
  • Loading branch information
zenozeng committed Mar 5, 2017
2 parents 93dad76 + df751d7 commit 675fd68
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.cask/
10 changes: 10 additions & 0 deletions Cask
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(source gnu)
(source melpa)

(package-file "./yafolding.el")

(development
(depends-on "f")
(depends-on "ecukes")
(depends-on "ert-runner")
(depends-on "el-mock"))
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,11 @@ along with this program. If not, see <http:https://www.gnu.org/licenses/>.
## Debug

- [Using Edebug](https://www.gnu.org/software/emacs/manual/html_node/elisp/Using-Edebug.html#Using-Edebug)

## Testing

For testing, use [ecukes][https://github.com/ecukes/ecukes], installed
by [Cask](https://github.com/cask/cask). The tests are in the
[features](./features/) subdirectory, test data is in the
[data](./test/data) dir. Running tests can be done by issueing `cask
exec ecukes --[no-]win`.
35 changes: 35 additions & 0 deletions features/step-definitions/yafolding-steps.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;; 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.

(Given "^I have an empty buffer$"
(lambda () (erase-buffer)))

(When "^I call yafolding-hide-all$"
(lambda () (yafolding-hide-all)))

(Then "^I should have an empty buffer$"
(lambda () (should (= (point-min) (point-max) 1))))

(Given "^I have a buffer with \"\\([^\"]+\\)\"$"
(lambda (filename)
(erase-buffer)
(insert-file-contents filename)))

(And "^I am on line 2$"
(lambda () (goto-line 2)))

(And "^I go to line 1$"
(lambda () (goto-line 1)))

(And "^I call yafolding-hide-element$"
(lambda () (yafolding-hide-element)))

(Then "^I should see only one line$"
(lambda ()
(save-excursion
(next-line)
(should (= (line-number-at-pos (point))
(line-number-at-pos (point-max)))))))

;; End of steps file
32 changes: 32 additions & 0 deletions features/support/env.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(require 'f)

(defvar yafolding-support-path
(f-dirname load-file-name))

(defvar yafolding-features-path
(f-parent yafolding-support-path))

(defvar yafolding-root-path
(f-parent yafolding-features-path))

(add-to-list 'load-path yafolding-root-path)

(require 'yafolding)
(require 'espuds)
(require 'ert)

(Setup
;; Before anything has run
)

(Before
;; Before each scenario is run
)

(After
;; After each scenario is run
)

(Teardown
;; After when everything has been run
)
17 changes: 17 additions & 0 deletions features/yafolding.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Feature: Fold all lines
In order to be able to visualize the outline of my file
As a user
I want to be able to fold all elements at once

Scenario: Empty buffers are not changed
Given I have an empty buffer
When I call yafolding-hide-all
Then I should have an empty buffer

Scenario: Test file from issue #23 should collapse correctly
Given I have a buffer with "test/data/issue-23.txt"
And I am on line 2
When I call yafolding-hide-all
And I go to line 1
And I call yafolding-hide-element
Then I should see only one line
File renamed without changes.

0 comments on commit 675fd68

Please sign in to comment.