{"_id":"UnderscoreMatchersForJasmine","_rev":"13-e17cdea2ead35979630e1cc7917a0639","name":"UnderscoreMatchersForJasmine","description":"Underscore and backbone Matchers for Jasmine-Node","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.1":{"author":{"name":"Reg Braithwaite","email":"raganwald@gmail.com","url":"http://reginald.braythwayt.com"},"name":"UnderscoreMatchersForJasmine","description":"Underscore and backbone Matchers for Jasmine-Node","version":"0.0.1","homepage":"https://github.com/raganwald/Underscore-Matchers-for-Jasmine","repository":{"type":"git","url":"git@github.com:raganwald/Underscore-Matchers-for-Jasmine.git"},"main":"lib/underscore_matchers.js","scripts":{"test":"jasmine-node --coffee --verbose spec"},"engines":{"node":"*"},"dependencies":{"underscore":">=1.2.2"},"devDependencies":{},"_npmUser":{"name":"raganwald","email":"raganwald@gmail.com"},"_id":"UnderscoreMatchersForJasmine@0.0.1","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.12","_defaultsLoaded":true,"dist":{"shasum":"1b3b24d6d7a7b863f6df48410067af05fae828da","tarball":"https://registry.npmjs.org/UnderscoreMatchersForJasmine/-/UnderscoreMatchersForJasmine-0.0.1.tgz","integrity":"sha512-HabHpPZqyME1tryLSfs+6Z6t1B3Jjgce47YzVvWXKUzE61+lvPedQ4kktYLeKFobm6yxzfbDL8vA7ZVMFWS1DA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICdne93MRXOCgi9OMzwuqsH0COdp+JrUrPofDK3PFEuUAiAau6B29U9106ijK/cBs6QEckdfb201nGYBtGmD/Nmm0g=="}]},"maintainers":[{"name":"raganwald","email":"raganwald@gmail.com"}]},"0.0.2":{"author":{"name":"Reg Braithwaite","email":"raganwald@gmail.com","url":"http://reginald.braythwayt.com"},"name":"UnderscoreMatchersForJasmine","description":"Underscore and backbone Matchers for Jasmine-Node","version":"0.0.2","homepage":"https://github.com/raganwald/Underscore-Matchers-for-Jasmine","repository":{"type":"git","url":"git@github.com:raganwald/Underscore-Matchers-for-Jasmine.git"},"main":"lib/underscore_matchers.js","scripts":{"test":"jasmine-node --coffee --verbose spec"},"engines":{"node":"*"},"dependencies":{"underscore":">=1.2.2"},"devDependencies":{},"_npmUser":{"name":"raganwald","email":"raganwald@gmail.com"},"_id":"UnderscoreMatchersForJasmine@0.0.2","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.12","_defaultsLoaded":true,"dist":{"shasum":"089fa525901626763a100e0d070342ab935e3406","tarball":"https://registry.npmjs.org/UnderscoreMatchersForJasmine/-/UnderscoreMatchersForJasmine-0.0.2.tgz","integrity":"sha512-4VzejOujdLP72dMP+J7JvWRgJAlxyEZTFSfRpH7JOYZlLIwt0NBunMAf4wYnum+Z3ao1EZDedwx9pjybQE5F9Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDwNFeUYAFHTw2jl44I5T2aqrDNcc0L5zoEkPzmS3VzhwIhANHK9AC8ctSL73HaTNlEXjAfADk3imNv1xK0YZ2fjNjd"}]},"maintainers":[{"name":"raganwald","email":"raganwald@gmail.com"}]},"0.0.3":{"author":{"name":"Reg Braithwaite","email":"raganwald@gmail.com","url":"http://reginald.braythwayt.com"},"name":"UnderscoreMatchersForJasmine","description":"Underscore and backbone Matchers for Jasmine-Node","version":"0.0.3","homepage":"https://github.com/raganwald/Underscore-Matchers-for-Jasmine","repository":{"type":"git","url":"git@github.com:raganwald/Underscore-Matchers-for-Jasmine.git"},"main":"lib/UnderscoreMatchersForJasmine.js","scripts":{"test":"jasmine-node --coffee --verbose spec"},"engines":{"node":"*"},"dependencies":{"underscore":">=1.2.2"},"devDependencies":{},"_npmUser":{"name":"raganwald","email":"raganwald@gmail.com"},"_id":"UnderscoreMatchersForJasmine@0.0.3","_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.12","_defaultsLoaded":true,"dist":{"shasum":"a09c6833b0935237cb0b6dc4726408f1c32e150f","tarball":"https://registry.npmjs.org/UnderscoreMatchersForJasmine/-/UnderscoreMatchersForJasmine-0.0.3.tgz","integrity":"sha512-blZlpQwm4Z4of3yYHp4bCgaqT4xe7MXNbJHI/0N3/uB8dnbF4q6k8pI0qS8uYBt9kqptS+k1WSCeMPEfVIF6TA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICFtqNcOwOhGozZzD2w9M3C2tY/giKG/4lHpaulXon1OAiAuZ6nI1W4gdDojy+oUd+5zcfNlGmu78bAKBnAd7cnyEg=="}]},"maintainers":[{"name":"raganwald","email":"raganwald@gmail.com"}]},"0.0.4":{"author":{"name":"Reg Braithwaite","email":"raganwald@gmail.com","url":"http://reginald.braythwayt.com"},"name":"UnderscoreMatchersForJasmine","description":"Underscore and backbone Matchers for Jasmine-Node","version":"0.0.4","homepage":"https://github.com/raganwald/Underscore-Matchers-for-Jasmine","repository":{"type":"git","url":"git@github.com:raganwald/Underscore-Matchers-for-Jasmine.git"},"main":"lib/UnderscoreMatchersForJasmine.js","scripts":{"test":"jasmine-node --coffee --verbose spec"},"engines":{"node":"*"},"dependencies":{"underscore":">=1.2.2"},"devDependencies":{},"_npmUser":{"name":"raganwald","email":"raganwald@gmail.com"},"_id":"UnderscoreMatchersForJasmine@0.0.4","optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.0-2","_nodeVersion":"v0.6.7","_defaultsLoaded":true,"dist":{"shasum":"4e95d163e2dbe795a1b84928eb42ac3d69929b28","tarball":"https://registry.npmjs.org/UnderscoreMatchersForJasmine/-/UnderscoreMatchersForJasmine-0.0.4.tgz","integrity":"sha512-l8TMgimcbdACilGiB2u7NojKr+lh4xzrkhPlfAjyUcGuyduZ49QIozZU+t7Yg9lIsxC+Vs3+D4g8wD76jF8uHg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSb3SZLKoL1AcPiHlwGRJeZpJERHpIBztcsAFzrsfm7wIhANyr66+bK2fB5lAwwfPJ1DqhEJGgv2AXBXtrXYWiANE9"}]},"maintainers":[{"name":"raganwald","email":"raganwald@gmail.com"}]},"0.0.5":{"author":{"name":"Reg Braithwaite","email":"raganwald@gmail.com","url":"http://reginald.braythwayt.com"},"name":"UnderscoreMatchersForJasmine","description":"Underscore and backbone Matchers for Jasmine-Node","version":"0.0.5","homepage":"https://github.com/raganwald/Underscore-Matchers-for-Jasmine","repository":{"type":"git","url":"git@github.com:raganwald/Underscore-Matchers-for-Jasmine.git"},"main":"lib/UnderscoreMatchersForJasmine.js","scripts":{"test":"jasmine-node --coffee --verbose spec"},"engines":{"node":"*"},"dependencies":{"underscore":">=1.2.2"},"devDependencies":{},"_npmUser":{"name":"raganwald","email":"raganwald@gmail.com"},"_id":"UnderscoreMatchersForJasmine@0.0.5","optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.0-2","_nodeVersion":"v0.6.7","_defaultsLoaded":true,"dist":{"shasum":"fba3217565fe4b90f60727b817dd1b03afc975e4","tarball":"https://registry.npmjs.org/UnderscoreMatchersForJasmine/-/UnderscoreMatchersForJasmine-0.0.5.tgz","integrity":"sha512-SYXT6k42SrGplcH3Ff8t2M73soLWq6D3ztNGYdpldufjbTUJ9sqb82svvr5dLtv4CZO8tN6FQyFjWUWb+oygNQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA1lcU9EZ/Dth6sfCPodc1yGOPCl1/gBW27lFHqYoVSSAiBclUklGrSlr5d9uQDjEEb9PkIImI+zeu5+vmz79VQAkA=="}]},"maintainers":[{"name":"raganwald","email":"raganwald@gmail.com"}]}},"readme":"Underscore Matchers for Jasmine\n===\n\nUnderscoreMatchersForJasmine adds a series of matchers for [Jasmine][1]-based Javascript/[Coffeescript][2] testing based on [Underscore][_] methods. Example:\n\n    expect(snafu).toInclude('s', 'n', 'a')\n    \n    // if snafu is an array, this is equivalent to:\n    expect(\n      _(snafu).include('s') && _(snafu).include('n') && _(snafu).include('a')\n    ).toBeTruthy()\n\n    // if snafu is a Backbone.js collection, this is equivalent to:\n    expect(\n      snafu.include('s') && snafu.include('n') && snafu.include('a')\n    ).toBeTruthy()\n    \n[1]: https://github.com/pivotal/jasmine\n[2]: https://github.com/jashkenas/coffee-script\n[_]: http://documentcloud.github.com/underscore/\n\nThat makes your tests easy to read, for example:\n\n    $ ->\n      describe 'States and StateMachines', ->\n        it 'should associate states with a state machine and the state machine with its states', ->\n          engine_status = new StateMachine()\n          running = engine_status.new_state()\n          idling = engine_status.new_state()\n          \n          expect(running).toRepondTo('state_machine')\n          expect(engine_status.states()).toInclude(running, idling)\n          \n        it 'should generate states with rpm', ->\n          engine_status = new StateMachine()\n          running = engine_status.new_state()\n          \n          expect(running).toBeA(State)\n          expect(running).toHave('rpm')\n\nIs it any good?\n---\n\n[Yes][y].\n\n[y]: http://news.ycombinator.com/item?id=3067434\n          \n*Why* is it any good?\n---\n\nLet's take it point by point:\n\n1. Underscore is a utility-belt library for Javascript. If you're using [Backbone.js][b], you are already using [Underscore][_]. If you aren't using either, you are excused from class, this library does not apply to your project.\n2. Jasmine is a [Test-Driven Development][tdd] testing framework for Javascript. You can run tests in a pretty browser window, you can run tests on the command line with Node.js, you can run tests in the console. If you are writing Javascript and/or Coffeescript, you should be using Jasmine.\n3. If you are using Underscore or Backbone and you are using Jasmine, your tests will be cleaner and more readable with these Underscore matchers for the same reason that your code is cleaner and more readable with Underscore.\n\n[tdd]: http://en.wikipedia.org/wiki/Test_Driven_Development\n[b]: http://documentcloud.github.com/backbone/\n\nCan I install it with npm?\n---\n\nYes:\n\n    npm install UnderscoreMatchersForJasmine\n\nCan I install it in other kinds of projects?\n---\n\nIf you're using Coffeescript, put `underscore_matchers.coffee` in your project. If you're using plain Javascript, it should therefore follow that you want to put `underscore_matchers.js` in your project. It's one file, just make sure that your include declarations or asset pipeline includes `underscore_matchers` *after* `jasmine.js`. That's it. For example, here's a [Jammit][3] `assets.yml` file from a Rails project:\n\n    allow_debugging: off\n    template_function: _.template\n    compress_assets: false\n\n    javascripts:\n      common:\n        - public/js/vendor/json2.js\n        - public/js/vendor/jquery-1.6.1.min.js\n        - public/js/vendor/jquery-ui-1.8.min.js\n        - public/js/vendor/jquery.combinators.min.js\n        - public/js/vendor/jquery.predicates.min.js\n        - public/js/vendor/underscore-min.js\n        - public/js/vendor/backbone.js\n        - public/js/vendor/async.js\n      application:\n        - public/js/compiled/models/*.js\n      test:\n        - public/js/vendor/jasmine/jasmine.js\n        - public/js/vendor/jasmine/jasmine-html.js\n        - public/js/compiled/jasmine/underscore_matchers.js\n        - public/js/compiled/spec/*.js\n\n    stylesheets:\n      common:\n      application:\n      test:\n        - public/js/vendor/jasmine/*.css\n        \n[3]: https://github.com/documentcloud/jammit\n\nYou can also put `underscore_matchers_spec.coffee` or `underscore_matchers_spec.js` in your project if you want to see these matchers test themselves. It's also handy documentation for how the matchers behave!\n\nWhich Matchers are included?\n---\n\nRead the code in [Coffeescript][5] or [Javascript][6].\n\n[5]: https://github.com/raganwald/Underscore-Matchers-for-Jasmine/blob/master/lib/underscore_matchers.coffee\n[6]: https://github.com/raganwald/Underscore-Matchers-for-Jasmine/blob/master/lib/underscore_matchers.js\n\nThat's it? Aren't there any more?\n---\n\nThis is what I happen to need right now for my actual code. **As I write more matchers, I'll add them**. So, if you're interested, watch the library. I suppose I could go through and make a matcher for every function in Underscore, but I'd rather let it grow organically. If there's a matcher you need that isn't here, well, **we're all in the same boat**:\n\n* If you're a *passenger*, send me a message describing the matcher you want. If it seems useful, I'll add it.\n* If you're a *sailor*, fork this project, add the matcher, and send me a pull request.\n* If you're the *captain of your own ship*, and you've already written some matchers like this, run up some signal flags and I'll include links to your project right here.\n* And if you're a *pirate*, take this code and/or just the idea and make your own library. I'm cool with that.\n\nIs it free?\n---\n\n[Yes][4].\n\n[4]: https://github.com/raganwald/Underscore-Matchers-for-Jasmine/blob/master/license.txt\n\nOther Random Observations\n---\n\n**Who's Using This?**\n\nI am.\n\n**Is there a gem?**\n\nNo. This is a Coffeescript and Javascript include file, not a ruby library. Coffeescript and Javascript files work everywhere, and you can read the source any time you want.\n\n**Any gotchas?**\n\nSome matchers, such as `toInclude(...)` and `toRespondTo(...)` can take multiple arguments. When they do, they have \"all\" semantics. For example:\n    \n    expect([1,2,3,4,5]).toRespondTo('push', 'pop')\n      // => succeeds because arrays respond to .push and .pop\n\n    expect([1,2,3,4,5]).toInclude(2,3,4,5,6)\n       // => fails because 6 is not included.\n      \nNow what if you want to test the opposite?\n\n    expect([1,2,3,4,5]).not.toInclude(2,3,4,5,6)\n      // succeeds because it doesn't include 2, 3, 4, 5, AND 6.\n      \nIf that's what you want, fine. But if what you really want is to test whether it doesn't include ANY of the arguments, you need a slightly different matcher:\n    \n    expect([1,2,3,4,5]).toRespondToAny('push', 'select_sql', 'diagonalize')\n      // => succeeds because arrays respond to at least one of the three methods given\n\n    expect([1,2,3,4,5]).toIncludeAny(2,3,4,5,6)\n      //  => succeeds because it includes at least one of the arguments\n\nThe opposite of an \"any\" matcher is a \"none\" matcher:\n\n    expect([1,2,3,4,5]).not.toIncludeAny(3, 6, 9)\n      //  => fails because [1,2,3,4,5] includes a 3\n\n    expect([1,2,3,4,5]).not.toIncludeAny(6, 9, 12)\n      //  => succeeds because [1,2,3,4,5] does not include ANY of the aarguments\n\n\n**Is this just for underscore stuff?**\n\nNo. I also sneak in some Backbone stuff here and there, but the code works just fine even if you don't use Backbone.js. For example:\n\n    $ ->\n      describe 'States', ->\n        it 'should permit cards to be added and removed', ->\n          state = new State()\n          card = new Card()\n          expect(state.cards()).toBeEmpty()\n          state.cards().add(card)\n          expect(state.cards()).not.toBeEmpty()\n          state.cards().remove(card)\n          expect(state.cards()).toBeEmpty()\n          \n`toBeEmpty` is more than just a wrapper for `_.isEmpty`:\n\n    expect(\n      _([]).isEmpty()\n    ).toBeTruthy() // => succeeds\n    \n    expect(\n      _(new Backbone.Collection()).isEmpty()\n    ).toBeTruthy() // => fails, wtf!?\n    \n    expect([]).toBeEmpty()\n      // => succeeds\n      \n    expect(new Backbone.Collection()).toBeEmpty()\n      // => succeeds\n      \nThe same goes for collection tests like `.toInclude`. You can pass it a backbone collection or an array as you see fit. If you don't want that behaviour, Jasmine includes a `contains()` matcher that expects an array.","maintainers":[{"name":"raganwald","email":"raganwald@gmail.com"}],"time":{"modified":"2022-06-13T02:16:35.488Z","created":"2011-11-28T22:32:23.712Z","0.0.1":"2011-11-28T22:32:24.208Z","0.0.2":"2011-12-05T20:14:18.245Z","0.0.3":"2011-12-05T20:55:52.210Z","0.0.4":"2012-05-06T23:32:18.821Z","0.0.5":"2012-05-08T13:43:56.555Z"},"author":{"name":"Reg Braithwaite","email":"raganwald@gmail.com","url":"http://reginald.braythwayt.com"},"repository":{"type":"git","url":"git@github.com:raganwald/Underscore-Matchers-for-Jasmine.git"}}