-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests the ability of roots to * make a new project * watch said project * reload the brower with changes to said project
- Loading branch information
Showing
4 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Feature: Live reloading of the browser | ||
|
||
Background: | ||
Given I have a roots project | ||
And I am watching it | ||
|
||
Scenario: Reloading on file change | ||
When I replace "views/index.jade" with "<h1><span>wow such magic</span></h1>" | ||
Then I should a "h1" tag with "wow such magic" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
fs = require("fs") | ||
Path = require("path") | ||
rootPath = Path.resolve(__dirname, 'rage') | ||
|
||
module.exports = -> | ||
@When /^I replace "([^"]*)" with "([^"]*)"$/, (filePath, content) -> | ||
fs.writeFileSync(Path.join(rootPath, filePath), content) | ||
|
||
@Then /^I should a "([^"]*)" tag with "([^"]*)"$/, (tag, content) -> | ||
new @Widget({root: tag}).read("span").should.eventually.eql(content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Roots = require("../../") | ||
When = require("when") | ||
path = require("path").resolve(__dirname, 'rage') | ||
rimraf = require("rimraf") | ||
Server = require("../../lib/local_server") | ||
|
||
on_error = (cli, server, err) -> server.show_error(Error(err).stack) | ||
on_start = (cli, server) -> server.compiling() | ||
on_done = (cli, server) -> server.reload() | ||
|
||
module.exports = -> | ||
@After -> | ||
When.Promise (resolve) -> | ||
rimraf path, -> | ||
console.log arguments | ||
resolve() | ||
|
||
@Given /^I have a roots project$/, -> | ||
Roots.new( | ||
path: path | ||
overrides: | ||
name: "doge-hunter" | ||
description: "data love geordi" | ||
) | ||
|
||
@Given /^I am watching it$/, -> | ||
_this = this | ||
|
||
When.Promise (resolve) -> | ||
project = new Roots(path) | ||
server = new Server(project, project.root) | ||
watcher = project.watch() | ||
cli = {} | ||
|
||
server.start(1111) | ||
|
||
watcher.on('start', on_start.bind(null, cli, server)) | ||
watcher.on('error', on_error.bind(null, cli, server)) | ||
watcher.on('done', on_done.bind(null, cli, server)) | ||
|
||
watcher.once 'done', -> | ||
_this.driver.get("http://127.0.0.1:1111/").then -> resolve() |