Commits

Anonymous committed 578b051 Draft

behaviour -> behavior

  • Participants
  • Parent commits 5382f3c

Comments (0)

Files changed (2)

File missbehave.meta

 ((egg "missbehave.egg")
  (author "David Krentzlin") 
- (synopsis "Behaviour Driven Scheme")
+ (synopsis "Behavior Driven Scheme")
  (category testing)
  (license "MIT")
  (doc-from-wiki)

File missbehave.scm

-;; 
+;;
 ;; %%HEADER%%
 ;;
 ;;
 
 (module missbehave
 (
-  run-specification behave call-with-specification make-empty-specification    
+  run-specification behave call-with-specification make-empty-specification
   describe context run-context call-with-context add-context-to-specification
   context-description create-context context? context-parent
-  
+
   add-hook-to-context before after
-  subject-set! subject 
- 
-  it create-example example-description run-example 
-  add-example-to-context pending 
+  subject-set! subject
+
+  it create-example example-description run-example
+  add-example-to-context pending
 
   example-result? example? example-result-example example-result-messages
   example-failed? example-pending? example-result-spec-file
-  example-spec-file 
- 
+  example-spec-file
+
   expect run-expectation  to
   make-matcher
   matcher
- 
+
   current-context context-subject-set!
   $ reset-state!
   current-spec-file
 ;;
 ;; A specification is the sum of all contexts/description with all
 ;; their examples. It's basically everything you have to say about the
-;; behaviour of a particular object or system.
+;; behavior of a particular object or system.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define (make-empty-specification) (list))
     (current-specification
       (cons context (current-specification)))))
 
-(define (filter-examples context include exclude)  
+(define (filter-examples context include exclude)
   (let ((examples (context-examples context)))
     (cond
      ((and (not include) (not exclude)) examples)
        after-all))
     context-result))
 
-(define (for-each-example-in-context callback context include exclude)
-  (for-each
-   callback
-   (reverse
-    (cond
+(define (filter-context-examles context include exclude)
+  (cond
      ((and exclude include)
       (if (meta-matches? (context-meta context) include)
           (filter-examples context  #f exclude)
       (if (meta-matches? (context-meta context) include)
           (filter-examples context #f exclude)
           (filter-examples context include #f)))
-     (exclude     
+     (exclude
       (filter-examples context #f exclude))
-     (else  (context-examples context))))))
+     (else  (context-examples context))))
+
+(define (for-each-example-in-context callback context include exclude)
+  (for-each callback (reverse (filter-contexts-examples context include exclude))
 
 (define (run-example-with-hooks example context reporter)
-  (reporter example mode: 'adhoc) 
+  (reporter example mode: 'adhoc)
   (let ((before-hooks-for-example (find-context-hooks-for-example 'before example context))
         (after-hooks-for-example  (find-context-hooks-for-example 'after  example context)))
     (call-with-hooks
 (define (subject-set! subject #!optional (context (current-context)))
   (when context
     (context-subject-set! context subject)))
-                    
+
 (define (subject)
   (when (current-context)
     (context-subject (current-context))))
       ((tag-expression->filter tags) meta)))
 
 (define ((tag-expression->filter tags) meta)
-  (every (lambda (tag) (member tag meta)) tags))
+  (every (cut member <> meta) tags))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Examples
 ;;
-;; Examples are pieces of behaviour you want to describe for a given
+;; Examples are pieces of behavior you want to describe for a given
 ;; object or system. Use them to specify how your "subject" should
 ;; behave like. An example is usually set of expecations that are run
 ;; against the parts of your code you want to specify.
 
 (define current-exit-continuation (make-parameter #f))
 
-(define-record example description behaviour pending meta spec-file)
+(define-record example description behavior pending meta spec-file)
 
-(define (create-example description behaviour #!key (pending #f) (meta (list)) (context #f))
-  (make-example  description behaviour pending  meta context))
+(define (create-example description behavior #!key (pending #f) (meta (list)) (context #f))
+  (make-example  description behavior pending  meta context))
 
 (define-record-printer (example ex out)
   (fprintf out "#<example '~A' meta(~A)>" (example-description ex) (example-meta ex)))
          (cps (alist-update! 'exn eps cps)))
     (with-output-to-string
         (lambda ()
-          (for-each 
+          (for-each
            (lambda (cp)
              (printf "~A:~%" (car cp))
              (for-each (lambda (p)
            cps)))))
 
 (define (run-example example)
-  (let((behaviour (example-behaviour example))
+  (let((behavior (example-behavior example))
        (result    (make-example-result 'succeeded '() example (example-spec-file example))))
     (parameterize ((current-example-result result))
       (cond
                  (fail-current-example-with! (sprintf "Error: ~S~%~A"
                                                       ((condition-property-accessor 'exn 'message) exn)
                                                       (format-condition-properties exn '(message call-chain)))))
-             (call-with-exit-handler behaviour (make-exit-handler exit result)))))))
+             (call-with-exit-handler behavior (make-exit-handler exit result)))))))
        result)))
 
 (define (call-with-exit-handler code handler)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Matcher
-;; 
-;; A matcher is responsible to check if a certain behaviour
-;; is present. It's a check agains the existing behaviour.
+;;
+;; A matcher is responsible to check if a certain behavior
+;; is present. It's a check agains the existing behavior.
 ;; Matchers do generate failure-messages if the expectation is not met
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 ;;
 ;; This is a simple mechanism to maintain state between examples. It
 ;; can be used in situations where a simple let over the examples
-;; doesn't suffice. 
+;; doesn't suffice.
 ;; This will most likely be used in setup/teardown code.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Reporting
-;; 
+;;
 ;; At some point we need to notify the programmer about the state of her expectations.
 ;; The reporter is responsible for presenting the result to the user.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;