{"action":"created","comment":{"url":"https://api.github.com/repos/agco-fuse/documentation/pulls/comments/59721475","id":59721475,"diff_hunk":"@@ -0,0 +1,47 @@\n+require 'spec_helper'\n+require './lib/template_handler.rb'\n+require './lib/json_template.rb'\n+require './lib/swagger_definition.rb'\n+\n+describe(TemplateHandler) do\n+  let(:template) do\n+    double('template')\n+  end\n+\n+  let(:file) do\n+    double('file')\n+  end\n+\n+  subject do\n+    TemplateHandler.new(template)\n+  end\n+\n+  it('should apply a template to a documentation file') do\n+    expect(File).to receive(:read)\\\n+      .with('source/doc1.html.md')\\\n+      .and_return('[[operation:getBrands]]\\n\\n[[model:Brands]]')\n+\n+    operation_template = '```json\\n{ operation: true }\\n```'\n+    expect(template).to receive(:render)\\\n+      .with('{ operation: true }')\\\n+      .and_return(operation_template)\n+    model_template = '```json\\n{ model: true }\\n```'\n+    expect(template).to receive(:render)\\\n+      .with('{ model: true }')\\\n+      .and_return(model_template)\n+\n+    expect(file).to receive(:write)\\\n+      .with([operation_template, '\\n', '\\n', model_template].join)\n+\n+    expect(File).to receive(:open)\\","path":"spec/template_handler_spec.rb","position":36,"original_position":36,"commit_id":"26594e334d20a963556790e6281981aa7ab03b0e","original_commit_id":"26594e334d20a963556790e6281981aa7ab03b0e","user":{"login":"bltavares","id":109474,"avatar_url":"https://avatars.githubusercontent.com/u/109474?v=3","gravatar_id":"","url":"https://api.github.com/users/bltavares","html_url":"https://github.com/bltavares","followers_url":"https://api.github.com/users/bltavares/followers","following_url":"https://api.github.com/users/bltavares/following{/other_user}","gists_url":"https://api.github.com/users/bltavares/gists{/gist_id}","starred_url":"https://api.github.com/users/bltavares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bltavares/subscriptions","organizations_url":"https://api.github.com/users/bltavares/orgs","repos_url":"https://api.github.com/users/bltavares/repos","events_url":"https://api.github.com/users/bltavares/events{/privacy}","received_events_url":"https://api.github.com/users/bltavares/received_events","type":"User","site_admin":false},"body":"How about this style instead of `\\` on the end?\r\n\r\n```ruby\r\n expect(File).to(\r\n  receive(:open)\r\n    .with('source/doc1.html.md', 'w')\r\n    .and_yield(file))\r\n```","created_at":"2016-04-14T13:59:33Z","updated_at":"2016-04-14T13:59:33Z","html_url":"https://github.com/agco-fuse/documentation/pull/1#discussion_r59721475","pull_request_url":"https://api.github.com/repos/agco-fuse/documentation/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/agco-fuse/documentation/pulls/comments/59721475"},"html":{"href":"https://github.com/agco-fuse/documentation/pull/1#discussion_r59721475"},"pull_request":{"href":"https://api.github.com/repos/agco-fuse/documentation/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/agco-fuse/documentation/pulls/1","id":66483551,"html_url":"https://github.com/agco-fuse/documentation/pull/1","diff_url":"https://github.com/agco-fuse/documentation/pull/1.diff","patch_url":"https://github.com/agco-fuse/documentation/pull/1.patch","issue_url":"https://api.github.com/repos/agco-fuse/documentation/issues/1","number":1,"state":"open","locked":false,"title":"Enables Swagger 2.x support","user":{"login":"glauco","id":76370,"avatar_url":"https://avatars.githubusercontent.com/u/76370?v=3","gravatar_id":"","url":"https://api.github.com/users/glauco","html_url":"https://github.com/glauco","followers_url":"https://api.github.com/users/glauco/followers","following_url":"https://api.github.com/users/glauco/following{/other_user}","gists_url":"https://api.github.com/users/glauco/gists{/gist_id}","starred_url":"https://api.github.com/users/glauco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glauco/subscriptions","organizations_url":"https://api.github.com/users/glauco/orgs","repos_url":"https://api.github.com/users/glauco/repos","events_url":"https://api.github.com/users/glauco/events{/privacy}","received_events_url":"https://api.github.com/users/glauco/received_events","type":"User","site_admin":false},"body":"As we move towards exposing new APIs we faced the problem of needing to\r\ndeal with Swagger 1.x and 2.x at the same time.\r\n\r\nThis commit extracts the generator out of Rakefile into smaller classes.\r\n\r\nThese were the created classes:\r\n- DocumentationFinder is responsible for retrieving the documentation\r\nmarkdown files.\r\n- Documentation transclusion is responsible for choreographing the whole\r\nprocess.\r\n- JsonTemplate is responsible for converting a JSON into a Markdown\r\nrepresentation.\r\n- Swagger1DefinitionExtractor is responsible for extracting information\r\nout of Swagger 1.x documents.\r\n- Swagger2DefinitionExtractor is responsible for extracing information\r\nout of Swagger 2.x documents.\r\n- SwaggerDefinitionExtractor is a facade/strategy that makes sure the\r\nuser is not bothered about which Swagger document version is being\r\nhandled.\r\n- SwaggerDefinition represents the operations and models available on\r\nSwagger.\r\n- SwaggerDocumentFetcher is responsible for retrieving Swagger\r\ndocuments.\r\n- SwaggerVersionChecker is responsible for identifying the Swagger\r\ndocument version.\r\n- TemplateHandler is responsible for applying a given SwaggerDefinition\r\nto the markdown documentation file.","created_at":"2016-04-14T13:26:57Z","updated_at":"2016-04-14T13:59:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9e6cdd939949bd6de8c4a467454f13b10247b18a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/agco-fuse/documentation/pulls/1/commits","review_comments_url":"https://api.github.com/repos/agco-fuse/documentation/pulls/1/comments","review_comment_url":"https://api.github.com/repos/agco-fuse/documentation/pulls/comments{/number}","comments_url":"https://api.github.com/repos/agco-fuse/documentation/issues/1/comments","statuses_url":"https://api.github.com/repos/agco-fuse/documentation/statuses/26594e334d20a963556790e6281981aa7ab03b0e","head":{"label":"agco-fuse:add-support-for-swagger-2.0","ref":"add-support-for-swagger-2.0","sha":"26594e334d20a963556790e6281981aa7ab03b0e","user":{"login":"agco-fuse","id":18173515,"avatar_url":"https://avatars.githubusercontent.com/u/18173515?v=3","gravatar_id":"","url":"https://api.github.com/users/agco-fuse","html_url":"https://github.com/agco-fuse","followers_url":"https://api.github.com/users/agco-fuse/followers","following_url":"https://api.github.com/users/agco-fuse/following{/other_user}","gists_url":"https://api.github.com/users/agco-fuse/gists{/gist_id}","starred_url":"https://api.github.com/users/agco-fuse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agco-fuse/subscriptions","organizations_url":"https://api.github.com/users/agco-fuse/orgs","repos_url":"https://api.github.com/users/agco-fuse/repos","events_url":"https://api.github.com/users/agco-fuse/events{/privacy}","received_events_url":"https://api.github.com/users/agco-fuse/received_events","type":"Organization","site_admin":false},"repo":{"id":55700821,"name":"documentation","full_name":"agco-fuse/documentation","owner":{"login":"agco-fuse","id":18173515,"avatar_url":"https://avatars.githubusercontent.com/u/18173515?v=3","gravatar_id":"","url":"https://api.github.com/users/agco-fuse","html_url":"https://github.com/agco-fuse","followers_url":"https://api.github.com/users/agco-fuse/followers","following_url":"https://api.github.com/users/agco-fuse/following{/other_user}","gists_url":"https://api.github.com/users/agco-fuse/gists{/gist_id}","starred_url":"https://api.github.com/users/agco-fuse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agco-fuse/subscriptions","organizations_url":"https://api.github.com/users/agco-fuse/orgs","repos_url":"https://api.github.com/users/agco-fuse/repos","events_url":"https://api.github.com/users/agco-fuse/events{/privacy}","received_events_url":"https://api.github.com/users/agco-fuse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/agco-fuse/documentation","description":"","fork":false,"url":"https://api.github.com/repos/agco-fuse/documentation","forks_url":"https://api.github.com/repos/agco-fuse/documentation/forks","keys_url":"https://api.github.com/repos/agco-fuse/documentation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/agco-fuse/documentation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/agco-fuse/documentation/teams","hooks_url":"https://api.github.com/repos/agco-fuse/documentation/hooks","issue_events_url":"https://api.github.com/repos/agco-fuse/documentation/issues/events{/number}","events_url":"https://api.github.com/repos/agco-fuse/documentation/events","assignees_url":"https://api.github.com/repos/agco-fuse/documentation/assignees{/user}","branches_url":"https://api.github.com/repos/agco-fuse/documentation/branches{/branch}","tags_url":"https://api.github.com/repos/agco-fuse/documentation/tags","blobs_url":"https://api.github.com/repos/agco-fuse/documentation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/agco-fuse/documentation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/agco-fuse/documentation/git/refs{/sha}","trees_url":"https://api.github.com/repos/agco-fuse/documentation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/agco-fuse/documentation/statuses/{sha}","languages_url":"https://api.github.com/repos/agco-fuse/documentation/languages","stargazers_url":"https://api.github.com/repos/agco-fuse/documentation/stargazers","contributors_url":"https://api.github.com/repos/agco-fuse/documentation/contributors","subscribers_url":"https://api.github.com/repos/agco-fuse/documentation/subscribers","subscription_url":"https://api.github.com/repos/agco-fuse/documentation/subscription","commits_url":"https://api.github.com/repos/agco-fuse/documentation/commits{/sha}","git_commits_url":"https://api.github.com/repos/agco-fuse/documentation/git/commits{/sha}","comments_url":"https://api.github.com/repos/agco-fuse/documentation/comments{/number}","issue_comment_url":"https://api.github.com/repos/agco-fuse/documentation/issues/comments{/number}","contents_url":"https://api.github.com/repos/agco-fuse/documentation/contents/{+path}","compare_url":"https://api.github.com/repos/agco-fuse/documentation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/agco-fuse/documentation/merges","archive_url":"https://api.github.com/repos/agco-fuse/documentation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/agco-fuse/documentation/downloads","issues_url":"https://api.github.com/repos/agco-fuse/documentation/issues{/number}","pulls_url":"https://api.github.com/repos/agco-fuse/documentation/pulls{/number}","milestones_url":"https://api.github.com/repos/agco-fuse/documentation/milestones{/number}","notifications_url":"https://api.github.com/repos/agco-fuse/documentation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/agco-fuse/documentation/labels{/name}","releases_url":"https://api.github.com/repos/agco-fuse/documentation/releases{/id}","deployments_url":"https://api.github.com/repos/agco-fuse/documentation/deployments","created_at":"2016-04-07T14:22:27Z","updated_at":"2016-04-08T14:13:11Z","pushed_at":"2016-04-14T13:54:38Z","git_url":"git://github.com/agco-fuse/documentation.git","ssh_url":"git@github.com:agco-fuse/documentation.git","clone_url":"https://github.com/agco-fuse/documentation.git","svn_url":"https://github.com/agco-fuse/documentation","homepage":null,"size":293,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"agco-fuse:master","ref":"master","sha":"2e2efebab238ba7f5476a9c43b4a136a1ff5f9d9","user":{"login":"agco-fuse","id":18173515,"avatar_url":"https://avatars.githubusercontent.com/u/18173515?v=3","gravatar_id":"","url":"https://api.github.com/users/agco-fuse","html_url":"https://github.com/agco-fuse","followers_url":"https://api.github.com/users/agco-fuse/followers","following_url":"https://api.github.com/users/agco-fuse/following{/other_user}","gists_url":"https://api.github.com/users/agco-fuse/gists{/gist_id}","starred_url":"https://api.github.com/users/agco-fuse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agco-fuse/subscriptions","organizations_url":"https://api.github.com/users/agco-fuse/orgs","repos_url":"https://api.github.com/users/agco-fuse/repos","events_url":"https://api.github.com/users/agco-fuse/events{/privacy}","received_events_url":"https://api.github.com/users/agco-fuse/received_events","type":"Organization","site_admin":false},"repo":{"id":55700821,"name":"documentation","full_name":"agco-fuse/documentation","owner":{"login":"agco-fuse","id":18173515,"avatar_url":"https://avatars.githubusercontent.com/u/18173515?v=3","gravatar_id":"","url":"https://api.github.com/users/agco-fuse","html_url":"https://github.com/agco-fuse","followers_url":"https://api.github.com/users/agco-fuse/followers","following_url":"https://api.github.com/users/agco-fuse/following{/other_user}","gists_url":"https://api.github.com/users/agco-fuse/gists{/gist_id}","starred_url":"https://api.github.com/users/agco-fuse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agco-fuse/subscriptions","organizations_url":"https://api.github.com/users/agco-fuse/orgs","repos_url":"https://api.github.com/users/agco-fuse/repos","events_url":"https://api.github.com/users/agco-fuse/events{/privacy}","received_events_url":"https://api.github.com/users/agco-fuse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/agco-fuse/documentation","description":"","fork":false,"url":"https://api.github.com/repos/agco-fuse/documentation","forks_url":"https://api.github.com/repos/agco-fuse/documentation/forks","keys_url":"https://api.github.com/repos/agco-fuse/documentation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/agco-fuse/documentation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/agco-fuse/documentation/teams","hooks_url":"https://api.github.com/repos/agco-fuse/documentation/hooks","issue_events_url":"https://api.github.com/repos/agco-fuse/documentation/issues/events{/number}","events_url":"https://api.github.com/repos/agco-fuse/documentation/events","assignees_url":"https://api.github.com/repos/agco-fuse/documentation/assignees{/user}","branches_url":"https://api.github.com/repos/agco-fuse/documentation/branches{/branch}","tags_url":"https://api.github.com/repos/agco-fuse/documentation/tags","blobs_url":"https://api.github.com/repos/agco-fuse/documentation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/agco-fuse/documentation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/agco-fuse/documentation/git/refs{/sha}","trees_url":"https://api.github.com/repos/agco-fuse/documentation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/agco-fuse/documentation/statuses/{sha}","languages_url":"https://api.github.com/repos/agco-fuse/documentation/languages","stargazers_url":"https://api.github.com/repos/agco-fuse/documentation/stargazers","contributors_url":"https://api.github.com/repos/agco-fuse/documentation/contributors","subscribers_url":"https://api.github.com/repos/agco-fuse/documentation/subscribers","subscription_url":"https://api.github.com/repos/agco-fuse/documentation/subscription","commits_url":"https://api.github.com/repos/agco-fuse/documentation/commits{/sha}","git_commits_url":"https://api.github.com/repos/agco-fuse/documentation/git/commits{/sha}","comments_url":"https://api.github.com/repos/agco-fuse/documentation/comments{/number}","issue_comment_url":"https://api.github.com/repos/agco-fuse/documentation/issues/comments{/number}","contents_url":"https://api.github.com/repos/agco-fuse/documentation/contents/{+path}","compare_url":"https://api.github.com/repos/agco-fuse/documentation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/agco-fuse/documentation/merges","archive_url":"https://api.github.com/repos/agco-fuse/documentation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/agco-fuse/documentation/downloads","issues_url":"https://api.github.com/repos/agco-fuse/documentation/issues{/number}","pulls_url":"https://api.github.com/repos/agco-fuse/documentation/pulls{/number}","milestones_url":"https://api.github.com/repos/agco-fuse/documentation/milestones{/number}","notifications_url":"https://api.github.com/repos/agco-fuse/documentation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/agco-fuse/documentation/labels{/name}","releases_url":"https://api.github.com/repos/agco-fuse/documentation/releases{/id}","deployments_url":"https://api.github.com/repos/agco-fuse/documentation/deployments","created_at":"2016-04-07T14:22:27Z","updated_at":"2016-04-08T14:13:11Z","pushed_at":"2016-04-14T13:54:38Z","git_url":"git://github.com/agco-fuse/documentation.git","ssh_url":"git@github.com:agco-fuse/documentation.git","clone_url":"https://github.com/agco-fuse/documentation.git","svn_url":"https://github.com/agco-fuse/documentation","homepage":null,"size":293,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/agco-fuse/documentation/pulls/1"},"html":{"href":"https://github.com/agco-fuse/documentation/pull/1"},"issue":{"href":"https://api.github.com/repos/agco-fuse/documentation/issues/1"},"comments":{"href":"https://api.github.com/repos/agco-fuse/documentation/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/agco-fuse/documentation/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/agco-fuse/documentation/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/agco-fuse/documentation/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/agco-fuse/documentation/statuses/26594e334d20a963556790e6281981aa7ab03b0e"}}}}