Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Phantomjs guard automatically runs PhantomJS with a driver and a URL, usually a web server hosting tests. It executes the tests and displays the test result.
branch: master

This branch is 1 commit behind carhartl:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/guard
spec
.gitignore
Gemfile
Guardfile
LICENSE
README.rdoc
Rakefile
guard-phantomjs.gemspec

README.rdoc

guard-phantomjs

Phantomjs guard automatically runs PhantomJS with a driver and a URL, usually a web server hosting tests. It executes the tests and displays the test result.

  • Tested on Ruby 1.8.7 & 1.9.2.

Install

Please be sure to have Guard installed before continue.

Add guard definition to your Guardfile by running this command:

guard init phantomjs

Jasmine runner:

if (phantom.state.length === 0) {
    if (phantom.args.length !== 1) {
        console.log('Usage: run-jasmine.js URL');
        phantom.exit();
    } else {
        phantom.state = 'run-jasmine';
        phantom.open(phantom.args[0]);
    }
} else {
    window.setInterval(function () {
        if (document.body.querySelector('.finished-at')) {
            console.log(document.body.querySelector('.description').innerText);
            var failed = document.body.querySelectorAll('div.jasmine_reporter .spec.failed .description');
            for (var i = 0, desc; desc = failed[i]; i++) {
                var message = [desc.title, desc.nextSibling.querySelector('.resultMessage.fail').innerText];
                console.log(message.join(' => '));
            }
            phantom.exit();
        }
    }, 100);
}

Save runner and pass its location to the guard as :runner option, see Options below.

Usage

Please read Guard usage doc

Options

The location of the test runner:

guard 'phantomjs', :runner => '...' do
  ...
end

The url of the webserver hosting the test suite:

guard 'phantomjs', :server => '...' do
  ...
end

Development

Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make.

Authors

Klaus Hartl

Something went wrong with that request. Please try again.