Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add travis and coveralls integration #19

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
language: node_js
node_js:
- "stable"
- "5"
- "4"
- "0.12"
- "0.10"
- "iojs"
before_install:
- npm install -g phantomjs-prebuilt
env:
- CXX=g++-4.8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
script: npm run-script coveralls
after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
7 changes: 0 additions & 7 deletions Makefile

This file was deleted.

File renamed without changes.
44 changes: 31 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
{
"name": "x-ray-phantom",
"version": "1.0.1",
"description": "phantom driver for x-ray",
"keywords": [],
"author": "Matthew Mueller <[email protected]>",
"version": "1.0.1",
"main": "index",
"author": {
"name": "Matthew Mueller",
"email": "[email protected]"
},
"repository": {
"type": "git",
"url": "git://github.com/lapwinglabs/x-ray-phantom.git"
},
"keywords": [],
"dependencies": {
"debug": "^2.1.1",
"nightmare": "^1.7.0",
"normalizeurl": "^0.1.3",
"wrap-fn": "^0.1.4"
"debug": "~2.1.1",
"nightmare": "~1.7.0",
"normalizeurl": "~0.1.3",
"wrap-fn": "~0.1.4"
},
"devDependencies": {
"cheerio": "^0.19.0",
"mocha": "*",
"nightmare-swiftly": "^0.2.4",
"x-ray-crawler": "^2.0.1"
"cheerio": "~0.19.0",
"coveralls": "~2.11.8",
"istanbul": "~0.4.2",
"mocha": "latest",
"nightmare-swiftly": "~0.2.4",
"x-ray": "~2.0.3",
"x-ray-crawler": "~2.0.1"
},
"engines": {
"node": ">= 0.10"
},
"scripts": {
"coveralls": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly",
"pretest": "standard",
"test": "mocha"
},
"bugs": {
"url": "https://github.com/lapwinglabs/x-ray-phantom/issues"
},
"main": "index"
}
"homepage": "https://github.com/lapwinglabs/x-ray-phantom#readme"
}
2 changes: 2 additions & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--reporter spec
--timeout 30000
71 changes: 0 additions & 71 deletions test/phantom.js

This file was deleted.

71 changes: 71 additions & 0 deletions test/phantom_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* global describe, it */

/**
* Module Dependencies
*/

var Crawler = require('x-ray-crawler')
var cheerio = require('cheerio')
var join = require('path').join
var assert = require('assert')
var phantom = require('../')

/**
* Tests
*/

describe('phantom driver', function () {
it('should have sensible defaults', function (done) {
var crawler = Crawler()
.driver(phantom({ webSecurity: false }))

crawler('http://google.com', function (err, ctx) {
if (err) return done(err)
var $ = cheerio.load(ctx.body)
var title = $('title').text()
assert.equal('Google', title)
done()
})
})

it('should work with client-side pages', function (done) {
var crawler = Crawler()
.driver(phantom({ webSecurity: false }))

crawler('https://exchange.coinbase.com/trade', function (err, ctx) {
if (err) return done(err)
var $ = cheerio.load(ctx.body)
var price = $('.market-num').text()
assert.equal(false, isNaN(+price))
done()
})
})

it('should support custom functions', function (done) {
var crawler = Crawler()
.driver(phantom(runner))

crawler('http://mat.io', function (err, ctx) {
if (err) return done(err)
var $ = cheerio.load(ctx.body)
var title = $('title').text()
assert.equal('Lapwing Labs', title)
done()
})

function runner (ctx, nightmare) {
return nightmare
.goto(ctx.url)
.click('.Header-logo-item+ .Header-list-item a')
.wait()
}
})
})

/**
* Read
*/

function get (path) {
return require(join(__dirname, 'fixtures', path))
}
22 changes: 22 additions & 0 deletions test/phantom_xray_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* global it, describe */

'use strict'

var Xray = require('x-ray')
var phantom = require('../')
var assert = require('assert')

describe('Xray.driver(fn)', function () {
it('should support basic phantom', function (done) {
var x = Xray()
.driver(phantom({
webSecurity: false
}))

x('http://www.google.com/ncr', 'title')(function (err, str) {
if (err) return done(err)
assert.equal('Google', str)
done()
})
})
})