-
Notifications
You must be signed in to change notification settings - Fork 4
/
README.md.raw
73 lines (46 loc) · 1.87 KB
/
README.md.raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
[![Build
Status](https://api.travis-ci.org/repositories/freshtonic/given.svg?branch=master)](https://travis-ci.org/freshtonic/given.git)
# Given
*Given* is a lazy-evaluation system for use in your specs.
Variables are defined within an environment object and are lazily computed on
demand. A variable can hold either a value, function or object. If the variable
is a function it used for computing the value of the variable when it is
accessed from the environment.
Variables are accessed from the environment as if they are plain JS properties.
Under the hood, the properties are defined using Object.defineProperty with
a 'get' accessor in order that their value can be computed on demand.
_WARNING_: Given is not yet stable. The API may change significantly before
1.0.0 and there may be show-stopping bugs.
## Installation
Add it to your package.json or `npm install given`.
## Usage
### Javascript
_USAGE_EXAMPLE_JS_
### Coffee
_USAGE_EXAMPLE_COFFEE_
## Caveats
To set a variable with a value that *is* a function, nest it within
another function (to avoid ambiguity with dynamically computing a value), like so:
```javascript
env.Let('aFunction', function() {
// This function will be the variable's value.
return function() {
return 'foo';
};
});
```
## Running the specs
Run `make spec`.
Install the `wach` node module if you would like to have the specs run
automatically when the source or specs are modified.
- `npm install -g wach`
- `make watch`
## Contributing
1. Fork it ( https://github.com/freshtonic/given/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## Licence
Copyright (c) 2014, given is developed and maintained by James Sadler, and is
released under the open MIT Licence.