1. David Krentzlin
  2. chickumber


David Krentzlin  committed 6040c40

added missing dependency to json in meta-file. Implemented missbehave-step-evaluator

  • Participants
  • Parent commits aec1594
  • Branches default

Comments (0)

Files changed (5)

File chickumber-server-cli.scm

View file
   (else        (use chickumber chickumber-server)))
-(define supported-frameworks '(test boolean))
+(define supported-frameworks '(test boolean missbehave))
 (define *verbosity* 0)
 (args:width 30)

File chickumber-server.scm

View file
+ missbehave-step-evaluator
 (import chicken scheme)
-(require-library tcp json files srfi-13 chickumber test posix defstruct)
+(require-library tcp json files srfi-13 chickumber test posix defstruct missbehave)
+  (rename missbehave (pending mb:pending) ($ mb:$))
   (only posix file-modification-time glob current-directory directory? set-signal-handler! signal/int signal/hup signal/term signal/quit)
   (only extras read-line sprintf read-file printf)
   (only data-structures alist-ref conc)
 (define (test-step-evaluator step args)
   (let ((errors '()))
     (define (test-handler status expect expr info)
       (when (or (eq? status 'ERROR) (eq? status 'FAIL))
         (set! errors (cons (collect-test-error status expect expr info) errors))))
               (fail (string-join errors "\n"))))))))
+(define (missbehave-step-evaluator step args)
+  (let ((errors '()))
+    (define (reporter data #!key (mode 'adhoc))
+      (when (and (eq? mode 'adhoc)
+                 (example-result? data)
+                 (example-failed? data))
+        (set! errors (cons (example-result-messages data) errors))))
+    (handle-exceptions exn
+        (begin
+          (fail ((condition-property-accessor 'exn 'message) exn)
+                backtrace: ((condition-property-accessor 'exn 'location) exn)))
+      (run-specification
+       (call-with-specification
+        (make-empty-specification)
+        (lambda ()
+          (describe "Step"
+             (it "runs"
+                (apply (step-code step) args)))))
+       reporter: reporter))
+    (if (null? errors)
+        (succeed)
+        (fail (string-join errors "\n")))))
 ;; this parameter is the adapter to plug in
 ;; custom step-evaluators that are aware of the test-mechanism used.
 (define current-step-evaluator    (make-parameter boolean-step-evaluator))
      (parameterize ((current-step-evaluator boolean-step-evaluator))
+    ((missbehave)
+     (parameterize ((current-step-evaluator missbehave-step-evaluator)
+                    (current-step-evaluator-dependencies '(missbehave)))
+       (thunk)))
      (parameterize ((current-step-evaluator test-step-evaluator)
                     (current-step-evaluator-dependencies '(test)))

File chickumber.meta

View file
  (license "MIT")
- (needs defstruct regex-literals test)
+ (needs defstruct regex-literals test json)
  (test-depends test)
  (files ".hgignore" ".rvmrc" "Gemfile" "Gemfile.lock" "Rakefile" "chickumber-server-cli.scm" "chickumber-server.scm" "chickumber.meta" "chickumber.release-info" "chickumber.scm" "chickumber.setup" "cucumber.yml" "examples/codebreaker/.rvmrc" "examples/codebreaker/README" "examples/codebreaker/codebreaker.scm" "examples/codebreaker/features/start_game.feature" "examples/codebreaker/features/step_definitions/chickumber.wire" "examples/codebreaker/features/step_definitions/codebreaker_steps.scm" "examples/codebreaker/features/submit_guess.feature" "examples/codebreaker/features/support/env.scm" "features/reload.feature" "features/server.feature" "features/step_definitions/cucumber_steps.rb" "features/step_definitions/wire_server_steps.rb" "features/support/env.rb" "features/wire_protocol.feature" "tests/run.scm"))

File features/tagging.feature

View file
+Feature: Support tags
+  In order to support all features of cucumber
+  As a developer using chickumber
+  I want to be able to specify hooks on tags
+ Given a standard Cucumber project directory structure
+ And a file named "features/wired.feature" with:
+ """
+ Feature: High strung
+   Scenario: Wired
+     Given we're all wired
+   @example  
+   Scenario: Wired with tags  
+     Given we're on tags
+ """
+ And a file named "features/step_definitions/some_remote_place.wire" with:
+ """
+ host: localhost
+ port: 54321
+ """
+Scenario: Run hooks for single tag

File tests/run.scm

View file
 ;; %%HEADER%%
-(use test json regex-literals regex)
+(use test json regex-literals regex missbehave)
 (load "../chickumber.scm")
 (load "../chickumber-server.scm")
-            )
+            (test-group "Missbehave"
+                        (test "Succeeding steps"
+                              '("success")
+                              (with-clean-steps
+                               (Given #/success/
+                                      (expect #t (be true)))
+                               (missbehave-step-evaluator (car *step-definitions*) '())))
+                        (test "Failing steps"
+                              '("fail" #(("message" . "Expected #t to be #f")))
+                              (with-clean-steps
+                               (Given #/failing/
+                                      (expect #t (be false)))
+                               (missbehave-step-evaluator (car *step-definitions*) '())))))