Reorg. Added examples/ with html and ruby test runner examples

This commit is contained in:
ragaskar 2009-08-26 22:13:30 -07:00
parent ba5b4ab166
commit 7a446d53c0
8 changed files with 92 additions and 30 deletions

View File

@ -87,6 +87,7 @@ module Jasmine
mappings.each do |from, to|
config[from] = Rack::File.new(to)
end
p mappings
app = Rack::URLMap.new(config)

View File

@ -1,6 +1,6 @@
require 'spec'
require 'open-uri'
require File.dirname(__FILE__) + '/jasmine_runner'
require File.dirname(__FILE__) + '/../jasmine_runner'
describe Jasmine::SimpleServer do
before do

View File

@ -4,37 +4,14 @@
<head>
<title>Jasmine Test Runner</title>
</head>
<script type="text/javascript" src="jasmine.js"></script>
<script type="text/javascript" src="TrivialReporter.js"></script>
<script type="text/javascript" src="../../lib/jasmine-0.9.0.js"></script>
<script type="text/javascript" src="../../lib/TrivialReporter.js"></script>
<link rel="stylesheet" type="text/css" href="../../lib/jasmine.css">
<script type="text/javascript">
jasmine.include('example_suite.js', true);
</script>
<style type="text/css">
.spec {
margin: 5px;
}
.passed {
background-color: lightgreen;
}
.failed {
background-color: pink;
}
.resultMessage {
white-space: pre;
}
.stackTrace {
white-space: pre;
font-size: .8em;
margin-left: 10px;
}
</style>
<body>
<script type="text/javascript">

32
examples/ruby/Rakefile Normal file
View File

@ -0,0 +1,32 @@
namespace :test do
desc "Run continuous integration tests"
require "spec"
require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:ci) do |t|
t.spec_opts = ["--color", "--format", "specdoc"]
t.spec_files = ["spec/jasmine_spec.rb"]
end
end
desc "Run specs via server"
task :jasmine_server do
require File.expand_path(File.join(File.dirname(__FILE__), "../../contrib/ruby/jasmine_spec_builder"))
JASMINE_LIB = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
dir_mappings = {
"/spec" => 'spec',
"/lib" => JASMINE_LIB
}
includes = ['lib/' + File.basename(Dir.glob("#{JASMINE_LIB}/jasmine*.js").first),
'lib/json2.js',
'lib/TrivialReporter.js']
spec_files = Dir.glob("spec/**/*[Ss]pec.js")
puts "your tests are here:"
puts " http://localhost:8888/run.html"
Jasmine::SimpleServer.start(8888, includes + spec_files, dir_mappings)
end

View File

@ -0,0 +1,11 @@
describe('ExampleSuite', function () {
it('should have a passing test', function() {
expect(true).toEqual(true);
});
describe('Nested Describe', function () {
it('should also have a passing test', function () {
expect(true).toEqual(true);
});
});
});

View File

@ -0,0 +1,30 @@
require 'rubygems'
require File.expand_path(File.join(File.dirname(__FILE__), "../../../contrib/ruby/jasmine_spec_builder"))
require "selenium_rc"
JASMINE_LIB = File.expand_path(File.join(File.dirname(__FILE__), '../../../lib'))
dir_mappings = {
"/spec" => 'spec',
"/lib" => JASMINE_LIB
}
includes = ['lib/' + File.basename(Dir.glob("#{JASMINE_LIB}/jasmine*.js").first),
'lib/json2.js',
'lib/TrivialReporter.js']
spec_files = Dir.glob("spec/**/*[Ss]pec.js")
jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path, includes + spec_files, dir_mappings)
spec_builder = Jasmine::SpecBuilder.new(spec_files, jasmine_runner)
should_stop = false
Spec::Runner.configure do |config|
config.after(:suite) do
spec_builder.stop if should_stop
end
end
spec_builder.start
should_stop = true
spec_builder.declare_suites

View File

@ -119,7 +119,10 @@ describe('RunnerTest', function() {
env.currentRunner.execute();
expect(fakeReporter.reportRunnerResults).wasNotCalled();
fakeTimer.tick(200);
expect(fakeReporter.reportRunnerResults).wasCalledWith(env.currentRunner);
//This blows up the JSApiReporter.
//expect(fakeReporter.reportRunnerResults).wasCalledWith(env.currentRunner);
expect(fakeReporter.reportRunnerResults).wasCalled();
expect(fakeReporter.reportRunnerResults.mostRecentCall.args[0].getResults()).toEqual(env.currentRunner.getResults());
});
@ -131,9 +134,13 @@ describe('RunnerTest', function() {
var runner = new jasmine.Runner(env);
runner.arbitraryVariable = 'foo';
spyOn(runner.queue, 'start');
expect(fakeReporter.reportRunnerStarting).wasNotCalled();
runner.execute();
expect(fakeReporter.reportRunnerStarting).wasCalledWith(runner);
expect(fakeReporter.reportRunnerStarting).wasCalled();
var reportedRunner = fakeReporter.reportRunnerStarting.mostRecentCall.args[0];
expect(reportedRunner.arbitraryVariable).toEqual('foo');
expect(runner.queue.start).wasCalled();
});
@ -147,7 +154,11 @@ describe('RunnerTest', function() {
document.runner = env.currentRunner;
var suites = env.currentRunner.getAllSuites();
expect(suites).toEqual([suite1, suite2]);
var suiteDescriptions = [];
for (var i = 0; i < suites.length; i++) {
suiteDescriptions.push(suites[i].getFullName());
}
expect(suiteDescriptions).toEqual([suite1.getFullName(), suite2.getFullName()]);
});
});