{"action":"created","comment":{"url":"https://api.github.com/repos/rspec/rspec.github.io/pulls/comments/50222443","id":50222443,"diff_hunk":"@@ -0,0 +1,220 @@\n+---\n+title: How the RSpec 3.0 composable matchers work\n+author: Sam Phippen\n+---\n+\n+##Warmup: the `===` protocol\n+\n+In Ruby, a number of objects implement the `===` protocol. Some of the objects\n+that implement this protocol include:\n+\n+* all class objects\n+* lambdas\n+* regexes\n+* ranges\n+\n+Conceptually, this protocol represents a \"match\", but can be thought of as\n+categorising instances of objects. That is, the object that implements `===`\n+defines whether or not the passed in object belongs in the same category.\n+For example, `Array === []` returns `true`. This is because an empty array is\n+an instance of the array class. `Array === {}` returns false because a hash is\n+not an array. For regexes, `===` returns true if the passed string matches the\n+regex, and false if it does not.\n+\n+The `===` method is used in Ruby case statements to decide if a branch should\n+be taken. For example\n+\n+```Ruby\n+case 3\n+when (1...18)\n+  puts \"hello\"\n+end\n+```\n+\n+will print hello, because `(1...18) === 3` returns `true`.\n+\n+The new RSpec matchers make heavy use of `===` internally, if you'd like to get\n+more of an understanding of `===`, I'd heavily suggest you pop open IRB and\n+play around with it a little before moving on.\n+\n+## RSpec matchers\n+\n+In an RSpec expectation expression like `expect(object_1).to eq(object_2)`\n+there are two primary objects at play, the **target** and the **matcher**. The\n+**target** object is created by \"expect\" and exposes `to` (and `to_not`) which","path":"source/blog/2015-10-31-rspec-compsable-matchers.md","position":44,"original_position":44,"commit_id":"791f05b57834ebc69cf1ed05b5ba279fbc679928","original_commit_id":"791f05b57834ebc69cf1ed05b5ba279fbc679928","user":{"login":"myronmarston","id":49391,"avatar_url":"https://avatars.githubusercontent.com/u/49391?v=3","gravatar_id":"","url":"https://api.github.com/users/myronmarston","html_url":"https://github.com/myronmarston","followers_url":"https://api.github.com/users/myronmarston/followers","following_url":"https://api.github.com/users/myronmarston/following{/other_user}","gists_url":"https://api.github.com/users/myronmarston/gists{/gist_id}","starred_url":"https://api.github.com/users/myronmarston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myronmarston/subscriptions","organizations_url":"https://api.github.com/users/myronmarston/orgs","repos_url":"https://api.github.com/users/myronmarston/repos","events_url":"https://api.github.com/users/myronmarston/events{/privacy}","received_events_url":"https://api.github.com/users/myronmarston/received_events","type":"User","site_admin":false},"body":"Any reason you put expect in quotes instead of backticks?  The backticks help make it clear that it's a method since it renders mono spaced.","created_at":"2016-01-20T07:37:58Z","updated_at":"2016-01-20T07:37:58Z","html_url":"https://github.com/rspec/rspec.github.io/pull/69#discussion_r50222443","pull_request_url":"https://api.github.com/repos/rspec/rspec.github.io/pulls/69","_links":{"self":{"href":"https://api.github.com/repos/rspec/rspec.github.io/pulls/comments/50222443"},"html":{"href":"https://github.com/rspec/rspec.github.io/pull/69#discussion_r50222443"},"pull_request":{"href":"https://api.github.com/repos/rspec/rspec.github.io/pulls/69"}}},"pull_request":{"url":"https://api.github.com/repos/rspec/rspec.github.io/pulls/69","id":34995115,"html_url":"https://github.com/rspec/rspec.github.io/pull/69","diff_url":"https://github.com/rspec/rspec.github.io/pull/69.diff","patch_url":"https://github.com/rspec/rspec.github.io/pull/69.patch","issue_url":"https://api.github.com/repos/rspec/rspec.github.io/issues/69","number":69,"state":"open","locked":false,"title":"Add a post on how the composable matchers work.","user":{"login":"samphippen","id":96662,"avatar_url":"https://avatars.githubusercontent.com/u/96662?v=3","gravatar_id":"","url":"https://api.github.com/users/samphippen","html_url":"https://github.com/samphippen","followers_url":"https://api.github.com/users/samphippen/followers","following_url":"https://api.github.com/users/samphippen/following{/other_user}","gists_url":"https://api.github.com/users/samphippen/gists{/gist_id}","starred_url":"https://api.github.com/users/samphippen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samphippen/subscriptions","organizations_url":"https://api.github.com/users/samphippen/orgs","repos_url":"https://api.github.com/users/samphippen/repos","events_url":"https://api.github.com/users/samphippen/events{/privacy}","received_events_url":"https://api.github.com/users/samphippen/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-05-08T09:57:11Z","updated_at":"2016-01-20T07:37:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d89998ba30c9f185cf0e34fb82ba9f6d14399e02","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rspec/rspec.github.io/pulls/69/commits","review_comments_url":"https://api.github.com/repos/rspec/rspec.github.io/pulls/69/comments","review_comment_url":"https://api.github.com/repos/rspec/rspec.github.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rspec/rspec.github.io/issues/69/comments","statuses_url":"https://api.github.com/repos/rspec/rspec.github.io/statuses/791f05b57834ebc69cf1ed05b5ba279fbc679928","head":{"label":"rspec:composable-matchers-post","ref":"composable-matchers-post","sha":"791f05b57834ebc69cf1ed05b5ba279fbc679928","user":{"login":"rspec","id":22388,"avatar_url":"https://avatars.githubusercontent.com/u/22388?v=3","gravatar_id":"","url":"https://api.github.com/users/rspec","html_url":"https://github.com/rspec","followers_url":"https://api.github.com/users/rspec/followers","following_url":"https://api.github.com/users/rspec/following{/other_user}","gists_url":"https://api.github.com/users/rspec/gists{/gist_id}","starred_url":"https://api.github.com/users/rspec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rspec/subscriptions","organizations_url":"https://api.github.com/users/rspec/orgs","repos_url":"https://api.github.com/users/rspec/repos","events_url":"https://api.github.com/users/rspec/events{/privacy}","received_events_url":"https://api.github.com/users/rspec/received_events","type":"Organization","site_admin":false},"repo":{"id":2544146,"name":"rspec.github.io","full_name":"rspec/rspec.github.io","owner":{"login":"rspec","id":22388,"avatar_url":"https://avatars.githubusercontent.com/u/22388?v=3","gravatar_id":"","url":"https://api.github.com/users/rspec","html_url":"https://github.com/rspec","followers_url":"https://api.github.com/users/rspec/followers","following_url":"https://api.github.com/users/rspec/following{/other_user}","gists_url":"https://api.github.com/users/rspec/gists{/gist_id}","starred_url":"https://api.github.com/users/rspec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rspec/subscriptions","organizations_url":"https://api.github.com/users/rspec/orgs","repos_url":"https://api.github.com/users/rspec/repos","events_url":"https://api.github.com/users/rspec/events{/privacy}","received_events_url":"https://api.github.com/users/rspec/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rspec/rspec.github.io","description":"source for rspec.info","fork":false,"url":"https://api.github.com/repos/rspec/rspec.github.io","forks_url":"https://api.github.com/repos/rspec/rspec.github.io/forks","keys_url":"https://api.github.com/repos/rspec/rspec.github.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rspec/rspec.github.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rspec/rspec.github.io/teams","hooks_url":"https://api.github.com/repos/rspec/rspec.github.io/hooks","issue_events_url":"https://api.github.com/repos/rspec/rspec.github.io/issues/events{/number}","events_url":"https://api.github.com/repos/rspec/rspec.github.io/events","assignees_url":"https://api.github.com/repos/rspec/rspec.github.io/assignees{/user}","branches_url":"https://api.github.com/repos/rspec/rspec.github.io/branches{/branch}","tags_url":"https://api.github.com/repos/rspec/rspec.github.io/tags","blobs_url":"https://api.github.com/repos/rspec/rspec.github.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rspec/rspec.github.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rspec/rspec.github.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/rspec/rspec.github.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rspec/rspec.github.io/statuses/{sha}","languages_url":"https://api.github.com/repos/rspec/rspec.github.io/languages","stargazers_url":"https://api.github.com/repos/rspec/rspec.github.io/stargazers","contributors_url":"https://api.github.com/repos/rspec/rspec.github.io/contributors","subscribers_url":"https://api.github.com/repos/rspec/rspec.github.io/subscribers","subscription_url":"https://api.github.com/repos/rspec/rspec.github.io/subscription","commits_url":"https://api.github.com/repos/rspec/rspec.github.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/rspec/rspec.github.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/rspec/rspec.github.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/rspec/rspec.github.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/rspec/rspec.github.io/contents/{+path}","compare_url":"https://api.github.com/repos/rspec/rspec.github.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rspec/rspec.github.io/merges","archive_url":"https://api.github.com/repos/rspec/rspec.github.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rspec/rspec.github.io/downloads","issues_url":"https://api.github.com/repos/rspec/rspec.github.io/issues{/number}","pulls_url":"https://api.github.com/repos/rspec/rspec.github.io/pulls{/number}","milestones_url":"https://api.github.com/repos/rspec/rspec.github.io/milestones{/number}","notifications_url":"https://api.github.com/repos/rspec/rspec.github.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rspec/rspec.github.io/labels{/name}","releases_url":"https://api.github.com/repos/rspec/rspec.github.io/releases{/id}","created_at":"2011-10-09T19:44:45Z","updated_at":"2015-09-15T13:34:56Z","pushed_at":"2016-01-20T02:17:46Z","git_url":"git://github.com/rspec/rspec.github.io.git","ssh_url":"git@github.com:rspec/rspec.github.io.git","clone_url":"https://github.com/rspec/rspec.github.io.git","svn_url":"https://github.com/rspec/rspec.github.io","homepage":"","size":10360,"stargazers_count":10,"watchers_count":10,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":21,"mirror_url":null,"open_issues_count":8,"forks":21,"open_issues":8,"watchers":10,"default_branch":"source"}},"base":{"label":"rspec:source","ref":"source","sha":"e29ac45967b54c3fd4f8f055c7c8800c240a53e0","user":{"login":"rspec","id":22388,"avatar_url":"https://avatars.githubusercontent.com/u/22388?v=3","gravatar_id":"","url":"https://api.github.com/users/rspec","html_url":"https://github.com/rspec","followers_url":"https://api.github.com/users/rspec/followers","following_url":"https://api.github.com/users/rspec/following{/other_user}","gists_url":"https://api.github.com/users/rspec/gists{/gist_id}","starred_url":"https://api.github.com/users/rspec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rspec/subscriptions","organizations_url":"https://api.github.com/users/rspec/orgs","repos_url":"https://api.github.com/users/rspec/repos","events_url":"https://api.github.com/users/rspec/events{/privacy}","received_events_url":"https://api.github.com/users/rspec/received_events","type":"Organization","site_admin":false},"repo":{"id":2544146,"name":"rspec.github.io","full_name":"rspec/rspec.github.io","owner":{"login":"rspec","id":22388,"avatar_url":"https://avatars.githubusercontent.com/u/22388?v=3","gravatar_id":"","url":"https://api.github.com/users/rspec","html_url":"https://github.com/rspec","followers_url":"https://api.github.com/users/rspec/followers","following_url":"https://api.github.com/users/rspec/following{/other_user}","gists_url":"https://api.github.com/users/rspec/gists{/gist_id}","starred_url":"https://api.github.com/users/rspec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rspec/subscriptions","organizations_url":"https://api.github.com/users/rspec/orgs","repos_url":"https://api.github.com/users/rspec/repos","events_url":"https://api.github.com/users/rspec/events{/privacy}","received_events_url":"https://api.github.com/users/rspec/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rspec/rspec.github.io","description":"source for rspec.info","fork":false,"url":"https://api.github.com/repos/rspec/rspec.github.io","forks_url":"https://api.github.com/repos/rspec/rspec.github.io/forks","keys_url":"https://api.github.com/repos/rspec/rspec.github.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rspec/rspec.github.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rspec/rspec.github.io/teams","hooks_url":"https://api.github.com/repos/rspec/rspec.github.io/hooks","issue_events_url":"https://api.github.com/repos/rspec/rspec.github.io/issues/events{/number}","events_url":"https://api.github.com/repos/rspec/rspec.github.io/events","assignees_url":"https://api.github.com/repos/rspec/rspec.github.io/assignees{/user}","branches_url":"https://api.github.com/repos/rspec/rspec.github.io/branches{/branch}","tags_url":"https://api.github.com/repos/rspec/rspec.github.io/tags","blobs_url":"https://api.github.com/repos/rspec/rspec.github.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rspec/rspec.github.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rspec/rspec.github.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/rspec/rspec.github.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rspec/rspec.github.io/statuses/{sha}","languages_url":"https://api.github.com/repos/rspec/rspec.github.io/languages","stargazers_url":"https://api.github.com/repos/rspec/rspec.github.io/stargazers","contributors_url":"https://api.github.com/repos/rspec/rspec.github.io/contributors","subscribers_url":"https://api.github.com/repos/rspec/rspec.github.io/subscribers","subscription_url":"https://api.github.com/repos/rspec/rspec.github.io/subscription","commits_url":"https://api.github.com/repos/rspec/rspec.github.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/rspec/rspec.github.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/rspec/rspec.github.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/rspec/rspec.github.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/rspec/rspec.github.io/contents/{+path}","compare_url":"https://api.github.com/repos/rspec/rspec.github.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rspec/rspec.github.io/merges","archive_url":"https://api.github.com/repos/rspec/rspec.github.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rspec/rspec.github.io/downloads","issues_url":"https://api.github.com/repos/rspec/rspec.github.io/issues{/number}","pulls_url":"https://api.github.com/repos/rspec/rspec.github.io/pulls{/number}","milestones_url":"https://api.github.com/repos/rspec/rspec.github.io/milestones{/number}","notifications_url":"https://api.github.com/repos/rspec/rspec.github.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rspec/rspec.github.io/labels{/name}","releases_url":"https://api.github.com/repos/rspec/rspec.github.io/releases{/id}","created_at":"2011-10-09T19:44:45Z","updated_at":"2015-09-15T13:34:56Z","pushed_at":"2016-01-20T02:17:46Z","git_url":"git://github.com/rspec/rspec.github.io.git","ssh_url":"git@github.com:rspec/rspec.github.io.git","clone_url":"https://github.com/rspec/rspec.github.io.git","svn_url":"https://github.com/rspec/rspec.github.io","homepage":"","size":10360,"stargazers_count":10,"watchers_count":10,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":21,"mirror_url":null,"open_issues_count":8,"forks":21,"open_issues":8,"watchers":10,"default_branch":"source"}},"_links":{"self":{"href":"https://api.github.com/repos/rspec/rspec.github.io/pulls/69"},"html":{"href":"https://github.com/rspec/rspec.github.io/pull/69"},"issue":{"href":"https://api.github.com/repos/rspec/rspec.github.io/issues/69"},"comments":{"href":"https://api.github.com/repos/rspec/rspec.github.io/issues/69/comments"},"review_comments":{"href":"https://api.github.com/repos/rspec/rspec.github.io/pulls/69/comments"},"review_comment":{"href":"https://api.github.com/repos/rspec/rspec.github.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rspec/rspec.github.io/pulls/69/commits"},"statuses":{"href":"https://api.github.com/repos/rspec/rspec.github.io/statuses/791f05b57834ebc69cf1ed05b5ba279fbc679928"}}}}