Skip to content
This repository has been archived by the owner on Jan 3, 2020. It is now read-only.

Commit

Permalink
Get everything working for Travis-CI
Browse files Browse the repository at this point in the history
This is a big step. It's undoing a lot of the work that was done to
remove the dependency on the jasmine gem. However, due to the way that
Travis-CI works, it's far easier to utilise jasmine:ci than it is to
manually invoke things.
  • Loading branch information
KushalP committed Mar 28, 2012
1 parent f6dd642 commit 4a506c9
Show file tree
Hide file tree
Showing 22 changed files with 128 additions and 56 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -2,5 +2,6 @@ source :gemcutter
source :rubygems

gem "coffee-script"
gem "jasmine"
gem "json"
gem "sinatra"
29 changes: 27 additions & 2 deletions Gemfile.lock
Expand Up @@ -2,17 +2,41 @@ GEM
remote: http://rubygems.org/
remote: http://rubygems.org/
specs:
childprocess (0.3.1)
ffi (~> 1.0.6)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.2.0)
diff-lcs (1.1.3)
execjs (1.3.0)
multi_json (~> 1.0)
json (1.6.5)
multi_json (1.1.0)
ffi (1.0.11)
jasmine (1.1.2)
jasmine-core (>= 1.1.0)
rack (>= 1.1)
rspec (>= 1.3.1)
selenium-webdriver (>= 0.1.3)
jasmine-core (1.1.0)
json (1.6.6)
multi_json (1.2.0)
rack (1.4.1)
rack-protection (1.2.0)
rack
rspec (2.9.0)
rspec-core (~> 2.9.0)
rspec-expectations (~> 2.9.0)
rspec-mocks (~> 2.9.0)
rspec-core (2.9.0)
rspec-expectations (2.9.0)
diff-lcs (~> 1.1.3)
rspec-mocks (2.9.0)
rubyzip (0.9.6.1)
selenium-webdriver (2.20.0)
childprocess (>= 0.2.5)
ffi (~> 1.0)
multi_json (~> 1.0)
rubyzip
sinatra (1.3.2)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
Expand All @@ -24,5 +48,6 @@ PLATFORMS

DEPENDENCIES
coffee-script
jasmine
json
sinatra
27 changes: 14 additions & 13 deletions Rakefile
Expand Up @@ -99,18 +99,19 @@ task :midas do
end
end

task :jasmine => [:jslibs, :coffeescript] do
css_files = Dir['lib/jasmine-1.0.1/jasmine.css']
jasmine_files = ['jasmine.js','jasmine-html.js'].map { |f|
"lib/jasmine-1.0.1/" + f
}
Dir['lib/jasmine-reporters/*.js'].each { |f| jasmine_files << f }

js_files = YAML::load(File.read("spec/javascripts/support/jasmine.yml"))['src_files'].map {|f| 'public/' + f }

spec_files = Dir['spec/javascripts/*.js']
template = ERB.new(File.read('spec/SpecRunner.html.erb')).result(binding)
File.open('SpecRunner.html', 'w+') { |f| f << template }
begin
require 'jasmine'
load 'jasmine/tasks/jasmine.rake'
rescue LoadError
task :jasmine do
abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
end
end

#`open SpecRunner.html`
task :travis do
["rake jslibs coffeescript jasmine:ci"].each do |cmd|
puts "Starting to run #{cmd}..."
system("export DISPLAY=:99.0 && bundle exec #{cmd}")
raise "#{cmd} failed!" unless $?.exitstatus == 0
end
end
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
1 change: 0 additions & 1 deletion public/assets/js/events.coffee
Expand Up @@ -63,7 +63,6 @@ $(document).ready ->
buildMonitor = new BuildMonitorController
projects = new ProjectController

$.facebox.settings.loadingImage = "/assets/images/loading.gif"
$("a[rel*=facebox]").facebox()
queryString = $.query
docButton = $("#doc-button")
Expand Down
20 changes: 4 additions & 16 deletions spec/javascripts/buildMonitorSpec.js
Expand Up @@ -18,17 +18,10 @@
describe('build monitor', function () {
var buildMonitorController;

var fixtures_dir = 'spec/assets/fixtures/';

beforeEach(function () {
var baseDir;
if (window.location.protocol.match(/file:/)) {
baseDir = window.location.pathname.replace('SpecRunner.html',
'');
} else {
baseDir = '';
}
var assetDir = baseDir + 'spec/assets/fixtures';
loadFixtures(assetDir + '/status-bar-initial.html',
assetDir + '/builds.html');

buildMonitorController = new BuildMonitorController();
});

Expand All @@ -38,10 +31,10 @@ describe('build monitor', function () {
BuildMonitor.failCount = 1;

var quantised = BuildMonitor.quantise();
$("#status-bar").replaceWith(buildMonitorController.renderStatusBar());
expect(quantised.green).toEqual(5);
expect(quantised.red).toEqual(5);
expect(quantised.grey).toEqual(0);

});

it('should have 1 green divs and 9 red divs if 1 build is green and 9 are red', function () {
Expand All @@ -50,7 +43,6 @@ describe('build monitor', function () {
BuildMonitor.failCount = 9;

var quantised = BuildMonitor.quantise();
$("#status-bar").replaceWith(buildMonitorController.renderStatusBar());
expect(quantised.green).toEqual(1);
expect(quantised.red).toEqual(9);
expect(quantised.grey).toEqual(0);
Expand All @@ -62,7 +54,6 @@ describe('build monitor', function () {
BuildMonitor.failCount = 9;

var quantised = BuildMonitor.quantise();
$("#status-bar").replaceWith(buildMonitorController.renderStatusBar());
expect(quantised.green).toEqual(2);
expect(quantised.red).toEqual(8);
expect(quantised.grey).toEqual(0);
Expand All @@ -74,7 +65,6 @@ describe('build monitor', function () {
BuildMonitor.failCount = 10;

var quantised = BuildMonitor.quantise();
$("#status-bar").replaceWith(buildMonitorController.renderStatusBar());
expect(quantised.green).toEqual(2);
expect(quantised.red).toEqual(8);
expect(quantised.grey).toEqual(0);
Expand All @@ -86,7 +76,6 @@ describe('build monitor', function () {
BuildMonitor.failCount = 9;

var quantised = BuildMonitor.quantise();
$("#status-bar").replaceWith(buildMonitorController.renderStatusBar());
expect(quantised.green).toEqual(2);
expect(quantised.red).toEqual(8);
expect(quantised.grey).toEqual(0);
Expand All @@ -98,7 +87,6 @@ describe('build monitor', function () {
BuildMonitor.failCount = 10;

var quantised = BuildMonitor.quantise();
$("#status-bar").replaceWith(buildMonitorController.renderStatusBar());
expect(quantised.green).toEqual(1);
expect(quantised.red).toEqual(9);
expect(quantised.grey).toEqual(0);
Expand Down
8 changes: 4 additions & 4 deletions spec/javascripts/cctrayUrlSpec.js
Expand Up @@ -25,22 +25,22 @@ describe('cctray', function () {
});

it('should have a default url', function() {
expect(CCTray.url(config)).toEqual('http://localhost:6969/localhost:/hudson?jsonp=?');
expect(CCTray.url(config)).toEqual('http://localhost:6969/localhost:8888/hudson?jsonp=?');
});

it('should have a url with a different context root if you tell it', function() {
config.context="/harry";
expect(CCTray.url(config)).toEqual('http://localhost:6969/localhost:/harry?jsonp=?');
expect(CCTray.url(config)).toEqual('http://localhost:6969/localhost:8888/harry?jsonp=?');
});

it('should cope with chrome passing a trailing hash on the context', function() {
config.context="/ci#";
expect(CCTray.url(config)).toEqual('http://localhost:6969/localhost:/ci?jsonp=?');
expect(CCTray.url(config)).toEqual('http://localhost:6969/localhost:8888/ci?jsonp=?');
});

it('should cope with chrome passing escaped paths hash on the context', function() {
config.context="%2Fhudson";
expect(CCTray.url(config)).toEqual('http://localhost:6969/localhost:/hudson?jsonp=?');
expect(CCTray.url(config)).toEqual('http://localhost:6969/localhost:8888/hudson?jsonp=?');
});

it('should have a url with a different port root if you tell it', function() {
Expand Down
3 changes: 2 additions & 1 deletion spec/javascripts/helpers/SpecHelper.js
@@ -1 +1,2 @@
//You may load required files here, or create test-runner-wide environment settings.
//You may load required files here, or create test-runner-wide
//environment settings.
12 changes: 6 additions & 6 deletions spec/javascripts/hudsonUrlSpec.js
Expand Up @@ -23,22 +23,22 @@ describe('hudson', function () {
});

it('should have a default url that hits our hudson dummy', function() {
expect(Hudson.url(config)).toEqual('http://localhost:/hudson/api/json?jsonp=?');
expect(Hudson.url(config)).toEqual('http://localhost:8888/hudson/api/json?jsonp=?');
});

it('should have a url with a different context root if you tell it', function() {
CONFIG.context="/harry";
expect(Hudson.url(config)).toEqual('http://localhost:/harry/api/json?jsonp=?');
expect(Hudson.url(config)).toEqual('http://localhost:8888/harry/api/json?jsonp=?');
});

it('should cope with chrome passing a trailing hash on the context', function() {
CONFIG.context="/ci#";
expect(Hudson.url(config)).toEqual('http://localhost:/ci/api/json?jsonp=?');
expect(Hudson.url(config)).toEqual('http://localhost:8888/ci/api/json?jsonp=?');
});

it('should cope with chrome passing escaped paths hash on the context', function() {
CONFIG.context="%2Fhudson";
expect(Hudson.url(config)).toEqual('http://localhost:/hudson/api/json?jsonp=?');
expect(Hudson.url(config)).toEqual('http://localhost:8888/hudson/api/json?jsonp=?');
});

it('should have a url with a different port root if you tell it', function() {
Expand All @@ -49,13 +49,13 @@ describe('hudson', function () {
it('should have a url with a different host if you tell it', function() {
CONFIG.host="harry";
CONFIG.context="/"
expect(Hudson.url(config)).toEqual('http://harry:/api/json?jsonp=?');
expect(Hudson.url(config)).toEqual('http://harry:8888/api/json?jsonp=?');
});

it('should put the username and password in the url if you give it', function() {
CONFIG.username="harpo";
CONFIG.password="swordfish";
expect(Hudson.url(config)).toEqual('http://harpo:swordfish@localhost:/hudson/api/json?jsonp=?');
expect(Hudson.url(config)).toEqual('http://harpo:swordfish@localhost:8888/hudson/api/json?jsonp=?');
});

});
6 changes: 5 additions & 1 deletion spec/javascripts/projectControllerSpec.js
Expand Up @@ -21,7 +21,11 @@ describe('Project Controller', function () {

beforeEach(function () {
project = new ProjectController();
$("<div id=\"container\"><ul id=\"projects\"></ul></div>").appendTo("body");

if ($("div#container ul#projects").length === 0) {
$("<div id=\"container\"><ul id=\"projects\"></ul></div>").appendTo("body");
}

container = $("div#container ul#projects");
});

Expand Down
2 changes: 1 addition & 1 deletion spec/javascripts/radiateSpec.js
Expand Up @@ -55,7 +55,7 @@ describe('CONFIG', function () {
expect(CONFIG.selectEngine('hudson').name).toEqual('hudson');
expect(CONFIG.selectEngine('hudson').defaultUri).toEqual('/hudson');
expect(CONFIG.selectEngine('hudson').defaultHost).toEqual('localhost');
expect(CONFIG.selectEngine('hudson').defaultPort).toEqual("");
expect(CONFIG.selectEngine('hudson').defaultPort).toEqual("8888");
});

/*
Expand Down
20 changes: 9 additions & 11 deletions spec/javascripts/support/jasmine.yml
Expand Up @@ -14,19 +14,17 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
src_files:
- ../target/assets/js/xfd-libs.js
- assets/js/resources/jasmine-jquery.js
- assets/js/resources/ejs_0.9_alpha_1_production.js
- ../target/assets/js/xfd.js
- target/assets/js/xfd-libs.js
- public/assets/js/resources/jasmine-jquery.js
- public/assets/js/resources/ejs_0.9_alpha_1_production.js
- target/assets/js/xfd.js

stylesheets:
- assets/css/main.css
- assets/css/builds.css
#stylesheets:

helpers:
#helpers:

spec_files:
#spec_files:

src_dir: public
#src_dir:

spec_dir:
#spec_dir:
23 changes: 23 additions & 0 deletions spec/javascripts/support/jasmine_config.rb
@@ -0,0 +1,23 @@
module Jasmine
class Config

# Add your overrides or custom config code here

end
end


# Note - this is necessary for rspec2, which has removed the backtrace
module Jasmine
class SpecBuilder
def declare_spec(parent, spec)
me = self
example_name = spec["name"]
@spec_ids << spec["id"]
backtrace = @example_locations[parent.description + " " + example_name]
parent.it example_name, {} do
me.report_spec(spec["id"])
end
end
end
end
32 changes: 32 additions & 0 deletions spec/javascripts/support/jasmine_runner.rb
@@ -0,0 +1,32 @@
$:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes

require 'rubygems'
require 'jasmine'
jasmine_config_overrides = File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config.rb'))
require jasmine_config_overrides if File.exist?(jasmine_config_overrides)
if Jasmine::Dependencies.rspec2?
require 'rspec'
else
require 'spec'
end

jasmine_config = Jasmine::Config.new
spec_builder = Jasmine::SpecBuilder.new(jasmine_config)

should_stop = false

if Jasmine::Dependencies.rspec2?
RSpec.configuration.after(:suite) do
spec_builder.stop if should_stop
end
else
Spec::Runner.configure do |config|
config.after(:suite) do
spec_builder.stop if should_stop
end
end
end

spec_builder.start
should_stop = true
spec_builder.declare_suites

0 comments on commit 4a506c9

Please sign in to comment.