jasmine 1.0.1.1 → 1.0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/.gitmodules +3 -0
- data/Gemfile +5 -0
- data/HOW_TO_TEST.markdown +11 -0
- data/README.markdown +42 -14
- data/RELEASE.markdown +22 -0
- data/Rakefile +76 -0
- data/generators/jasmine/jasmine_generator.rb +15 -13
- data/generators/jasmine/templates/spec/javascripts/support/jasmine_config.rb +23 -0
- data/install.rb +2 -0
- data/jasmine.gemspec +52 -0
- data/jasmine/Gemfile +6 -0
- data/jasmine/MIT.LICENSE +20 -0
- data/jasmine/README.markdown +28 -0
- data/jasmine/Rakefile +182 -0
- data/jasmine/cruise_config.rb +21 -0
- data/jasmine/example/spec/PlayerSpec.js +58 -0
- data/jasmine/example/spec/SpecHelper.js +9 -0
- data/jasmine/example/src/Player.js +22 -0
- data/jasmine/example/src/Song.js +7 -0
- data/jasmine/images/fail-16.png +0 -0
- data/jasmine/images/fail.png +0 -0
- data/jasmine/images/go-16.png +0 -0
- data/jasmine/images/go.png +0 -0
- data/jasmine/images/pending-16.png +0 -0
- data/jasmine/images/pending.png +0 -0
- data/jasmine/images/question-bk.png +0 -0
- data/jasmine/images/questionbk-16.png +0 -0
- data/jasmine/images/spinner.gif +0 -0
- data/jasmine/jsdoc-template/allclasses.tmpl +17 -0
- data/jasmine/jsdoc-template/allfiles.tmpl +56 -0
- data/jasmine/jsdoc-template/class.tmpl +646 -0
- data/jasmine/jsdoc-template/index.tmpl +39 -0
- data/jasmine/jsdoc-template/publish.js +184 -0
- data/jasmine/jsdoc-template/static/default.css +162 -0
- data/jasmine/jsdoc-template/static/header.html +2 -0
- data/jasmine/jsdoc-template/static/index.html +19 -0
- data/jasmine/jsdoc-template/symbol.tmpl +35 -0
- data/jasmine/spec/runner.html +80 -0
- data/jasmine/spec/suites/BaseSpec.js +27 -0
- data/jasmine/spec/suites/CustomMatchersSpec.js +97 -0
- data/jasmine/spec/suites/EnvSpec.js +158 -0
- data/jasmine/spec/suites/ExceptionsSpec.js +107 -0
- data/jasmine/spec/suites/JsApiReporterSpec.js +103 -0
- data/jasmine/spec/suites/MatchersSpec.js +795 -0
- data/jasmine/spec/suites/MockClockSpec.js +38 -0
- data/jasmine/spec/suites/MultiReporterSpec.js +45 -0
- data/jasmine/spec/suites/NestedResultsSpec.js +54 -0
- data/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
- data/jasmine/spec/suites/QueueSpec.js +23 -0
- data/jasmine/spec/suites/ReporterSpec.js +56 -0
- data/jasmine/spec/suites/RunnerSpec.js +267 -0
- data/jasmine/spec/suites/SpecRunningSpec.js +1253 -0
- data/jasmine/spec/suites/SpecSpec.js +124 -0
- data/jasmine/spec/suites/SpySpec.js +201 -0
- data/jasmine/spec/suites/SuiteSpec.js +120 -0
- data/jasmine/spec/suites/TrivialReporterSpec.js +238 -0
- data/jasmine/spec/suites/UtilSpec.js +40 -0
- data/jasmine/spec/suites/WaitsForBlockSpec.js +87 -0
- data/jasmine/src/Block.js +22 -0
- data/jasmine/src/Env.js +264 -0
- data/jasmine/src/JsApiReporter.js +102 -0
- data/jasmine/src/Matchers.js +354 -0
- data/jasmine/src/MultiReporter.js +35 -0
- data/jasmine/src/NestedResults.js +80 -0
- data/jasmine/src/PrettyPrinter.js +122 -0
- data/jasmine/src/Queue.js +99 -0
- data/jasmine/src/Reporter.js +31 -0
- data/jasmine/src/Runner.js +77 -0
- data/jasmine/src/Spec.js +242 -0
- data/jasmine/src/Suite.js +82 -0
- data/jasmine/src/WaitsBlock.js +13 -0
- data/jasmine/src/WaitsForBlock.js +52 -0
- data/jasmine/src/base.js +589 -0
- data/jasmine/src/html/TrivialReporter.js +188 -0
- data/jasmine/src/html/jasmine.css +166 -0
- data/jasmine/src/mock-timeout.js +183 -0
- data/jasmine/src/util.js +67 -0
- data/jasmine/src/version.json +5 -0
- data/lib/generators/jasmine/examples/USAGE +11 -0
- data/lib/generators/jasmine/examples/examples_generator.rb +19 -0
- data/lib/generators/jasmine/examples/templates/public/javascripts/jasmine_examples/Player.js +22 -0
- data/lib/generators/jasmine/examples/templates/public/javascripts/jasmine_examples/Song.js +7 -0
- data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +9 -0
- data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +58 -0
- data/lib/generators/jasmine/install/USAGE +11 -0
- data/lib/generators/jasmine/install/install_generator.rb +18 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/helpers/.gitkeep +0 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +81 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_config.rb +23 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_runner.rb +20 -0
- data/lib/generators/jasmine/jasmine_generator.rb +32 -0
- data/lib/generators/jasmine/templates/INSTALL +9 -0
- data/lib/generators/jasmine/templates/lib/tasks/jasmine.rake +2 -0
- data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
- data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +73 -0
- data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine_config.rb +23 -0
- data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/lib/jasmine.rb +31 -6
- data/lib/jasmine/command_line_tool.rb +1 -0
- data/lib/jasmine/config.rb +16 -44
- data/lib/jasmine/generator.rb +9 -0
- data/lib/jasmine/selenium_driver.rb +18 -18
- data/lib/jasmine/server.rb +0 -24
- data/lib/jasmine/spec_builder.rb +4 -4
- data/lib/jasmine/tasks/jasmine.rake +2 -2
- data/lib/jasmine/version.rb +3 -0
- data/spec/config_spec.rb +174 -123
- data/spec/fixture/jasmine.erb.yml +4 -0
- data/spec/jasmine_pojs_spec.rb +51 -0
- data/spec/jasmine_rails2_spec.rb +93 -0
- data/spec/jasmine_rails3_spec.rb +71 -0
- data/spec/spec_helper.rb +8 -2
- metadata +215 -65
- data/spec/bug_fixes_spec.rb +0 -32
- data/spec/rails_generator_spec.rb +0 -31
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
At the moment we don't have an automated way to test the Jasmine Gem in both configurations: Rails 2 / RSpec 1.x & Rails 3 / RSpec 2. CI will handle a broad matrix, but you need to ensure that your changes work across Rails 2&3.
|
2
|
+
|
3
|
+
So here are the manual steps:
|
4
|
+
|
5
|
+
* Edit jasmine.gemspec and uncomment the lines for Rails 2, comment out the lines for Rails 3
|
6
|
+
* Delete `Gemfile.lock`
|
7
|
+
* exec a `bundle install`
|
8
|
+
* `rake` until specs are green
|
9
|
+
* Repeat with the Rails 3 development gems
|
10
|
+
* Repeat again with the Rails 2 development gems
|
11
|
+
* Check in
|
data/README.markdown
CHANGED
@@ -1,13 +1,19 @@
|
|
1
|
-
|
2
|
-
============
|
1
|
+
# The Jasmine Gem
|
3
2
|
|
4
|
-
|
3
|
+
The [Jasmine](http://github.com/pivotal/jasmine) Ruby Gem is a package of helper code for developing Jasmine projects for Ruby-based web projects (Rails, Sinatra, etc.) or for JavaScript projects where Ruby is a welcome partner. It serves up a project's Jasmine suite in a browser so you can focus on your code instead of manually editing script tags in the Jasmine runner HTML file.
|
5
4
|
|
6
|
-
|
5
|
+
## Contents
|
6
|
+
This gem contains:
|
7
7
|
|
8
|
-
|
8
|
+
* A small server that builds and executes a Jasmine suite for a project
|
9
|
+
* A script that sets up a project to use the Jasmine gem's server
|
10
|
+
* Generators for Ruby on Rails projects (Rails 2 and Rails 3)
|
9
11
|
|
10
|
-
|
12
|
+
You can get all of this by: `gem install jasmine` or by adding Jasmine to your `Gemfile`.
|
13
|
+
|
14
|
+
## Init A Project
|
15
|
+
|
16
|
+
To initialize a project for Jasmine, it depends on your web framework
|
11
17
|
|
12
18
|
For Rails2 support, use
|
13
19
|
|
@@ -15,29 +21,51 @@ For Rails2 support, use
|
|
15
21
|
|
16
22
|
For Rails3 support, use
|
17
23
|
|
18
|
-
`
|
24
|
+
`rails g jasmine:install`
|
25
|
+
`rails g jasmine:examples`
|
19
26
|
|
20
|
-
For other
|
27
|
+
For any other project (Sinatra, Merb, or something we don't yet know about) use
|
21
28
|
|
22
29
|
`jasmine init`
|
23
30
|
|
24
|
-
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
Start the Jasmine server:
|
25
34
|
|
26
35
|
`rake jasmine`
|
27
36
|
|
28
|
-
|
37
|
+
Point your browser to `localhost:8888`. The suite will run every time this page is re-loaded.
|
29
38
|
|
30
|
-
|
39
|
+
For Continuous Integration environments, add this task to the project build steps:
|
31
40
|
|
32
41
|
`rake jasmine:ci`
|
33
42
|
|
34
|
-
|
43
|
+
This uses Selenium to launch a browser and run the Jasmine suite. Then it uses RSpec to extract the results from the Jasmine reporter and write them to your build log.
|
35
44
|
|
36
|
-
|
45
|
+
## Configuration
|
37
46
|
|
38
47
|
Customize `spec/javascripts/support/jasmine.yml` to enumerate the source files, stylesheets, and spec files you would like the Jasmine runner to include.
|
39
48
|
You may use dir glob strings.
|
40
49
|
|
41
|
-
|
50
|
+
For more complex configuration (e.g., port number), edit `spec/javascripts/support/jasmine_config.rb` file directly.
|
51
|
+
|
52
|
+
## Note about the CI task and RSpec
|
53
|
+
|
54
|
+
This gem requires RSpec for the `jasmine:ci` rake task to work. But this gem does not explicitly *depend* on any version of the RSpec gem.
|
55
|
+
|
56
|
+
If you're writing a Rails application then as long as you've installed RSpec before you install Jasmine and attempt a `rake jasmine:ci`, then you will be fine.
|
57
|
+
|
58
|
+
If you're using another Ruby framework, or don't care about Ruby, then run
|
59
|
+
|
60
|
+
`gem install rspec`
|
61
|
+
|
62
|
+
before you attempt the CI task.
|
63
|
+
|
64
|
+
## Support
|
65
|
+
|
66
|
+
Jasmine Mailing list: [jasmine-js@googlegroups.com](mailto:jasmine-js@googlegroups.com)
|
67
|
+
Twitter: [@jasminebdd](http://twitter.com/jasminebdd)
|
68
|
+
|
69
|
+
Please file issues here at Github
|
42
70
|
|
43
71
|
Copyright (c) 2008-2010 Pivotal Labs. This software is licensed under the MIT License.
|
data/RELEASE.markdown
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Releasing Jasmine
|
2
|
+
|
3
|
+
Add release notes to gh-pages branch /release-notes.html.markdown
|
4
|
+
|
5
|
+
## Jasmine core
|
6
|
+
|
7
|
+
* update version.json with new version
|
8
|
+
* rake jasmine:dist
|
9
|
+
* add pages/downloads/*.zip
|
10
|
+
* commit, tag, and push both jasmine/pages and jasmine
|
11
|
+
* * git push
|
12
|
+
* * git tag -a x.x.x-release
|
13
|
+
* * git push --tags
|
14
|
+
|
15
|
+
## Jasmine Gem
|
16
|
+
|
17
|
+
* update version in version.rb
|
18
|
+
* for release candidates, add "rc" + number to the end of the appropriate version part,
|
19
|
+
e.g. we should have tagged the 1.0 RC's as 1.0.0rc1, not 1.0.0.rc1. Likewise 1.0.0.1rc1.
|
20
|
+
* rake jeweler:install and try stuff out
|
21
|
+
* * (jasmine init and script/generate jasmine)
|
22
|
+
* rake site
|
data/Rakefile
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/lib")
|
3
|
+
require "bundler"
|
4
|
+
Bundler.setup
|
5
|
+
|
6
|
+
def rspec2?
|
7
|
+
Gem.available? "rspec", ">= 2.0"
|
8
|
+
end
|
9
|
+
|
10
|
+
def rails3?
|
11
|
+
Gem.available? "rails", ">= 3.0"
|
12
|
+
end
|
13
|
+
|
14
|
+
if rspec2?
|
15
|
+
require 'rspec'
|
16
|
+
require 'rspec/core/rake_task'
|
17
|
+
else
|
18
|
+
require 'spec'
|
19
|
+
require 'spec/rake/spectask'
|
20
|
+
end
|
21
|
+
require 'ci/reporter/rake/rspec'
|
22
|
+
|
23
|
+
desc "Run all examples"
|
24
|
+
if rspec2?
|
25
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
26
|
+
t.pattern = 'spec/**/*.rb'
|
27
|
+
end
|
28
|
+
else
|
29
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
30
|
+
t.spec_files = FileList['spec/**/*.rb']
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
task :spec => ['jasmine:copy_examples_to_gem', 'bundle_install', 'ci:setup:rspec']
|
35
|
+
|
36
|
+
task :spex do
|
37
|
+
`bundle install`
|
38
|
+
Rake::Task["spec"].invoke
|
39
|
+
end
|
40
|
+
|
41
|
+
task :default => :spec
|
42
|
+
|
43
|
+
namespace :jasmine do
|
44
|
+
require './spec/jasmine_self_test_config'
|
45
|
+
task :server do
|
46
|
+
puts "your tests are here:"
|
47
|
+
puts " http://localhost:8888/"
|
48
|
+
|
49
|
+
JasmineSelfTestConfig.new.start_server
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "Copy examples from Jasmine JS to the gem"
|
53
|
+
task :copy_examples_to_gem do
|
54
|
+
unless File.exist?('jasmine/lib')
|
55
|
+
raise "Jasmine submodule isn't present. Run git submodule update --init"
|
56
|
+
end
|
57
|
+
|
58
|
+
require "fileutils"
|
59
|
+
|
60
|
+
# copy jasmine's example tree into our generator templates dir
|
61
|
+
FileUtils.rm_r('generators/jasmine/templates/jasmine-example', :force => true)
|
62
|
+
FileUtils.cp_r('jasmine/example', 'generators/jasmine/templates/jasmine-example', :preserve => true)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "Run specs via server"
|
67
|
+
task :jasmine => ['jasmine:server']
|
68
|
+
|
69
|
+
desc "Install Bundle"
|
70
|
+
task "bundle_install" do
|
71
|
+
`bundle install`
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
require 'bundler'
|
76
|
+
Bundler::GemHelper.install_tasks
|
@@ -1,26 +1,28 @@
|
|
1
1
|
class JasmineGenerator < Rails::Generator::Base
|
2
2
|
def manifest
|
3
|
-
|
3
|
+
m = ::Rails::Generator::Manifest.new
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
m.directory "public/javascripts"
|
6
|
+
m.file "jasmine-example/src/Player.js", "public/javascripts/Player.js"
|
7
|
+
m.file "jasmine-example/src/Song.js", "public/javascripts/Song.js"
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
m.directory "spec/javascripts"
|
10
|
+
m.file "jasmine-example/spec/PlayerSpec.js", "spec/javascripts/PlayerSpec.js"
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
m.directory "spec/javascripts/helpers"
|
13
|
+
m.file "jasmine-example/spec/SpecHelper.js", "spec/javascripts/helpers/SpecHelper.js"
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
m.directory "spec/javascripts/support"
|
16
|
+
m.file "spec/javascripts/support/jasmine_runner.rb", "spec/javascripts/support/jasmine_runner.rb"
|
17
|
+
m.file "spec/javascripts/support/jasmine_config.rb", "spec/javascripts/support/jasmine_config.rb"
|
18
|
+
m.file "spec/javascripts/support/jasmine-rails.yml", "spec/javascripts/support/jasmine.yml"
|
19
|
+
m.readme "INSTALL"
|
18
20
|
|
21
|
+
unless ::Rails::VERSION::STRING[0,1] == "3"
|
19
22
|
m.directory "lib/tasks"
|
20
23
|
m.file "lib/tasks/jasmine.rake", "lib/tasks/jasmine.rake"
|
21
|
-
|
22
|
-
m.readme "INSTALL"
|
23
24
|
end
|
25
|
+
m
|
24
26
|
end
|
25
27
|
|
26
28
|
def file_name
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Jasmine
|
2
|
+
class Config
|
3
|
+
|
4
|
+
# Add your overrides or custom config code here
|
5
|
+
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
# Note - this is necessary for rspec2, which has removed the backtrace
|
11
|
+
module Jasmine
|
12
|
+
class SpecBuilder
|
13
|
+
def declare_spec(parent, spec)
|
14
|
+
me = self
|
15
|
+
example_name = spec["name"]
|
16
|
+
@spec_ids << spec["id"]
|
17
|
+
backtrace = @example_locations[parent.description + " " + example_name]
|
18
|
+
parent.it example_name, {} do
|
19
|
+
me.report_spec(spec["id"])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/install.rb
ADDED
data/jasmine.gemspec
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "jasmine/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = %q{jasmine}
|
7
|
+
s.version = Jasmine::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
|
10
|
+
s.authors = ["Rajan Agaskar", "Christian Williams", "Davis Frank"]
|
11
|
+
s.summary = %q{JavaScript BDD framework}
|
12
|
+
s.description = %q{Test your JavaScript without any framework dependencies, in any environment, and with a nice descriptive syntax.}
|
13
|
+
s.email = %q{jasmine-js@googlegroups.com}
|
14
|
+
s.homepage = "http://pivotal.github.com/jasmine"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n") | Dir.glob('jasmine/**/*')
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
19
|
+
s.default_executable = %q{jasmine}
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
22
|
+
|
23
|
+
if ENV['RAILS_VERSION'] == 'pojs-rspec1'
|
24
|
+
s.add_development_dependency 'rspec', '~> 1.3.1'
|
25
|
+
s.add_development_dependency 'rake-tasks'
|
26
|
+
s.add_development_dependency 'rack', "1.1" if ENV["RUBY_VERSION"] =~ /1\.8\.6/
|
27
|
+
elsif ENV['RAILS_VERSION'] == 'pojs-rspec2'
|
28
|
+
s.add_development_dependency 'rspec', '~> 2.5.0'
|
29
|
+
s.add_development_dependency 'rake-tasks'
|
30
|
+
s.add_development_dependency 'rack', "1.1" if ENV["RUBY_VERSION"] =~ /1\.8\.6/
|
31
|
+
elsif ENV['RAILS_VERSION'] == 'rails2'
|
32
|
+
# for development & test of Rails 2 Generators
|
33
|
+
s.add_development_dependency 'rspec', '~> 1.3.1'
|
34
|
+
s.add_development_dependency 'rails', '~> 2.3.10'
|
35
|
+
s.add_development_dependency 'rack', '1.1'
|
36
|
+
else
|
37
|
+
# for development & test of Rails 3 Generators
|
38
|
+
s.add_development_dependency 'rspec', '>= 2.5.0'
|
39
|
+
s.add_development_dependency 'rails', '>= 3.0.3 '
|
40
|
+
s.add_development_dependency 'rack', '>= 1.2.1'
|
41
|
+
end
|
42
|
+
|
43
|
+
s.add_development_dependency 'rack-test'
|
44
|
+
s.add_development_dependency 'gem-release', ">= 0.0.16"
|
45
|
+
s.add_development_dependency 'ci_reporter'
|
46
|
+
|
47
|
+
s.add_dependency 'rack', '>= 1.1'
|
48
|
+
s.add_dependency 'rspec', '>= 1.3.1'
|
49
|
+
s.add_dependency 'json_pure', '>= 1.4.3'
|
50
|
+
s.add_dependency 'selenium-webdriver', '>= 0.1.3'
|
51
|
+
|
52
|
+
end
|
data/jasmine/Gemfile
ADDED
data/jasmine/MIT.LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008-2010 Pivotal Labs
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<a name="README">[Jasmine](http://pivotal.github.com/jasmine/)</a>
|
2
|
+
=======
|
3
|
+
**A JavaScript Testing Framework**
|
4
|
+
|
5
|
+
Want to use Jasmine in a project? Go HERE: [http://pivotal.github.com/jasmine/](http://pivotal.github.com/jasmine/)
|
6
|
+
|
7
|
+
Want to contribute to Jasmine? Read on...
|
8
|
+
|
9
|
+
<i>(More developer docs to come...)</i>
|
10
|
+
|
11
|
+
## Support
|
12
|
+
We now have a Google Group for support & discussion.
|
13
|
+
|
14
|
+
* Discussion: [http://groups.google.com/group/jasmine-js](http://groups.google.com/group/jasmine-js)
|
15
|
+
* Group email: [jasmine-js@googlegroups.com](jasmine-js@googlegroups.com)
|
16
|
+
* Current build status of Jasmine is visible at [ci.pivotallabs.com](http://ci.pivotallabs.com)
|
17
|
+
* Pivotal Tracker project: [http://www.pivotaltracker.com/projects/10606](http://www.pivotaltracker.com/projects/10606)
|
18
|
+
* Twitter: [@JasmineBDD](http://twitter.com/JasmineBDD)
|
19
|
+
|
20
|
+
## Maintainers
|
21
|
+
* [Davis W. Frank](mailto:dwfrank@pivotallabs.com), Pivotal Labs
|
22
|
+
* [Rajan Agaskar](mailto:rajan@pivotallabs.com), Pivotal Labs
|
23
|
+
* [Christian Williams](mailto:xian@pivotallabs.com), Pivotal Labs
|
24
|
+
|
25
|
+
## Developers
|
26
|
+
We welcome your contributions! Jasmine is currently maintained by Davis Frank ([infews](http://github.com/infews)), Rajan Agaskar ([ragaskar](http://github.com/ragaskar)), and Christian Williams ([Xian](http://github.com/Xian)). You can help us by removing all other recipients from your pull request.
|
27
|
+
|
28
|
+
Copyright (c) 2008-2010 Pivotal Labs. This software is licensed under the MIT License.
|
data/jasmine/Rakefile
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
def jasmine_sources
|
2
|
+
sources = ["src/base.js", "src/util.js", "src/Env.js", "src/Reporter.js", "src/Block.js"]
|
3
|
+
sources += Dir.glob('src/*.js').reject { |f| f == 'src/base.js' || sources.include?(f) }.sort
|
4
|
+
sources
|
5
|
+
end
|
6
|
+
|
7
|
+
def jasmine_html_sources
|
8
|
+
["src/html/TrivialReporter.js"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def jasmine_version
|
12
|
+
"#{version_hash['major']}.#{version_hash['minor']}.#{version_hash['build']}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def version_hash
|
16
|
+
require 'json'
|
17
|
+
@version ||= JSON.parse(File.new("src/version.json").read);
|
18
|
+
end
|
19
|
+
|
20
|
+
task :default => 'jasmine:dist'
|
21
|
+
|
22
|
+
def substitute_jasmine_version(filename)
|
23
|
+
contents = File.read(filename)
|
24
|
+
contents = contents.gsub(/##JASMINE_VERSION##/, (jasmine_version))
|
25
|
+
contents = contents.gsub(/[^\n]*REMOVE_THIS_LINE_FROM_BUILD[^\n]*/, '')
|
26
|
+
File.open(filename, 'w') { |f| f.write(contents) }
|
27
|
+
end
|
28
|
+
|
29
|
+
namespace :jasmine do
|
30
|
+
|
31
|
+
desc 'Prepares for distribution'
|
32
|
+
task :dist => ['jasmine:build', 'jasmine:doc', 'jasmine:build_example_project', 'jasmine:fill_index_downloads']
|
33
|
+
|
34
|
+
desc 'Check jasmine sources for coding problems'
|
35
|
+
task :lint do
|
36
|
+
passed = true
|
37
|
+
jasmine_sources.each do |src|
|
38
|
+
lines = File.read(src).split(/\n/)
|
39
|
+
lines.each_index do |i|
|
40
|
+
line = lines[i]
|
41
|
+
undefineds = line.scan(/.?undefined/)
|
42
|
+
if undefineds.include?(" undefined") || undefineds.include?("\tundefined")
|
43
|
+
puts "Dangerous undefined at #{src}:#{i}:\n > #{line}"
|
44
|
+
passed = false
|
45
|
+
end
|
46
|
+
|
47
|
+
if line.scan(/window/).length > 0
|
48
|
+
puts "Dangerous window at #{src}:#{i}:\n > #{line}"
|
49
|
+
passed = false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
unless passed
|
55
|
+
puts "Lint failed!"
|
56
|
+
exit 1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
desc 'Builds lib/jasmine from source'
|
61
|
+
task :build => :lint do
|
62
|
+
puts 'Building Jasmine from source'
|
63
|
+
|
64
|
+
sources = jasmine_sources
|
65
|
+
version = version_hash
|
66
|
+
|
67
|
+
old_jasmine_files = Dir.glob('lib/jasmine*.js')
|
68
|
+
old_jasmine_files.each { |file| File.delete(file) }
|
69
|
+
|
70
|
+
File.open("lib/jasmine.js", 'w') do |jasmine|
|
71
|
+
sources.each do |source_filename|
|
72
|
+
jasmine.puts(File.read(source_filename))
|
73
|
+
end
|
74
|
+
|
75
|
+
jasmine.puts %{
|
76
|
+
jasmine.version_= {
|
77
|
+
"major": #{version['major'].to_json},
|
78
|
+
"minor": #{version['minor'].to_json},
|
79
|
+
"build": #{version['build'].to_json},
|
80
|
+
"revision": #{Time.now.to_i}
|
81
|
+
};
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
File.open("lib/jasmine-html.js", 'w') do |jasmine_html|
|
86
|
+
jasmine_html_sources.each do |source_filename|
|
87
|
+
jasmine_html.puts(File.read(source_filename))
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
FileUtils.cp("src/html/jasmine.css", "lib/jasmine.css")
|
92
|
+
end
|
93
|
+
|
94
|
+
downloads_file = 'pages/download.html.md'
|
95
|
+
task :need_pages_submodule do
|
96
|
+
unless File.exists?(downloads_file)
|
97
|
+
raise "Jasmine pages submodule isn't present. Run git submodule update --init"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
desc "Build jasmine documentation"
|
102
|
+
task :doc => :need_pages_submodule do
|
103
|
+
puts 'Creating Jasmine Documentation'
|
104
|
+
require 'rubygems'
|
105
|
+
require 'jsdoc_helper'
|
106
|
+
|
107
|
+
FileUtils.rm_r "pages/jsdoc", :force => true
|
108
|
+
|
109
|
+
JsdocHelper::Rake::Task.new(:lambda_jsdoc) do |t|
|
110
|
+
t[:files] = jasmine_sources << jasmine_html_sources
|
111
|
+
t[:options] = "-a"
|
112
|
+
t[:out] = "pages/jsdoc"
|
113
|
+
# JsdocHelper bug: template must be relative to the JsdocHelper gem, ick
|
114
|
+
t[:template] = File.join("../".*(100), Dir::getwd, "jsdoc-template")
|
115
|
+
end
|
116
|
+
Rake::Task[:lambda_jsdoc].invoke
|
117
|
+
end
|
118
|
+
|
119
|
+
desc "Build example project"
|
120
|
+
task :build_example_project => :need_pages_submodule do
|
121
|
+
require 'tmpdir'
|
122
|
+
|
123
|
+
temp_dir = File.join(Dir.tmpdir, 'jasmine-standalone-project')
|
124
|
+
puts "Building Example Project in #{temp_dir}"
|
125
|
+
FileUtils.rm_r temp_dir if File.exists?(temp_dir)
|
126
|
+
Dir.mkdir(temp_dir)
|
127
|
+
|
128
|
+
root = File.expand_path(File.dirname(__FILE__))
|
129
|
+
FileUtils.cp_r File.join(root, 'example/.'), File.join(temp_dir)
|
130
|
+
substitute_jasmine_version(File.join(temp_dir, "SpecRunner.html"))
|
131
|
+
|
132
|
+
lib_dir = File.join(temp_dir, "lib/jasmine-#{jasmine_version}")
|
133
|
+
FileUtils.mkdir_p(lib_dir)
|
134
|
+
{
|
135
|
+
"lib/jasmine.js" => "jasmine.js",
|
136
|
+
"lib/jasmine-html.js" => "jasmine-html.js",
|
137
|
+
"src/html/jasmine.css" => "jasmine.css",
|
138
|
+
"MIT.LICENSE" => "MIT.LICENSE"
|
139
|
+
}.each_pair do |src, dest|
|
140
|
+
FileUtils.cp(File.join(root, src), File.join(lib_dir, dest))
|
141
|
+
end
|
142
|
+
|
143
|
+
dist_dir = File.join(root, 'pages/downloads')
|
144
|
+
zip_file_name = File.join(dist_dir, "jasmine-standalone-#{jasmine_version}.zip")
|
145
|
+
puts "Zipping Example Project and moving to #{zip_file_name}"
|
146
|
+
FileUtils.mkdir(dist_dir) unless File.exist?(dist_dir)
|
147
|
+
if File.exist?(zip_file_name)
|
148
|
+
puts "WARNING!!! #{zip_file_name} already exists!"
|
149
|
+
FileUtils.rm(zip_file_name)
|
150
|
+
end
|
151
|
+
exec "cd #{temp_dir} && zip -r #{zip_file_name} . -x .[a-zA-Z0-9]*"
|
152
|
+
end
|
153
|
+
|
154
|
+
task :fill_index_downloads do
|
155
|
+
require 'digest/sha1'
|
156
|
+
|
157
|
+
download_html = "<!-- START_DOWNLOADS -->\n"
|
158
|
+
Dir.glob('pages/downloads/*.zip').sort.reverse.each do |f|
|
159
|
+
sha1 = Digest::SHA1.hexdigest File.read(f)
|
160
|
+
|
161
|
+
fn = f.sub(/^pages\//, '')
|
162
|
+
version = /jasmine-standalone-(.*).zip/.match(f)[1]
|
163
|
+
prerelease = /\.rc/.match(f)
|
164
|
+
download_html += prerelease ? "<tr class=\"rc\">\n" : "<tr>\n"
|
165
|
+
download_html += " <td class=\"link\"><a href=\"#{fn}\">#{fn.sub(/downloads\//, '')}</a></td>\n"
|
166
|
+
download_html += " <td class=\"version\">#{version}</td>\n"
|
167
|
+
download_html += " <td class=\"size\">#{File.size(f) / 1024}k</td>\n"
|
168
|
+
download_html += " <td class=\"date\">#{File.mtime(f).strftime("%Y/%m/%d %H:%M:%S %Z")}</td>\n"
|
169
|
+
download_html += " <td class=\"sha\">#{sha1}</td>\n"
|
170
|
+
download_html += "</tr>\n"
|
171
|
+
end
|
172
|
+
download_html += "<!-- END_DOWNLOADS -->"
|
173
|
+
|
174
|
+
downloads_page = File.read(downloads_file)
|
175
|
+
matcher = /<!-- START_DOWNLOADS -->.*<!-- END_DOWNLOADS -->/m
|
176
|
+
downloads_page = downloads_page.sub(matcher, download_html)
|
177
|
+
File.open(downloads_file, 'w') {|f| f.write(downloads_page)}
|
178
|
+
puts "rewrote that file"
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
task :jasmine => ['jasmine:dist']
|