diff --git a/Gruntfile.coffee b/Gruntfile.coffee index b27a82a..8707fd6 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -12,6 +12,25 @@ module.exports = -> # Browser build of NoFlo noflo_browser: + options: + webpack: + module: + loaders: [ + { test: /\.coffee$/, loader: "coffee-loader" } + { test: /\.json$/, loader: "json-loader" } + { test: /\.fbp$/, loader: "fbp-loader" } + ] + resolve: + extensions: [".coffee", ".js"] + node: + net: 'empty' + tls: 'empty' + fs: 'empty' + target: 'web' + ignores: [ + /bin\/coffee/ + /tv4/ + ] build: files: 'browser/noflo-github.js': ['component.json'] diff --git a/components/CreateBlob.coffee b/components/CreateBlob.coffee index b04d77d..c6330f5 100644 --- a/components/CreateBlob.coffee +++ b/components/CreateBlob.coffee @@ -1,5 +1,5 @@ noflo = require 'noflo' -octo = require 'octo' +github = require 'github' exports.getComponent = -> c = new noflo.Component @@ -26,15 +26,20 @@ exports.getComponent = -> async: true forwardGroups: true , (data, groups, out, callback) -> - api = octo.api() - api.token c.params.token if c.params.token + api = new github + unless c.params.token + return callback new Error 'token required' + api.authenticate + type: 'token' + token: c.params.token - req = api.post "/repos/#{data.repository}/git/blobs", + [org, repoName] = data.repository.split '/' + api.gitdata.createBlob + owner: org + repo: repoName content: data.content encoding: 'utf-8' - req.on 'success', (res) -> - out.send res.body.sha + , (err, res) -> + return callback err if err + out.send res.sha do callback - req.on 'error', (err) -> - callback err.error or err.body - do req diff --git a/components/CreateCommit.coffee b/components/CreateCommit.coffee index 6a97d9e..1af800c 100644 --- a/components/CreateCommit.coffee +++ b/components/CreateCommit.coffee @@ -1,5 +1,5 @@ noflo = require 'noflo' -octo = require 'octo' +github = require 'github' exports.getComponent = -> c = new noflo.Component @@ -32,16 +32,21 @@ exports.getComponent = -> async: true forwardGroups: true , (data, groups, out, callback) -> - api = octo.api() - api.token c.params.token if c.params.token + api = new github + unless c.params.token + return callback new Error 'token required' + api.authenticate + type: 'token' + token: c.params.token - req = api.post "/repos/#{data.repository}/git/commits", + [org, repoName] = data.repository.split '/' + api.gitdata.createCommit + owner: org + repo: repoName message: data.message tree: data.tree parents: data.parents or [] - req.on 'success', (res) -> - out.send res.body.sha + , (err, res) -> + return callback err if err + out.send res.sha do callback - req.on 'error', (err) -> - callback err.error or err.body - do req diff --git a/components/CreateOrgRepository.coffee b/components/CreateOrgRepository.coffee index 88464bb..bc5f3df 100644 --- a/components/CreateOrgRepository.coffee +++ b/components/CreateOrgRepository.coffee @@ -1,5 +1,5 @@ noflo = require 'noflo' -octo = require 'octo' +github = require 'github' exports.getComponent = -> c = new noflo.Component @@ -26,19 +26,19 @@ exports.getComponent = -> async: true forwardGroups: true , (data, groups, out, callback) -> - api = octo.api() + api = new github unless c.params.token return callback new Error 'token required' - api.token c.params.token + api.authenticate + type: 'token' + token: c.params.token - request = api.post "/orgs/#{data.org}/repos", + api.repos.createForOrg + org: data.org name: data.in - - request.on 'success', (res) -> + , (err, res) -> + return callback err if err out.beginGroup data.in out.send res.body out.endGroup() - callback() - request.on 'error', (err) -> - callback err.error or err.body - do request + do callback diff --git a/components/CreateOrphanBranch.coffee b/components/CreateOrphanBranch.coffee index 8199699..dee5899 100644 --- a/components/CreateOrphanBranch.coffee +++ b/components/CreateOrphanBranch.coffee @@ -1,5 +1,5 @@ noflo = require 'noflo' -octo = require 'octo' +github = require 'github' exports.getComponent = -> c = new noflo.Component @@ -21,7 +21,7 @@ exports.getComponent = -> c.outPorts.add 'error', datatype: 'object' - c.getOcto = -> octo + c.getApi = -> new github noflo.helpers.WirePattern c, in: ['branch', 'repository'] @@ -30,45 +30,54 @@ exports.getComponent = -> async: true forwardGroups: true , (data, groups, out, callback) -> - api = octo.api() - api.token c.params.token if c.params.token + api = new github + unless c.params.token + return callback new Error 'token required' + api.authenticate + type: 'token' + token: c.params.token + [org, repoName] = data.repository.split '/' # First check if the branch already exists - branchReq = api.get "/repos/#{data.repository}/branches/#{data.branch}" - branchReq.on 'success', (branchRes) -> - out.send data.branch - callback() - branchReq.on 'error', -> + api.repos.getBranch + owner: org + repo: repoName + branch: data.branch + , (err) -> + unless err + out.send data.branch + do callback + return # Missing branch, we need to create an empty commit, and then a reference to it - treeReq = api.post "/repos/#{data.repository}/git/trees", + api.gitdata.createTree + owner: org + repo: repoName tree: [ path: 'README.md' content: data.branch mode: '100644' type: 'blob' ] - treeReq.on 'success', (treeRes) -> - return callback new Error 'No SHA' unless treeRes.body.sha + , (err, tree) -> + return callback err if err + return callback new Error 'No SHA' unless tree.sha - commitReq = api.post "/repos/#{data.repository}/git/commits", + api.gitdata.createCommit + owner: org + repo: repoName message: 'Initial' - tree: treeRes.body.sha + tree: tree.sha parents: [] - commitReq.on 'success', (commitRes) -> - refReq = api.post "/repos/#{data.repository}/git/refs", + , (err, commit) -> + return callback err if err + return callback new Error 'No commit SHA' unless commit.sha + + api.gitdata.createReference + owner: org + repo: repoName ref: "refs/heads/#{data.branch}" - sha: commitRes.body.sha - refReq.on 'success', (refRes) -> + sha: commit.sha + , (err) -> + return callback err if err out.send data.branch callback() - refReq.on 'error', (error) -> - callback error.error or error.body - do refReq - - commitReq.on 'error', (error) -> - callback error.error or error.body - do commitReq - treeReq.on 'error', (error) -> - callback error.error or error.body - do treeReq - do branchReq diff --git a/components/CreateRepository.coffee b/components/CreateRepository.coffee index 482372c..77c239a 100644 --- a/components/CreateRepository.coffee +++ b/components/CreateRepository.coffee @@ -1,5 +1,5 @@ noflo = require 'noflo' -octo = require 'octo' +github = require 'github' exports.getComponent = -> c = new noflo.Component @@ -10,6 +10,7 @@ exports.getComponent = -> c.inPorts.add 'token', datatype: 'string' description: 'GitHub API token' + required: true c.outPorts.add 'out', datatype: 'object' c.outPorts.add 'error', @@ -23,19 +24,18 @@ exports.getComponent = -> async: true forwardGroups: true , (data, groups, out, callback) -> - api = octo.api() + api = new github unless c.params.token return callback new Error 'token required' - api.token c.params.token + api.authenticate + type: 'token' + token: c.params.token - request = api.post '/user/repos', + api.repos.create name: data - - request.on 'success', (res) -> + , (err, res) -> + return callback err if err out.beginGroup data - out.send res.body + out.send res out.endGroup() callback() - request.on 'error', (err) -> - callback err.error or err.body - do request diff --git a/components/CreateTree.coffee b/components/CreateTree.coffee index c89c02a..4e93de0 100644 --- a/components/CreateTree.coffee +++ b/components/CreateTree.coffee @@ -1,5 +1,5 @@ noflo = require 'noflo' -octo = require 'octo' +github = require 'github' exports.getComponent = -> c = new noflo.Component @@ -29,15 +29,20 @@ exports.getComponent = -> async: true forwardGroups: true , (data, groups, out, callback) -> - api = octo.api() - api.token c.params.token if c.params.token + api = new github + unless c.params.token + return callback new Error 'token required' + api.authenticate + type: 'token' + token: c.params.token - req = api.post "/repos/#{data.repository}/git/trees", + [org, repoName] = data.repository.split '/' + api.gitdata.createTree + owner: org + repo: repoName tree: data.tree base_tree: c.params.base - req.on 'success', (res) -> - out.send res.body + , (err, res) -> + return callback err if err + out.send res do callback - req.on 'error', (err) -> - callback err.error or err.body - do req diff --git a/components/GetBlob.coffee b/components/GetBlob.coffee index 7c6b37b..85e8a4b 100644 --- a/components/GetBlob.coffee +++ b/components/GetBlob.coffee @@ -1,5 +1,5 @@ noflo = require 'noflo' -octo = require 'octo' +github = require 'github' exports.getComponent = -> c = new noflo.Component @@ -28,19 +28,24 @@ exports.getComponent = -> async: true forwardGroups: true , (data, groups, out, callback) -> - api = octo.api() - api.token c.params.token if c.params.token + api = new github + unless c.params.token + return callback new Error 'token required' + api.authenticate + type: 'token' + token: c.params.token - request = api.get "/repos/#{data.repository}/git/blobs/#{data.sha}" - request.on 'success', (res) -> - unless res.body - return callback new Error 'no result available' + [org, repoName] = data.repository.split '/' + api.gitdata.getBlob + owner: org + repo: repoName + sha: data.sha + , (err, res) -> + return callback err if err + return callback new Error 'no result available' unless res out.beginGroup data.repository out.beginGroup data.sha out.send res.body out.endGroup() out.endGroup() do callback - request.on 'error', (err) -> - callback err.error or err.body - do request diff --git a/components/GetContents.coffee b/components/GetContents.coffee index c92b834..9d3b0a2 100644 --- a/components/GetContents.coffee +++ b/components/GetContents.coffee @@ -1,10 +1,6 @@ noflo = require 'noflo' -octo = require 'octo' - -unless noflo.isBrowser() - atob = require 'atob' -else - atob = window.atob +github = require 'github' +atob = require 'atob' exports.getComponent = -> c = new noflo.Component @@ -52,18 +48,27 @@ exports.getComponent = -> async: true forwardGroups: true , (data, groups, out, callback) -> - api = octo.api() - api.token c.params.token if c.params.token + api = new github + if c.params.token + api.authenticate + type: 'token' + token: c.params.token - request = api.get "/repos/#{data.repository}/contents/#{data.path}?ref=#{c.ref}" - request.on 'success', (res) -> - unless res.body.content - unless toString.call(res.body) is '[object Array]' + [org, repoName] = data.repository.split '/' + api.repos.getContent + owner: org + repo: repoName + path: data.path + ref: c.ref + , (err, res) -> + return callback err if err + unless res.content + unless toString.call(res) is '[object Array]' callback new Error 'content not found' return # Directory, send file paths c.outPorts.files.beginGroup data.repository if c.sendRepo - for file in res.body + for file in res c.outPorts.files.send file c.outPorts.files.endGroup() if c.sendRepo c.outPorts.files.disconnect() @@ -71,10 +76,7 @@ exports.getComponent = -> return out.beginGroup data.repository if c.sendRepo out.beginGroup data.path - out.send decodeURIComponent escape atob res.body.content.replace /\s/g, '' + out.send decodeURIComponent escape atob res.content.replace /\s/g, '' out.endGroup() out.endGroup() if c.sendRepo do callback - request.on 'error', (err) -> - callback err.error or err.body - do request diff --git a/components/GetCurrentUser.coffee b/components/GetCurrentUser.coffee index c8abb6c..579a298 100644 --- a/components/GetCurrentUser.coffee +++ b/components/GetCurrentUser.coffee @@ -1,5 +1,5 @@ noflo = require 'noflo' -octo = require 'octo' +github = require 'github' exports.getComponent = -> c = new noflo.Component @@ -16,12 +16,11 @@ exports.getComponent = -> forwardGroups: true async: true , (data, groups, out, callback) -> - api = octo.api() - api.token data - request = api.get "/user" - request.on 'success', (res) => - out.send res.body + api = new github + api.authenticate + type: 'token' + token: data + api.users.get {}, (err, res) -> + return callback err if err + out.send res do callback - request.on 'error', (err) => - callback err.error or err.body - do request diff --git a/components/GetGist.coffee b/components/GetGist.coffee index 787a7d6..1ed0267 100644 --- a/components/GetGist.coffee +++ b/components/GetGist.coffee @@ -1,5 +1,5 @@ noflo = require 'noflo' -octo = require 'octo' +github = require 'github' exports.getComponent = -> c = new noflo.Component @@ -24,18 +24,19 @@ exports.getComponent = -> async: true forwardGroups: true , (id, groups, out, callback) -> - api = octo.api() - api.token c.params.token if c.params?.token - - request = api.get "/gists/#{id}" - request.on 'success', (res) -> - unless res.body + api = new github + if c.params.token + api.authenticate + type: 'token' + token: c.params.token + api.gists.get + id: id + , (err, res) -> + return callback err if err + unless res callback new Error 'No result received' return out.beginGroup id - out.send res.body + out.send res out.endGroup id callback() - request.on 'error', (err) -> - callback err.error or err.body - do request diff --git a/components/GetReference.coffee b/components/GetReference.coffee index 5f2f690..6d339f4 100644 --- a/components/GetReference.coffee +++ b/components/GetReference.coffee @@ -1,5 +1,5 @@ noflo = require 'noflo' -octo = require 'octo' +github = require 'github' exports.getComponent = -> c = new noflo.Component @@ -24,21 +24,27 @@ exports.getComponent = -> async: true forwardGroups: true , (repository, groups, out, callback) -> - api = octo.api() - api.token c.params.token if c.params?.token + api = new github + if c.params.token + api.authenticate + type: 'token' + token: c.params.token + ref = c.params?.reference or 'heads/master' - request = api.get "/repos/#{repository}/git/refs/#{ref}" - request.on 'success', (res) -> - unless res.body + [org, repoName] = data.repository.split '/' + api.gitdata.getReference + owner: org + repo: repoName + ref: ref + , (err, res) -> + return callback err if err + unless res callback new Error 'No result received' return out.beginGroup repository out.beginGroup ref - out.send res.body + out.send res out.endGroup() out.endGroup() do callback - request.on 'error', (err) -> - callback err.error or err.body - do request diff --git a/components/GetRepository.coffee b/components/GetRepository.coffee index ef1dc6b..55de091 100644 --- a/components/GetRepository.coffee +++ b/components/GetRepository.coffee @@ -1,5 +1,5 @@ noflo = require 'noflo' -octo = require 'octo' +github = require 'github' exports.getComponent = -> c = new noflo.Component @@ -23,17 +23,20 @@ exports.getComponent = -> async: true forwardGroups: true , (data, groups, out, callback) -> - api = octo.api() + api = new github unless c.params.token return callback new Error 'token required' - api.token c.params.token + api.authenticate + type: 'token' + token: c.params.token - request = api.get "/repos/#{data}" - request.on 'success', (res) -> + [org, repoName] = data.split '/' + api.repos.get + owner: org + repo: repoName + , (err, res) -> + return callback err if err out.beginGroup data - out.send res.body + out.send res out.endGroup() callback() - request.on 'error', (res) -> - callback res.error or res.body - do request diff --git a/components/GetStargazers.coffee b/components/GetStargazers.coffee index 1512f85..f711d07 100644 --- a/components/GetStargazers.coffee +++ b/components/GetStargazers.coffee @@ -1,5 +1,25 @@ noflo = require 'noflo' -octo = require 'octo' +github = require 'github' + +sendBatch = (api, data, res, out, callback, grouped) -> + unless grouped + out.beginGroup data + grouped = true + + unless res.length + out.endGroup() if grouped + return callback() + + out.send user for user in res + + unless api.hasNextPage res + out.endGroup() if grouped + callback() + return + + api.getNextPage res, {}, (err, next) -> + return callback err if err + sendBatch api, data, next, out, callback, grouped exports.getComponent = -> c = new noflo.Component @@ -21,23 +41,19 @@ exports.getComponent = -> forwardGroups: true async: true , (data, groups, out, callback) -> - api = octo.api() - api.token c.params.token + api = new github + unless c.params.token + return callback new Error 'token required' + api.authenticate + type: 'token' + token: c.params.token + grouped = false - request = api.get "/repos/#{data}/stargazers" - request.perpage 30 - request.on 'success', (res) -> - unless grouped - out.beginGroup data - grouped = true - - unless res.body.length - out.endGroup() if grouped - return callback() - out.send user for user in res.body - return request.next() if request.hasnext() - out.endGroup() if grouped - callback() - request.on 'error', (err) => - callback err.error or err.body - do request + + [org, repoName] = data.split '/' + api.activity.getStargazersForRepo + owner: org + repo: repoName + , (err, res) -> + return callback err if err + sendBatch api, data, res, out, callback, grouped diff --git a/components/GetUser.coffee b/components/GetUser.coffee index 441f704..5920d58 100644 --- a/components/GetUser.coffee +++ b/components/GetUser.coffee @@ -1,5 +1,5 @@ noflo = require 'noflo' -octo = require 'octo' +github = require 'github' exports.getComponent = -> c = new noflo.Component @@ -21,13 +21,15 @@ exports.getComponent = -> forwardGroups: true async: true , (data, groups, out, callback) -> - api = octo.api() - api.token c.params.token - - request = api.get "/users/#{data}" - request.on 'success', (res) -> - out.send res.body + api = new github + unless c.params.token + return callback new Error 'token required' + api.authenticate + type: 'token' + token: c.params.token + api.users.getForUser + username: data + , (err, res) -> + return callback err if err + out.send res do callback - request.on 'error', (err) -> - callback err.error or err.body - do request diff --git a/components/SetContents.coffee b/components/SetContents.coffee index 8c2a2d8..cedde41 100644 --- a/components/SetContents.coffee +++ b/components/SetContents.coffee @@ -1,10 +1,6 @@ noflo = require 'noflo' -octo = require 'octo' - -unless noflo.isBrowser() - btoa = require 'btoa' -else - btoa = window.btoa +github = require 'github' +btoa = require 'btoa' exports.getComponent = -> c = new noflo.Component @@ -57,47 +53,55 @@ exports.getComponent = -> async: true forwardGroups: true , (data, groups, out, callback) -> - api = octo.api() - api.token c.params.token if c.params.token + api = new github + unless c.params.token + return callback new Error 'token required' + api.authenticate + type: 'token' + token: c.params.token + [org, repoName] = data.repository.split '/' # Start by getting the SHA - shaReq = api.get "/repos/#{data.repository}/contents/#{data.path}?ref=#{c.branch}" - shaReq.on 'success', (shaRes) -> - # SHA found, update - updateReq = api.put "/repos/#{data.repository}/contents/#{data.path}", - path: data.path - message: data.message - content: btoa unescape encodeURIComponent data.in - sha: shaRes.body.sha - branch: c.branch - updateReq.on 'success', (updateRes) -> - # File was updated - out.beginGroup data.repository if c.sendRepo - out.beginGroup data.path - out.send updateRes.body.commit.sha - out.endGroup() - out.endGroup() if c.sendRepo - do callback - updateReq.on 'error', (error) -> - callback error.error or error.body - do updateReq - - shaReq.on 'error', -> + api.repos.getContent + owner: org + repo: repoName + path: data.path + branch: c.branch + , (err, res) -> + if res.sha + # SHA found, update + api.repos.updateFile + owner: org + repo: repoName + path: data.path + message: data.message + content: btoa unescape encodeURIComponent data.in + sha: res.sha + branch: c.branch + , (err, updated) -> + return callback err if err + # File was updated + out.beginGroup data.repository if c.sendRepo + out.beginGroup data.path + out.send updated.commit.sha + out.endGroup() + out.endGroup() if c.sendRepo + do callback + return # No SHA found, create as new file - createReq = api.put "/repos/#{data.repository}/contents/#{data.path}", + api.repos.createFile + owner: org + repo: repoName path: data.path message: data.message content: btoa unescape encodeURIComponent data.in branch: c.branch - createReq.on 'success', (createRes) -> + , (err, created) -> + return callback err if err # File was created out.beginGroup data.repository if c.sendRepo out.beginGroup data.path - out.send createRes.body.commit.sha + out.send created.commit.sha out.endGroup() out.endGroup() if c.sendRepo do callback - createReq.on 'error', (error) -> - callback error.error or error.body - do createReq - do shaReq diff --git a/components/UpdateReference.coffee b/components/UpdateReference.coffee index 0f56189..d3e1d00 100644 --- a/components/UpdateReference.coffee +++ b/components/UpdateReference.coffee @@ -1,5 +1,5 @@ noflo = require 'noflo' -octo = require 'octo' +github = require 'github' exports.getComponent = -> c = new noflo.Component @@ -31,18 +31,25 @@ exports.getComponent = -> async: true forwardGroups: true , (data, groups, out, callback) -> - api = octo.api() - api.token c.params.token if c.params.token + api = new github + unless c.params.token + return callback new Error 'token required' + api.authenticate + type: 'token' + token: c.params.token + ref = c.params?.reference or 'heads/master' force = String(c.params?.force) is 'true' ref = ref.substr 5 if ref.substr(0, 5) is 'refs/' - req = api.patch "/repos/#{data.repository}/git/refs/#{ref}", + [org, repoName] = data.repository.split '/' + api.gitdata.updateReference + owner: org + repo: repoName + ref: ref sha: data.commit force: false - req.on 'success', (res) -> + , (err, res) -> + return callback err if err out.send res.body do callback - req.on 'error', (err) -> - callback err.error or err.body - do req diff --git a/package.json b/package.json index 7196ac4..b3f8d40 100644 --- a/package.json +++ b/package.json @@ -15,10 +15,10 @@ "node": ">=0.6.0" }, "dependencies": { - "noflo": "0.x >= 0.5", - "octo": "git://github.com/bergie/octo.git#patched", "atob": "~2.0.3", - "btoa": "~1.1.2" + "btoa": "~1.1.2", + "github": "^7.0.1", + "noflo": "0.x >= 0.5" }, "devDependencies": { "chai": "^3.5.0", diff --git a/spec/CreateOrphanBranch.coffee b/spec/CreateOrphanBranch.coffee index bcae1b1..b55e1f9 100644 --- a/spec/CreateOrphanBranch.coffee +++ b/spec/CreateOrphanBranch.coffee @@ -71,36 +71,42 @@ describe 'CreateOrphanBranch component', -> describe 'creating a branch to a newly-initialized repo', -> api = null + repoName = null before (done) -> return @skip() unless process?.env?.GITHUB_API_TOKEN @timeout 4000 - api = c.getOcto().api() - api.token process.env.GITHUB_API_TOKEN - request = api.post "/orgs/the-domains/repos", - name: "example.com" + + prefix = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5) + repoName = "#{prefix}.example.com" + + api = c.getApi() + api.authenticate + type: 'token' + token: process.env.GITHUB_API_TOKEN + api.repos.createForOrg + org: 'the-domains' + name: repoName private: false has_issues: false has_wiki: false has_downloads: false auto_init: true - request.on 'success', (res) -> + , (err) -> + return done err if err setTimeout -> done() , 1000 - request.on 'error', (err) -> - done new Error err.body.message - do request return after (done) -> return @skip() unless process?.env?.GITHUB_API_TOKEN @timeout 4000 - request = api.del "/repos/the-domains/example.com" - request.on 'success', -> + api.repos.delete + owner: 'the-domains' + repo: repoName + , (err) -> + return done err if err + api = null done() - request.on 'error', (err) -> - done new Error err.body.message - do request - api = null return it 'should succeed', (done) -> @timeout 10000 @@ -109,5 +115,5 @@ describe 'CreateOrphanBranch component', -> chai.expect(data).to.equal 'grid-pages' done() token.send process.env.GITHUB_API_TOKEN - repo.send 'the-domains/example.com' + repo.send "the-domains/#{repoName}" branch.send 'grid-pages' diff --git a/spec/GetContents.coffee b/spec/GetContents.coffee index b8b43fe..aff9a2d 100644 --- a/spec/GetContents.coffee +++ b/spec/GetContents.coffee @@ -89,8 +89,9 @@ describe 'GetContents component', -> out.on 'data', (data) -> return done new Error 'Unexpected data received' err.on 'data', (data) -> - chai.expect(data).to.be.an 'error' - chai.expect(data.status).to.equal 404 + chai.expect(data).to.be.an 'object' + chai.expect(data.message).to.be.a 'string' + chai.expect(data.code).to.equal 404 done() token.send process.env.GITHUB_API_TOKEN diff --git a/spec/GetGist.coffee b/spec/GetGist.coffee index 0e3407e..f067b76 100644 --- a/spec/GetGist.coffee +++ b/spec/GetGist.coffee @@ -36,8 +36,6 @@ describe 'GetGist component', -> err = null describe 'reading a valid gist without token', -> - before -> - return @skip() unless process?.env?.GITHUB_API_TOKEN it 'should succeed', (done) -> err.on 'data', done out.on 'data', (data) -> @@ -49,7 +47,6 @@ describe 'GetGist component', -> before -> return @skip() unless process?.env?.GITHUB_API_TOKEN it 'should succeed', (done) -> - return @skip() unless process?.env?.GITHUB_API_TOKEN err.on 'data', done out.on 'data', (data) -> chai.expect(data).to.be.an 'object' diff --git a/spec/GetRepository.coffee b/spec/GetRepository.coffee index 08240f5..7f6c55c 100644 --- a/spec/GetRepository.coffee +++ b/spec/GetRepository.coffee @@ -57,8 +57,9 @@ describe 'GetRepository component', -> out.on 'data', (data) -> return done new Error 'Should not have returned data' err.on 'data', (data) -> - chai.expect(data).to.be.an 'error' - chai.expect(data.status).to.equal 404 + chai.expect(data).to.be.an 'object' + chai.expect(data.message).to.be.a 'string' + chai.expect(data.code).to.equal 404 done() token.send process.env.GITHUB_API_TOKEN