{"name":"chai-fuzzy","version":"0.0.1","description":"fuzzy matchers for chai","main":"index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"git://github.com/elliotf/chai-fuzzy.git"},"author":"","license":"MIT","devDependencies":{"chai":"~1.2.0","mocha":"~1.5.0","nodemon":"~0.6.23"},"dependencies":{"underscore":"~1.4.1"},"_id":"chai-fuzzy@0.0.1","dist":{"shasum":"e15e05ebfd4093d4de8997a64357a9fdf987f651","tarball":"http://registry-npm.ywwl.com/chai-fuzzy/download/chai-fuzzy-0.0.1.tgz","integrity":"sha512-qFFPN4WgYHErbrKQleKrcsFik//tohdO9Zvp2ZcU0Iy+ao6YK9b5ePDM1Ty3DqOuh78rf907ECfZD4l42RmphQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHuA69XYLeM2jj/TfsCmuFJRa6E0L7vcEPbF7FJ0wdxFAiAmLjSBOLEyHl/lM9kTzTo6cASwWIvsczQGgQdb0ac72Q=="}],"size":4308,"noattachment":false,"key":"/chai-fuzzy/-/chai-fuzzy-0.0.1.tgz"},"_npmVersion":"1.1.62","_npmUser":{"name":"elliotf","email":"efoster+opensource@firetaco.com"},"maintainers":[{"name":"elliotf","email":"efoster+opensource@firetaco.com"}],"directories":{},"readme":"# chai-fuzzy\n\nFuzzy matchers for chai based on underscore and inspired by jasmine.\n\nMake assertions that values have all the same attributes and values without asserting strict object equality.\n\n[![Build Status](https://travis-ci.org/elliotf/chai-fuzzy.png)](https://travis-ci.org/elliotf/chai-fuzzy)\n\n## Using\n\nAlso see the [tests](https://github.com/elliotf/chai-fuzzy/tree/master/test/) and [examples](https://github.com/elliotf/chai-fuzzy/tree/master/examples/).\n\n### browser-side\n\ninclude chai fuzzy after chai and underscore:\n\n    <script src=\"underscore.js\"></script>\n    <script src=\"chai.js\"></script>\n    <script src=\"chai-fuzzy.js\"></script>\n\n### server-side\n\nhave chai use chai-fuzzy:\n\n    var chai = require('chai');\n    chai.use(require('chai-fuzzy'));\n\n## Assertions\n\n\n### like(value)\n\ncompare object attributes and values rather than checking to see if they're the same reference\n\n    var subject = {a: 'a'};\n    subject.should.be.like({a: 'a'});\n    subject.should.not.be.like({x: 'x'});\n    subject.should.not.be.like({a: 'a', b: 'b'});\n\n    expect(subject).to.be.like({a: 'a'});\n    expect(subject).not.to.be.like({x: 'x'});\n    expect(subject).not.to.be.like({a: 'a', b: 'b'});\n\n    assert.like(subject, {a: 'a'});\n    assert.notLike(subject, {x: 'x'});\n    assert.notLike(subject, {a: 'a', b: 'b'});\n\n    var subject = ['a'];\n    subject.should.be.like(['a']);\n    subject.should.not.be.like(['x']);\n    subject.should.not.be.like(['a', 'b']);\n\n    expect(subject).to.be.like(['a']);\n    expect(subject).not.to.be.like(['x']);\n    expect(subject).not.to.be.like(['a', 'b']);\n\n    assert.like(subject, ['a']);\n    assert.notLike(subject, ['x']);\n    assert.notLike(subject, ['a', 'b']);\n\n## containOneLike(value)\n\ncheck the first level of the container for a value like the one provided\n\n    var subject = {\n      a:   'alphabet'\n      , b: 'butternut'\n      , c: {\n        name:       'chowder'\n        , attributes: [\n          'scales'\n          , 'fins'\n        ]\n      }\n      , x: 'xylophone'\n      , z: 'xylophone'\n    };\n    subject.should.containOneLike({\n      name:         'chowder'\n      , attributes: [\n        'scales', 'fins'\n      ]\n    });\n    subject.should.not.containOneLike({\n      name:         'chowder'\n      , attributes: [\n        'scales', 'fins', 'cream'\n      ]\n    });\n\n    subject.should.containOneLike('xylophone');\n    subject.should.not.containOneLike('cow patties');\n\n    expect(subject).to.containOneLike('xylophone');\n    expect(subject).to.not.containOneLike('cow patties');\n\n    assert.containOneLike(subject, 'xylophone');\n    assert.notContainOneLike(subject, 'cow patties');\n\n    // same for arrays\n\n# jsonOf(value)\n\ncheck that the given javascript object is like the JSON-ified expected value.  Useful for checking stringification and parsing of an object.\n\n    var apple = {\n      skin: 'thin'\n      , colors: ['red', 'green', 'yellow']\n      , isFruit: true\n      , picked: new Date()\n    };\n    var orange = {\n      skin: 'thin'\n      , colors: ['red', 'green', 'yellow']\n      , isFruit: true\n      , picked: new Date()\n    };\n    // here appleJSON would be the json result of some process like a JSON api\n    var appleJSON  = JSON.parse(JSON.stringify(apple));\n\n    appleJSON.should.be.jsonOf(apple);\n    appleJSON.should.not.be.jsonOf(orange);\n\n    expect(appleJSON).to.be.jsonOf(apple);\n    expect(appleJSON).to.not.be.jsonOf(orange);\n\n    assert.jsonOf(appleJSON, apple);\n    assert.notJsonOf(appleJSON, orange);\n\n# Thanks\n\nThanks to [Davis](http://github.com/infews/ \"Davis\") for passing along the idea of using underscore rather than cribbing parts of jasmine.\n\nThanks to [Bart van der Schoor](https://github.com/Bartvds \"Bart van der Schoor\") for adding assert-style compatibility\n\n","publish_time":1349206690533,"_cnpm_publish_time":1349206690533,"dist-tags":{"latest":"1.6.1"}}