Skip to content

Commit

Permalink
Start implementing integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DamienCassou committed Jan 31, 2014
1 parent de8d504 commit 49dfc13
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Cask
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
(depends-on "org-plus-contrib")
(depends-on "ert")
(depends-on "cl-lib")
)
(depends-on "ecukes")
(depends-on "espuds"))
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ $(PRECOMMIT_HOOK) :
.PHONY: compile
compile : $(OBJECTS)

# Run ert tests.
.PHONY: check
check : compile
# Run tests.
.PHONY: unit-tests ecukes-tests check
unit-tests : compile
$(CASK) exec $(EMACS) $(EMACSFLAGS) \
$(patsubst %,-l % , $(SRCS))\
$(patsubst %,-l % , $(TESTS))\
-f ert-run-tests-batch-and-exit

ecukes-tests : compile
$(CASK) exec ecukes --script

check : unit-tests ecukes-tests

# Export the org documentation to an info manual.
.PHONY: info
info : $(INFO_MANUAL)
Expand Down
95 changes: 95 additions & 0 deletions features/pillar.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
Feature: Fontification
In order to read Pillar files easily
As an author using Pillar
I want to have syntax highlighting

Background:
Given I am in buffer "foo.pillar"
And I clear the buffer
And I start pillar mode

Scenario: Standard text is not fontified
When I insert "Some text"
And I place the cursor between "t" and "e"
Then current point should not be in bold

Scenario: Titles are fontified
When I clear the buffer
And I insert "!Title"
And I place the cursor between "!" and "Title"
Then current point should be in bold

When I clear the buffer
And I insert "!!Title"
And I place the cursor between "!" and "Title"
Then current point should be in bold

When I clear the buffer
And I insert "!!!Title"
And I place the cursor between "!" and "Title"
Then current point should be in bold

When I clear the buffer
And I insert "!!!!Title"
And I place the cursor between "!" and "Title"
Then current point should be in bold

Scenario: Bold test is fontified
When I clear the buffer
And I insert "Text ""is"" formatted"
And I place the cursor between "i" and "s"
Then current point should be in bold
And current point should have the pillar-bold-face face

Scenario: Italic text is fontified
When I clear the buffer
And I insert "Text ''is'' formatted"
And I place the cursor between "i" and "s"
Then current point should be in italic
And current point should have the pillar-italic-face face

Scenario: Strike-through text is fontified
When I clear the buffer
And I insert "Text --is-- formatted"
And I place the cursor between "i" and "s"
Then current point should be in strike-through
And current point should have the pillar-strikethrough-face face

Scenario: Subscript text is fontified
When I clear the buffer
And I insert "Text @@is@@ formatted"
And I place the cursor between "i" and "s"
Then current point should have the pillar-subscript-face face

Scenario: Superscript text is fontified
When I clear the buffer
And I insert "Text ^^is^^ formatted"
And I place the cursor between "i" and "s"
Then current point should have the pillar-superscript-face face

Scenario: Underline text is fontified
When I clear the buffer
And I insert "Text __is__ formatted"
And I place the cursor between "i" and "s"
Then current point should be in underline
And current point should have the pillar-underlined-face face

Scenario: Link text is fontified
When I clear the buffer
And I insert "Text *is* formatted"
And I place the cursor between "i" and "s"
Then current point should be in underline
And current point should have the pillar-link-face face

Scenario: Embedded link text is fontified
When I clear the buffer
And I insert "Text +is+ formatted"
And I place the cursor between "i" and "s"
Then current point should be in underline
And current point should have the pillar-link-embedded-face face

Scenario: Monospace text is fontified
When I clear the buffer
And I insert "Text ==is== formatted"
And I place the cursor between "i" and "s"
And current point should have the pillar-monospaced-face face
90 changes: 90 additions & 0 deletions features/step-definitions/pillar-steps.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
(defun pillar-steps::faces-at-point ()
(let ((face (or (get-char-property (point) 'read-face-name)
(get-char-property (point) 'face))))
(if (listp face)
face
(list face))))

(defun pillar-steps::fontify ()
(setq font-lock-fontify-buffer-function
#'font-lock-default-fontify-buffer)
(font-lock-fontify-buffer))

(defun pillar-steps::character-fontified-p (property valid-values)
(pillar-steps::fontify)
(cl-member-if
(lambda (face)
(memq (face-attribute face property nil t) valid-values))
(pillar-steps::faces-at-point)))

(defun pillar-steps::character-bold-p ()
(pillar-steps::character-fontified-p
:weight
'(semi-bold bold extra-bold ultra-bold)))

(Then "current point should be in bold"
(lambda ()
(cl-assert
(pillar-steps::character-bold-p)
nil
"Expected current point to be in bold")))

(Then "current point should not be in bold"
(lambda ()
(cl-assert
(not (pillar-steps::character-bold-p))
nil
"Expected current point to be in bold")))

(Then "current point should be in italic"
(lambda ()
(cl-assert
(pillar-steps::character-italic-p)
nil
"Expected current point to be in italic")))

(defun pillar-steps::character-italic-p ()
(pillar-steps::character-fontified-p
:slant
'(italic oblique)))

(defun pillar-steps::character-strike-through-p ()
(pillar-steps::character-fontified-p
:strike-through
'(t)))

(Then "current point should be in strike-through"
(lambda ()
(cl-assert
(pillar-steps::character-strike-through-p)
nil
"Expected current point to be in strike-through")))

(defun pillar-steps::character-underline-p ()
(pillar-steps::character-fontified-p
:underline
'(t)))

(Then "current point should be in underline"
(lambda ()
(cl-assert
(pillar-steps::character-underline-p)
nil
"Expected current point to be in underline")))

(Then "^current point should have the \\([-a-z]+\\) face$"
(lambda (face)
(pillar-steps::fontify)
(cl-assert
(cl-member
(intern face)
(pillar-steps::faces-at-point)))
nil))

(When "^I start pillar mode$"
(lambda ()
(pillar-mode)))

;; Local Variables:
;; eval: (flycheck-mode -1)
;; End:
21 changes: 21 additions & 0 deletions features/support/env.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(require 'f)

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

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

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


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

(require 'pillar)
(require 'espuds)
(require 'ert)

;; Local Variables:
;; eval: (flycheck-mode -1)
;; End:

0 comments on commit 49dfc13

Please sign in to comment.