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.
Files changed (116) hide show
  1. data/.gitignore +11 -0
  2. data/.gitmodules +3 -0
  3. data/Gemfile +5 -0
  4. data/HOW_TO_TEST.markdown +11 -0
  5. data/README.markdown +42 -14
  6. data/RELEASE.markdown +22 -0
  7. data/Rakefile +76 -0
  8. data/generators/jasmine/jasmine_generator.rb +15 -13
  9. data/generators/jasmine/templates/spec/javascripts/support/jasmine_config.rb +23 -0
  10. data/install.rb +2 -0
  11. data/jasmine.gemspec +52 -0
  12. data/jasmine/Gemfile +6 -0
  13. data/jasmine/MIT.LICENSE +20 -0
  14. data/jasmine/README.markdown +28 -0
  15. data/jasmine/Rakefile +182 -0
  16. data/jasmine/cruise_config.rb +21 -0
  17. data/jasmine/example/spec/PlayerSpec.js +58 -0
  18. data/jasmine/example/spec/SpecHelper.js +9 -0
  19. data/jasmine/example/src/Player.js +22 -0
  20. data/jasmine/example/src/Song.js +7 -0
  21. data/jasmine/images/fail-16.png +0 -0
  22. data/jasmine/images/fail.png +0 -0
  23. data/jasmine/images/go-16.png +0 -0
  24. data/jasmine/images/go.png +0 -0
  25. data/jasmine/images/pending-16.png +0 -0
  26. data/jasmine/images/pending.png +0 -0
  27. data/jasmine/images/question-bk.png +0 -0
  28. data/jasmine/images/questionbk-16.png +0 -0
  29. data/jasmine/images/spinner.gif +0 -0
  30. data/jasmine/jsdoc-template/allclasses.tmpl +17 -0
  31. data/jasmine/jsdoc-template/allfiles.tmpl +56 -0
  32. data/jasmine/jsdoc-template/class.tmpl +646 -0
  33. data/jasmine/jsdoc-template/index.tmpl +39 -0
  34. data/jasmine/jsdoc-template/publish.js +184 -0
  35. data/jasmine/jsdoc-template/static/default.css +162 -0
  36. data/jasmine/jsdoc-template/static/header.html +2 -0
  37. data/jasmine/jsdoc-template/static/index.html +19 -0
  38. data/jasmine/jsdoc-template/symbol.tmpl +35 -0
  39. data/jasmine/spec/runner.html +80 -0
  40. data/jasmine/spec/suites/BaseSpec.js +27 -0
  41. data/jasmine/spec/suites/CustomMatchersSpec.js +97 -0
  42. data/jasmine/spec/suites/EnvSpec.js +158 -0
  43. data/jasmine/spec/suites/ExceptionsSpec.js +107 -0
  44. data/jasmine/spec/suites/JsApiReporterSpec.js +103 -0
  45. data/jasmine/spec/suites/MatchersSpec.js +795 -0
  46. data/jasmine/spec/suites/MockClockSpec.js +38 -0
  47. data/jasmine/spec/suites/MultiReporterSpec.js +45 -0
  48. data/jasmine/spec/suites/NestedResultsSpec.js +54 -0
  49. data/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
  50. data/jasmine/spec/suites/QueueSpec.js +23 -0
  51. data/jasmine/spec/suites/ReporterSpec.js +56 -0
  52. data/jasmine/spec/suites/RunnerSpec.js +267 -0
  53. data/jasmine/spec/suites/SpecRunningSpec.js +1253 -0
  54. data/jasmine/spec/suites/SpecSpec.js +124 -0
  55. data/jasmine/spec/suites/SpySpec.js +201 -0
  56. data/jasmine/spec/suites/SuiteSpec.js +120 -0
  57. data/jasmine/spec/suites/TrivialReporterSpec.js +238 -0
  58. data/jasmine/spec/suites/UtilSpec.js +40 -0
  59. data/jasmine/spec/suites/WaitsForBlockSpec.js +87 -0
  60. data/jasmine/src/Block.js +22 -0
  61. data/jasmine/src/Env.js +264 -0
  62. data/jasmine/src/JsApiReporter.js +102 -0
  63. data/jasmine/src/Matchers.js +354 -0
  64. data/jasmine/src/MultiReporter.js +35 -0
  65. data/jasmine/src/NestedResults.js +80 -0
  66. data/jasmine/src/PrettyPrinter.js +122 -0
  67. data/jasmine/src/Queue.js +99 -0
  68. data/jasmine/src/Reporter.js +31 -0
  69. data/jasmine/src/Runner.js +77 -0
  70. data/jasmine/src/Spec.js +242 -0
  71. data/jasmine/src/Suite.js +82 -0
  72. data/jasmine/src/WaitsBlock.js +13 -0
  73. data/jasmine/src/WaitsForBlock.js +52 -0
  74. data/jasmine/src/base.js +589 -0
  75. data/jasmine/src/html/TrivialReporter.js +188 -0
  76. data/jasmine/src/html/jasmine.css +166 -0
  77. data/jasmine/src/mock-timeout.js +183 -0
  78. data/jasmine/src/util.js +67 -0
  79. data/jasmine/src/version.json +5 -0
  80. data/lib/generators/jasmine/examples/USAGE +11 -0
  81. data/lib/generators/jasmine/examples/examples_generator.rb +19 -0
  82. data/lib/generators/jasmine/examples/templates/public/javascripts/jasmine_examples/Player.js +22 -0
  83. data/lib/generators/jasmine/examples/templates/public/javascripts/jasmine_examples/Song.js +7 -0
  84. data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +9 -0
  85. data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +58 -0
  86. data/lib/generators/jasmine/install/USAGE +11 -0
  87. data/lib/generators/jasmine/install/install_generator.rb +18 -0
  88. data/lib/generators/jasmine/install/templates/spec/javascripts/helpers/.gitkeep +0 -0
  89. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +81 -0
  90. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_config.rb +23 -0
  91. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_runner.rb +20 -0
  92. data/lib/generators/jasmine/jasmine_generator.rb +32 -0
  93. data/lib/generators/jasmine/templates/INSTALL +9 -0
  94. data/lib/generators/jasmine/templates/lib/tasks/jasmine.rake +2 -0
  95. data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
  96. data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +73 -0
  97. data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine_config.rb +23 -0
  98. data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine_runner.rb +32 -0
  99. data/lib/jasmine.rb +31 -6
  100. data/lib/jasmine/command_line_tool.rb +1 -0
  101. data/lib/jasmine/config.rb +16 -44
  102. data/lib/jasmine/generator.rb +9 -0
  103. data/lib/jasmine/selenium_driver.rb +18 -18
  104. data/lib/jasmine/server.rb +0 -24
  105. data/lib/jasmine/spec_builder.rb +4 -4
  106. data/lib/jasmine/tasks/jasmine.rake +2 -2
  107. data/lib/jasmine/version.rb +3 -0
  108. data/spec/config_spec.rb +174 -123
  109. data/spec/fixture/jasmine.erb.yml +4 -0
  110. data/spec/jasmine_pojs_spec.rb +51 -0
  111. data/spec/jasmine_rails2_spec.rb +93 -0
  112. data/spec/jasmine_rails3_spec.rb +71 -0
  113. data/spec/spec_helper.rb +8 -2
  114. metadata +215 -65
  115. data/spec/bug_fixes_spec.rb +0 -32
  116. data/spec/rails_generator_spec.rb +0 -31
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ .idea
2
+ pkg
3
+ bin
4
+ !bin/jasmine
5
+ .bundle
6
+ .DS_Store
7
+ .rvmrc
8
+ .pairs
9
+ *.swp
10
+ Gemfile.lock
11
+ spec/reports
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "jasmine"]
2
+ path = jasmine
3
+ url = git://github.com/pivotal/jasmine.git
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ # dependencies are specified in jasmine.gemspec
4
+
5
+ gemspec
@@ -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
- jasmine-gem
2
- ============
1
+ # The Jasmine Gem
3
2
 
4
- Jasmine Gem dynamically serves and runs suites for [Jasmine](http://github.com/pivotal/jasmine).
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
- To use:
5
+ ## Contents
6
+ This gem contains:
7
7
 
8
- `gem install jasmine`
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
- Post-installation:
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
- `bundle exec jasmine init`
24
+ `rails g jasmine:install`
25
+ `rails g jasmine:examples`
19
26
 
20
- For other Ruby projects (including Merb), use
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
- After initializing a project, you may
31
+ ## Usage
32
+
33
+ Start the Jasmine server:
25
34
 
26
35
  `rake jasmine`
27
36
 
28
- to set up a server. Opening localhost:8888 in a web browser will now run your jasmine specs.
37
+ Point your browser to `localhost:8888`. The suite will run every time this page is re-loaded.
29
38
 
30
- You may also
39
+ For Continuous Integration environments, add this task to the project build steps:
31
40
 
32
41
  `rake jasmine:ci`
33
42
 
34
- which will run your Jasmine suites using selenium and rspec. This task is suitable for running in continuous integration environments. There is currently a known issue using this rake task with RSpec2 beta.
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
- Simple Configuration:
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
- It is also possible to add overrides into the `spec/javascripts/support/jasmine_config.rb` file directly if you require further customization.
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
- record do |m|
3
+ m = ::Rails::Generator::Manifest.new
4
4
 
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"
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
- m.directory "spec/javascripts"
10
- m.file "jasmine-example/spec/PlayerSpec.js", "spec/javascripts/PlayerSpec.js"
9
+ m.directory "spec/javascripts"
10
+ m.file "jasmine-example/spec/PlayerSpec.js", "spec/javascripts/PlayerSpec.js"
11
11
 
12
- m.directory "spec/javascripts/helpers"
13
- m.file "jasmine-example/spec/SpecHelper.js", "spec/javascripts/helpers/SpecHelper.js"
12
+ m.directory "spec/javascripts/helpers"
13
+ m.file "jasmine-example/spec/SpecHelper.js", "spec/javascripts/helpers/SpecHelper.js"
14
14
 
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-rails.yml", "spec/javascripts/support/jasmine.yml"
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
@@ -0,0 +1,2 @@
1
+ xjasmine_bin = File.expand_path(File.join(File.dirname(__FILE__), 'bin', 'jasmine'))
2
+ `#{jasmine_bin} init`
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
@@ -0,0 +1,6 @@
1
+ source :gemcutter
2
+
3
+ gem "jekyll", "0.6.2"
4
+ gem "json_pure", "~>1.4.3"
5
+ gem "ragaskar-jsdoc_helper"
6
+ gem "rake", "0.8.7"
@@ -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']