Permalink
Browse files

Switch to Sprockets for asset serving.

  • Loading branch information...
1 parent 86d0562 commit f1e11d406dd4e3c2a46f87692e7e6bd44e7dc29a @airhorns committed Dec 8, 2011
View
@@ -3,4 +3,3 @@ source :gemcutter
gemspec
gem 'pry'
-gem 'sprockets'
View
@@ -2,6 +2,7 @@
require 'sinatra/base'
require 'capybara'
require 'launchy'
+require 'coffee-script'
require 'everblue/version'
require 'everblue/application'
require 'json'
@@ -31,6 +32,36 @@ def use_defaults!
config.mounted_at = ""
end
end
+
+ def test_dir=(new_dir)
+ update_asset_paths(new_dir, test_dir)
+ @test_dir = new_dir
+ end
+
+ def public_dir=(new_dir)
+ update_asset_paths(new_dir, public_dir)
+ @public_dir = new_dir
+ end
+
+ def root=(new_root)
+ @root = new_root
+ update_asset_paths(test_dir, test_dir)
+ update_asset_paths(public_dir, public_dir)
+ @root
+ end
+
+ private
+
+ def update_asset_paths(new_dir, old_dir)
+ return if root.nil?
+ old_dir = File.expand_path(old_dir, root)
+ new_dir = File.expand_path(new_dir, root)
+ old_paths = Everblue::AssetsEnvironment.clear_paths
+ old_paths.delete(old_dir)
+ old_paths.unshift(new_dir).each do |dir|
+ Everblue::AssetsEnvironment.append_path(dir)
+ end
+ end
end
end
@@ -1,46 +1,48 @@
+require 'sprockets'
+
module Everblue
- class Application < Sinatra::Base
+ class TestApplication < Sinatra::Base
+
set :static, false
set :root, File.expand_path('.', File.dirname(__FILE__))
helpers do
def url(path)
Everblue.mounted_at.to_s + path.to_s
end
-
- def render_test(test)
- test.read if test
- rescue StandardError => error
- erb :_test_error, :locals => { :error => error }
- end
end
get '/' do
+ Everblue.root = "/Users/hornairs/Code/everblue/spec/suite1"
@suite = Everblue::Suite.new
erb :list
end
get '/run/all' do
@suite = Everblue::Suite.new
- @js_test_helper = @suite.get_test('test_helper.js')
- @coffee_test_helper = @suite.get_test('test_helper.coffee')
erb :run
end
get '/run/*' do |name|
@suite = Everblue::Suite.new
@test = @suite.get_test(name)
- @js_test_helper = @suite.get_test('test_helper.js')
- @coffee_test_helper = @suite.get_test('test_helper.coffee')
erb :run
end
+ end
+
+ AssetsEnvironment = Sprockets::Environment.new
+ assets_path = File.expand_path(File.join(File.dirname(__FILE__), 'assets'))
+ AssetsEnvironment.append_path assets_path
+ qunit_assets_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'qunit', 'qunit'))
+ AssetsEnvironment.append_path qunit_assets_path
- get "/resources/*" do |path|
- send_file File.expand_path(File.join('resources', path), File.dirname(__FILE__))
+ Application = Rack::Builder.app do
+ map '/assets' do
+ run AssetsEnvironment
end
- get '/*' do |path|
- send_file File.join(Everblue.root, Everblue.public_dir, path)
+ map '/' do
+ run TestApplication
end
end
end
File renamed without changes
@@ -1,18 +1,17 @@
body {
- font-family: 'Lucida grande', 'sans-serif';
+ font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
background: #f0f0f0;
}
a {
- color: #4DA524;
+ color: #2A24A5;
}
#page, #test, .jasmine_reporter {
- width: 800px;
background: white;
-moz-border-radius: 3px;
padding: 20px;
- margin: 50px auto 30px;
+ margin: 10px auto 30px;
border: 1px solid #ddd;
box-shadow: 0 1px 3px 1px rgba(0,0,0,0.05)
}
@@ -32,7 +31,6 @@ a {
font-size: 24px;
margin: 0 0 15px;
border-bottom: 3px solid #AEAEAE;
- text-transform: uppercase;
padding-bottom: 4px;
}
@@ -76,7 +74,7 @@ a {
}
#page ul li a:first-child:hover, #page #all a:first-child:hover {
- background: #4DA524;
+ background: #242DA5;
color: #fff;
text-decoration: none;
border-radius: 3px;
@@ -170,3 +168,203 @@ text-shadow: 0px 0px 4px rgba(255,255,255,0.3)
#footer a.elabs:hover img {
opacity: 1;
}
+
+/**
+ * QUnit v1.3.0pre - A JavaScript Unit Testing Framework
+ *
+ * http://docs.jquery.com/QUnit
+ *
+ * Copyright (c) 2011 John Resig, Jörn Zaefferer
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * or GPL (GPL-LICENSE.txt) licenses.
+ */
+
+/** Font Family and Sizes */
+
+
+#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
+#qunit-tests { font-size: smaller; }
+
+
+/** Resets */
+
+#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
+ margin: 0;
+ padding: 0;
+}
+
+
+#qunit-header a:hover,
+#qunit-header a:focus {
+ color: #fff;
+}
+
+#qunit-testrunner-toolbar {
+ padding: 0.5em 0 0.5em 2em;
+ color: #5E740B;
+}
+
+#qunit-userAgent {
+ padding: 0.5em 0 0.5em 2.5em;
+ color: #366097;
+ border-bottom: 1px solid #fff;
+}
+
+
+/** Tests: Pass/Fail */
+
+#qunit-tests {
+ list-style-position: inside;
+}
+
+#qunit-tests li {
+ padding: 0.4em 0.5em 0.4em 2.5em;
+ border-bottom: 1px solid #fff;
+ list-style-position: inside;
+}
+
+#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
+ display: none;
+}
+
+#qunit-tests li strong {
+ cursor: pointer;
+}
+
+#qunit-tests li a {
+ padding: 0.5em;
+ color: #c2ccd1;
+ text-decoration: none;
+}
+#qunit-tests li a:hover,
+#qunit-tests li a:focus {
+ color: #000;
+}
+
+#qunit-tests ol {
+ margin-top: 0.5em;
+ padding: 0.5em;
+
+ background-color: #fff;
+
+ border-radius: 5px;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+
+ box-shadow: inset 0px 2px 3px #999;
+ -moz-box-shadow: inset 0px 2px 3px #999;
+ -webkit-box-shadow: inset 0px 2px 3px #999;
+}
+
+#qunit-tests table {
+ border-collapse: collapse;
+ margin-top: .2em;
+}
+
+#qunit-tests th {
+ text-align: right;
+ vertical-align: top;
+ padding: 0 .5em 0 0;
+}
+
+#qunit-tests td {
+ vertical-align: top;
+}
+
+#qunit-tests pre {
+ margin: 0;
+ white-space: pre-wrap;
+ word-wrap: break-word;
+}
+
+#qunit-tests del {
+ background-color: #e0f2be;
+ color: #374e0c;
+ text-decoration: none;
+}
+
+#qunit-tests ins {
+ background-color: #ffcaca;
+ color: #500;
+ text-decoration: none;
+}
+
+/*** Test Counts */
+
+#qunit-tests b.counts { color: black; }
+#qunit-tests b.passed { color: #5E740B; }
+#qunit-tests b.failed { color: #710909; }
+
+#qunit-tests li li {
+ margin: 0.5em;
+ padding: 0.4em 0.5em 0.4em 0.5em;
+ background-color: #fff;
+ border-bottom: none;
+ list-style-position: inside;
+}
+
+/*** Passing Styles */
+
+#qunit-tests li li.pass {
+ color: #5E740B;
+ background-color: #fff;
+ border-left: 26px solid #C6E746;
+}
+
+#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
+#qunit-tests .pass .test-name { color: #366097; }
+
+#qunit-tests .pass .test-actual,
+#qunit-tests .pass .test-expected { color: #999999; }
+
+#qunit-banner.qunit-pass { background-color: #C6E746; }
+
+/*** Failing Styles */
+
+#qunit-tests li li.fail {
+ color: #710909;
+ background-color: #fff;
+ border-left: 26px solid #EE5757;
+ white-space: pre;
+}
+
+#qunit-tests > li:last-child {
+ border-radius: 0 0 15px 15px;
+ -moz-border-radius: 0 0 15px 15px;
+ -webkit-border-bottom-right-radius: 15px;
+ -webkit-border-bottom-left-radius: 15px;
+}
+
+#qunit-tests .fail { color: #000000; background-color: #EE5757; }
+#qunit-tests .fail .test-name,
+#qunit-tests .fail .module-name { color: #000000; }
+
+#qunit-tests .fail .test-actual { color: #EE5757; }
+#qunit-tests .fail .test-expected { color: green; }
+
+#qunit-banner.qunit-fail { background-color: #EE5757; }
+
+
+/** Result */
+
+#qunit-testresult {
+ padding: 0.5em 0.5em 0.5em 2.5em;
+
+ color: #2b81af;
+ background-color: #D2E0E6;
+
+ border-bottom: 1px solid white;
+ border-radius: 15px 15px 0 0;
+ -moz-border-radius: 15px 15px 0 0;
+ -webkit-border-top-right-radius: 15px;
+ -webkit-border-top-left-radius: 15px;
+
+}
+
+/** Fixture */
+
+#qunit-fixture {
+ position: absolute;
+ top: -10000px;
+ left: -10000px;
+}
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,13 @@
+//= require jquery
+//= require qunit
+//= require_self
+//= require test_helper
+
if(!this.JSON){this.JSON={};}
var Everblue = {};
+Everblue.driver = <%= Everblue.driver.to_json %>;
Everblue.dots = ""
Everblue.ReflectiveReporter = function() {
@@ -25,8 +31,8 @@ Everblue.ReflectiveReporter = function() {
};
};
-Everblue.templates = {};
-
Everblue.getResults = function() {
return JSON.stringify(Everblue.results);
};
+
+QUnit.config.autorun = false;
@@ -0,0 +1,11 @@
+(function() {
+ var run = function() {
+ QUnit.start();
+ };
+ if (window.addEventListener) {
+ window.addEventListener("load", run, false);
+ }
+ else {
+ window.attachEvent("onload", run);
+ }
+})();
@@ -0,0 +1,3 @@
+// This is a dummy test helper which sprockets will find if you don't provide one to find first in your test dir.
+window.defaultTestHelper = true;
+console.warn("Warning: no test helper found!");
Oops, something went wrong.

0 comments on commit f1e11d4

Please sign in to comment.