https://github.com/faradayio/hangarjs
Hangar's other half
https://github.com/faradayio/hangarjs
Last synced: 8 months ago
JSON representation
Hangar's other half
- Host: GitHub
- URL: https://github.com/faradayio/hangarjs
- Owner: faradayio
- Created: 2014-12-26T21:15:50.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-09-13T15:56:16.000Z (over 9 years ago)
- Last Synced: 2025-09-04T09:14:45.725Z (9 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 4
- Watchers: 9
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#hangarjs
Use hangar factories from protractor
##Install
Use npm
```bash
npm install hangarjs
```
##Usage
Initialize hangar, passing it the URL where hangar can be reached, as well as the protractor object
```javascript
var hangar = require('hangarjs');
var factory = new hangar('http://localhost/', protractor);
```
Create a record
```javascript
factory.create('user', {
email: 'somebody@gmail.com',
password: 'hunter2'
});
```
Get example attributes
```javascript
factory.attributesFor('user').then(function(attributes){
//...
});
```
Create a record based on the example
```javascript
factory.attributesFor('user').then(function(attributes){
attributes.admin = true;
factory.create('user', attributes);
});
```
Create a record based in traits
```javascript
factory.create('user',
{ email: 'somebody@gmail.com', password: 'hunter2'},
{ traits: ["admin", "full"] }
);
```
Empty the db when you're done testing
```
factory.clear();
```