{"action":"created","issue":{"url":"https://api.github.com/repos/chaijs/chai-fs/issues/17","repository_url":"https://api.github.com/repos/chaijs/chai-fs","labels_url":"https://api.github.com/repos/chaijs/chai-fs/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/chaijs/chai-fs/issues/17/comments","events_url":"https://api.github.com/repos/chaijs/chai-fs/issues/17/events","html_url":"https://github.com/chaijs/chai-fs/pull/17","id":173778378,"number":17,"title":"Enhanced the `.content()` assertion syntax","user":{"login":"BigstickCarpet","id":3453903,"avatar_url":"https://avatars.githubusercontent.com/u/3453903?v=3","gravatar_id":"","url":"https://api.github.com/users/BigstickCarpet","html_url":"https://github.com/BigstickCarpet","followers_url":"https://api.github.com/users/BigstickCarpet/followers","following_url":"https://api.github.com/users/BigstickCarpet/following{/other_user}","gists_url":"https://api.github.com/users/BigstickCarpet/gists{/gist_id}","starred_url":"https://api.github.com/users/BigstickCarpet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BigstickCarpet/subscriptions","organizations_url":"https://api.github.com/users/BigstickCarpet/orgs","repos_url":"https://api.github.com/users/BigstickCarpet/repos","events_url":"https://api.github.com/users/BigstickCarpet/events{/privacy}","received_events_url":"https://api.github.com/users/BigstickCarpet/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-29T13:46:54Z","updated_at":"2016-08-30T11:37:23Z","closed_at":"2016-08-30T11:35:05Z","pull_request":{"url":"https://api.github.com/repos/chaijs/chai-fs/pulls/17","html_url":"https://github.com/chaijs/chai-fs/pull/17","diff_url":"https://github.com/chaijs/chai-fs/pull/17.diff","patch_url":"https://github.com/chaijs/chai-fs/pull/17.patch"},"body":"This PR enhances the `.content()` and `.content.that.match()` assertion syntax in two ways:\r\n\r\n1. **Consistent chaining behavior**<br>\r\nThe `.content()` assertions can now be chained behind `.file()`, which is more consistent with other `chai-fs` assertions and may be more readable/preferable to some people.  The existing syntax (without chaining behind `.file()`) still works as well.  For example, the following are identical:\r\n\r\n```\r\n// These two are the same\r\nexpect(path).to.have.content(data);\r\nexpect(path).to.be.a.file().with.content(data);\r\n\r\n// These two are the same\r\nexpect(path).to.not.have.content(data);\r\nexpect(path).to.be.a.file().and.not.have.content(data);\r\n```\r\n\r\n2. **Plural alias**<br>\r\nAdded an plural (`.contents()`), which is just an alias and behaves identically.  This just allows certain chaining structures to read more like English.\r\n\r\n```\r\n// These two are the same\r\nexpect(path).to.be.a.file().with.content(data);\r\nexpect(path).to.be.a.file().with.contents(data);\r\n```\r\n\r\n----------------------------------------------\r\n\r\nBoth of these changes improve readability & consistency of `chai-fs`, and they will also both be useful for my next pull request (which I'll probably submit tomorrow), which enhances the `.content` assertion to support _directory_ contents in addition to file contents.  That'll look like this:\r\n\r\n```\r\n// Assert the top-level contents of a directory\r\nexpect(path).to.be.a.directory().with.contents([\"file1.txt\", \"file2.txt\", \"subdir1\", \"subdir2\"]);\r\n\r\n// Assert the deep contents of a directory\r\nexpect(path).to.be.a.directory().with.deep.contents([\r\n  \"file1.txt\", \"file2.txt\", \r\n  \"subdir1\", \"subdir1/file3.txt\", \"subdir1/file4.txt\",\r\n  \"subdir2\", \"subdir2/file5.txt\", \"subdir2/file6.txt\",\r\n  \"subdir2/subdir3\", \"subdir2/subdir3/file7.txt\", \"subdir2/subdir3/file8.txt\"\r\n]);\r\n\r\n// Assert that two directories have the same top-level contents\r\nexpect(path).to.be.a.directory().and.equal(otherPath);\r\n\r\n// Assert that two directories have the same deep contents\r\nexpect(path).to.be.a.directory().and.deep.equal(otherPath);\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/chaijs/chai-fs/issues/comments/243412053","html_url":"https://github.com/chaijs/chai-fs/pull/17#issuecomment-243412053","issue_url":"https://api.github.com/repos/chaijs/chai-fs/issues/17","id":243412053,"user":{"login":"BigstickCarpet","id":3453903,"avatar_url":"https://avatars.githubusercontent.com/u/3453903?v=3","gravatar_id":"","url":"https://api.github.com/users/BigstickCarpet","html_url":"https://github.com/BigstickCarpet","followers_url":"https://api.github.com/users/BigstickCarpet/followers","following_url":"https://api.github.com/users/BigstickCarpet/following{/other_user}","gists_url":"https://api.github.com/users/BigstickCarpet/gists{/gist_id}","starred_url":"https://api.github.com/users/BigstickCarpet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BigstickCarpet/subscriptions","organizations_url":"https://api.github.com/users/BigstickCarpet/orgs","repos_url":"https://api.github.com/users/BigstickCarpet/repos","events_url":"https://api.github.com/users/BigstickCarpet/events{/privacy}","received_events_url":"https://api.github.com/users/BigstickCarpet/received_events","type":"User","site_admin":false},"created_at":"2016-08-30T11:37:22Z","updated_at":"2016-08-30T11:37:22Z","body":"thanks guys.  working on the next one now..."}}
{"actor":{"display_login":"BigstickCarpet"}}