josephholsten-jasmine 1.1.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. data/.gitignore +11 -0
  2. data/.gitmodules +3 -0
  3. data/Gemfile +5 -0
  4. data/HOW_TO_TEST.markdown +9 -0
  5. data/MIT.LICENSE +20 -0
  6. data/README.markdown +71 -0
  7. data/RELEASE.markdown +22 -0
  8. data/Rakefile +76 -0
  9. data/bin/jasmine +6 -0
  10. data/generators/jasmine/jasmine_generator.rb +32 -0
  11. data/generators/jasmine/templates/INSTALL +9 -0
  12. data/generators/jasmine/templates/jasmine-example/SpecRunner.html +27 -0
  13. data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +58 -0
  14. data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +9 -0
  15. data/generators/jasmine/templates/jasmine-example/src/Player.js +22 -0
  16. data/generators/jasmine/templates/jasmine-example/src/Song.js +7 -0
  17. data/generators/jasmine/templates/lib/tasks/jasmine.rake +8 -0
  18. data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
  19. data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +73 -0
  20. data/generators/jasmine/templates/spec/javascripts/support/jasmine_config.rb +23 -0
  21. data/generators/jasmine/templates/spec/javascripts/support/jasmine_runner.rb +32 -0
  22. data/jasmine/Gemfile +6 -0
  23. data/jasmine/Gemfile.lock +33 -0
  24. data/jasmine/HowToRelease.markdown +29 -0
  25. data/jasmine/MIT.LICENSE +20 -0
  26. data/jasmine/README.markdown +50 -0
  27. data/jasmine/Rakefile +166 -0
  28. data/jasmine/cruise_config.rb +21 -0
  29. data/jasmine/example/SpecRunner.html +27 -0
  30. data/jasmine/example/spec/PlayerSpec.js +58 -0
  31. data/jasmine/example/spec/SpecHelper.js +9 -0
  32. data/jasmine/example/src/Player.js +22 -0
  33. data/jasmine/example/src/Song.js +7 -0
  34. data/jasmine/images/jasmine_favicon.png +0 -0
  35. data/jasmine/jsdoc-template/allclasses.tmpl +17 -0
  36. data/jasmine/jsdoc-template/allfiles.tmpl +56 -0
  37. data/jasmine/jsdoc-template/class.tmpl +646 -0
  38. data/jasmine/jsdoc-template/index.tmpl +39 -0
  39. data/jasmine/jsdoc-template/publish.js +184 -0
  40. data/jasmine/jsdoc-template/static/default.css +162 -0
  41. data/jasmine/jsdoc-template/static/header.html +2 -0
  42. data/jasmine/jsdoc-template/static/index.html +19 -0
  43. data/jasmine/jsdoc-template/symbol.tmpl +35 -0
  44. data/jasmine/jshint/jshint.js +5919 -0
  45. data/jasmine/jshint/run.js +98 -0
  46. data/jasmine/lib/jasmine-html.js +190 -0
  47. data/jasmine/lib/jasmine.css +166 -0
  48. data/jasmine/lib/jasmine.js +2445 -0
  49. data/jasmine/lib/json2.js +478 -0
  50. data/jasmine/spec/node_suite.js +233 -0
  51. data/jasmine/spec/runner.html +82 -0
  52. data/jasmine/spec/suites/BaseSpec.js +27 -0
  53. data/jasmine/spec/suites/CustomMatchersSpec.js +97 -0
  54. data/jasmine/spec/suites/EnvSpec.js +158 -0
  55. data/jasmine/spec/suites/ExceptionsSpec.js +107 -0
  56. data/jasmine/spec/suites/JsApiReporterSpec.js +103 -0
  57. data/jasmine/spec/suites/MatchersSpec.js +795 -0
  58. data/jasmine/spec/suites/MockClockSpec.js +38 -0
  59. data/jasmine/spec/suites/MultiReporterSpec.js +45 -0
  60. data/jasmine/spec/suites/NestedResultsSpec.js +54 -0
  61. data/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
  62. data/jasmine/spec/suites/QueueSpec.js +23 -0
  63. data/jasmine/spec/suites/ReporterSpec.js +56 -0
  64. data/jasmine/spec/suites/RunnerSpec.js +267 -0
  65. data/jasmine/spec/suites/SpecRunningSpec.js +1253 -0
  66. data/jasmine/spec/suites/SpecSpec.js +124 -0
  67. data/jasmine/spec/suites/SpySpec.js +201 -0
  68. data/jasmine/spec/suites/SuiteSpec.js +120 -0
  69. data/jasmine/spec/suites/TrivialConsoleReporterSpec.js +431 -0
  70. data/jasmine/spec/suites/TrivialReporterSpec.js +238 -0
  71. data/jasmine/spec/suites/UtilSpec.js +39 -0
  72. data/jasmine/spec/suites/WaitsForBlockSpec.js +118 -0
  73. data/jasmine/src/Block.js +22 -0
  74. data/jasmine/src/Env.js +264 -0
  75. data/jasmine/src/JsApiReporter.js +102 -0
  76. data/jasmine/src/Matchers.js +354 -0
  77. data/jasmine/src/MultiReporter.js +35 -0
  78. data/jasmine/src/NestedResults.js +80 -0
  79. data/jasmine/src/PrettyPrinter.js +123 -0
  80. data/jasmine/src/Queue.js +99 -0
  81. data/jasmine/src/Reporter.js +31 -0
  82. data/jasmine/src/Runner.js +77 -0
  83. data/jasmine/src/Spec.js +242 -0
  84. data/jasmine/src/Suite.js +82 -0
  85. data/jasmine/src/WaitsBlock.js +15 -0
  86. data/jasmine/src/WaitsForBlock.js +54 -0
  87. data/jasmine/src/base.js +608 -0
  88. data/jasmine/src/console/TrivialConsoleReporter.js +144 -0
  89. data/jasmine/src/html/TrivialReporter.js +190 -0
  90. data/jasmine/src/html/jasmine.css +166 -0
  91. data/jasmine/src/mock-timeout.js +183 -0
  92. data/jasmine/src/util.js +67 -0
  93. data/jasmine/src/version.json +5 -0
  94. data/jasmine.gemspec +52 -0
  95. data/lib/generators/jasmine/examples/USAGE +11 -0
  96. data/lib/generators/jasmine/examples/examples_generator.rb +19 -0
  97. data/lib/generators/jasmine/examples/templates/public/javascripts/jasmine_examples/Player.js +22 -0
  98. data/lib/generators/jasmine/examples/templates/public/javascripts/jasmine_examples/Song.js +7 -0
  99. data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +9 -0
  100. data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +58 -0
  101. data/lib/generators/jasmine/install/USAGE +11 -0
  102. data/lib/generators/jasmine/install/install_generator.rb +18 -0
  103. data/lib/generators/jasmine/install/templates/spec/javascripts/helpers/.gitkeep +0 -0
  104. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +81 -0
  105. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_config.rb +23 -0
  106. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_runner.rb +20 -0
  107. data/lib/generators/jasmine/jasmine_generator.rb +32 -0
  108. data/lib/generators/jasmine/templates/INSTALL +9 -0
  109. data/lib/generators/jasmine/templates/lib/tasks/jasmine.rake +2 -0
  110. data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
  111. data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +73 -0
  112. data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine_config.rb +23 -0
  113. data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine_runner.rb +32 -0
  114. data/lib/jasmine/base.rb +66 -0
  115. data/lib/jasmine/command_line_tool.rb +72 -0
  116. data/lib/jasmine/config.rb +190 -0
  117. data/lib/jasmine/railtie.rb +20 -0
  118. data/lib/jasmine/run.html.erb +44 -0
  119. data/lib/jasmine/selenium_driver.rb +49 -0
  120. data/lib/jasmine/server.rb +106 -0
  121. data/lib/jasmine/spec_builder.rb +162 -0
  122. data/lib/jasmine/tasks/jasmine.rake +44 -0
  123. data/lib/jasmine/version.rb +3 -0
  124. data/lib/jasmine.rb +14 -0
  125. data/spec/config_spec.rb +308 -0
  126. data/spec/fixture/jasmine.erb.yml +4 -0
  127. data/spec/jasmine_command_line_tool_spec.rb +29 -0
  128. data/spec/jasmine_pojs_spec.rb +51 -0
  129. data/spec/jasmine_rails2_spec.rb +93 -0
  130. data/spec/jasmine_rails3_spec.rb +71 -0
  131. data/spec/jasmine_self_test_config.rb +15 -0
  132. data/spec/jasmine_self_test_spec.rb +24 -0
  133. data/spec/server_spec.rb +80 -0
  134. data/spec/spec_helper.rb +65 -0
  135. metadata +386 -0
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,9 @@
1
+ To test changes to the jasmine-gem:
2
+
3
+ * Export RAILS_VERSION as either "pojs-rspec1", "pojs-rspec2", or "rails2" to test environments other than Rails 3.
4
+ * Delete `Gemfile.lock`
5
+ * Clear out your current gemset
6
+ * exec a `bundle install`
7
+ * `rake` until specs are green
8
+ * Repeat
9
+ * Check in
data/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.
data/README.markdown ADDED
@@ -0,0 +1,71 @@
1
+ # The Jasmine Gem
2
+
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.
4
+
5
+ ## Contents
6
+ This gem contains:
7
+
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)
11
+
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
17
+
18
+ For Rails2 support, use
19
+
20
+ `script/generate jasmine`
21
+
22
+ For Rails3 support, use
23
+
24
+ `rails g jasmine:install`
25
+ `rails g jasmine:examples`
26
+
27
+ For any other project (Sinatra, Merb, or something we don't yet know about) use
28
+
29
+ `jasmine init`
30
+
31
+ ## Usage
32
+
33
+ Start the Jasmine server:
34
+
35
+ `rake jasmine`
36
+
37
+ Point your browser to `localhost:8888`. The suite will run every time this page is re-loaded.
38
+
39
+ For Continuous Integration environments, add this task to the project build steps:
40
+
41
+ `rake jasmine:ci`
42
+
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.
44
+
45
+ ## Configuration
46
+
47
+ Customize `spec/javascripts/support/jasmine.yml` to enumerate the source files, stylesheets, and spec files you would like the Jasmine runner to include.
48
+ You may use dir glob strings.
49
+
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
70
+
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
data/bin/jasmine ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'jasmine'
5
+
6
+ Jasmine::CommandLineTool.new.process ARGV
@@ -0,0 +1,32 @@
1
+ class JasmineGenerator < Rails::Generator::Base
2
+ def manifest
3
+ m = ::Rails::Generator::Manifest.new
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"
8
+
9
+ m.directory "spec/javascripts"
10
+ m.file "jasmine-example/spec/PlayerSpec.js", "spec/javascripts/PlayerSpec.js"
11
+
12
+ m.directory "spec/javascripts/helpers"
13
+ m.file "jasmine-example/spec/SpecHelper.js", "spec/javascripts/helpers/SpecHelper.js"
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_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"
20
+
21
+ unless ::Rails::VERSION::STRING[0,1] == "3"
22
+ m.directory "lib/tasks"
23
+ m.file "lib/tasks/jasmine.rake", "lib/tasks/jasmine.rake"
24
+ end
25
+ m
26
+ end
27
+
28
+ def file_name
29
+ "create_blog"
30
+ end
31
+
32
+ end
@@ -0,0 +1,9 @@
1
+ Jasmine has been installed with example specs.
2
+
3
+ To run the server:
4
+
5
+ rake jasmine
6
+
7
+ To run the automated CI task with Selenium:
8
+
9
+ rake jasmine:ci
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+ <html>
4
+ <head>
5
+ <title>Jasmine Test Runner</title>
6
+ <link rel="stylesheet" type="text/css" href="lib/jasmine-##JASMINE_VERSION##/jasmine.css">
7
+ <script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine.js"></script>
8
+ <script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine-html.js"></script>
9
+
10
+ <!-- include source files here... -->
11
+ <script type="text/javascript" src="src/Player.js"></script>
12
+ <script type="text/javascript" src="src/Song.js"></script>
13
+
14
+ <!-- include spec files here... -->
15
+ <script type="text/javascript" src="spec/SpecHelper.js"></script>
16
+ <script type="text/javascript" src="spec/PlayerSpec.js"></script>
17
+
18
+ </head>
19
+ <body>
20
+ <div id="REMOVE_THIS_LINE_FROM_BUILD"><p>You must be trying to look at examples in the Jasmine source tree.</p><p>Please download a distribution version of Jasmine at <a href="http://pivotal.github.com/jasmine/">http://pivotal.github.com/jasmine/</a>.</p></div>
21
+ <script type="text/javascript">
22
+ jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
23
+ jasmine.getEnv().execute();
24
+ </script>
25
+
26
+ </body>
27
+ </html>
@@ -0,0 +1,58 @@
1
+ describe("Player", function() {
2
+ var player;
3
+ var song;
4
+
5
+ beforeEach(function() {
6
+ player = new Player();
7
+ song = new Song();
8
+ });
9
+
10
+ it("should be able to play a Song", function() {
11
+ player.play(song);
12
+ expect(player.currentlyPlayingSong).toEqual(song);
13
+
14
+ //demonstrates use of custom matcher
15
+ expect(player).toBePlaying(song);
16
+ });
17
+
18
+ describe("when song has been paused", function() {
19
+ beforeEach(function() {
20
+ player.play(song);
21
+ player.pause();
22
+ });
23
+
24
+ it("should indicate that the song is currently paused", function() {
25
+ expect(player.isPlaying).toBeFalsy();
26
+
27
+ // demonstrates use of 'not' with a custom matcher
28
+ expect(player).not.toBePlaying(song);
29
+ });
30
+
31
+ it("should be possible to resume", function() {
32
+ player.resume();
33
+ expect(player.isPlaying).toBeTruthy();
34
+ expect(player.currentlyPlayingSong).toEqual(song);
35
+ });
36
+ });
37
+
38
+ // demonstrates use of spies to intercept and test method calls
39
+ it("tells the current song if the user has made it a favorite", function() {
40
+ spyOn(song, 'persistFavoriteStatus');
41
+
42
+ player.play(song);
43
+ player.makeFavorite();
44
+
45
+ expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
46
+ });
47
+
48
+ //demonstrates use of expected exceptions
49
+ describe("#resume", function() {
50
+ it("should throw an exception if song is already playing", function() {
51
+ player.play(song);
52
+
53
+ expect(function() {
54
+ player.resume();
55
+ }).toThrow("song is already playing");
56
+ });
57
+ });
58
+ });
@@ -0,0 +1,9 @@
1
+ beforeEach(function() {
2
+ this.addMatchers({
3
+ toBePlaying: function(expectedSong) {
4
+ var player = this.actual;
5
+ return player.currentlyPlayingSong === expectedSong
6
+ && player.isPlaying;
7
+ }
8
+ })
9
+ });
@@ -0,0 +1,22 @@
1
+ function Player() {
2
+ }
3
+ Player.prototype.play = function(song) {
4
+ this.currentlyPlayingSong = song;
5
+ this.isPlaying = true;
6
+ };
7
+
8
+ Player.prototype.pause = function() {
9
+ this.isPlaying = false;
10
+ };
11
+
12
+ Player.prototype.resume = function() {
13
+ if (this.isPlaying) {
14
+ throw new Error("song is already playing");
15
+ }
16
+
17
+ this.isPlaying = true;
18
+ };
19
+
20
+ Player.prototype.makeFavorite = function() {
21
+ this.currentlyPlayingSong.persistFavoriteStatus(true);
22
+ };
@@ -0,0 +1,7 @@
1
+ function Song() {
2
+ }
3
+
4
+ Song.prototype.persistFavoriteStatus = function(value) {
5
+ // something complicated
6
+ throw new Error("not yet implemented");
7
+ };
@@ -0,0 +1,8 @@
1
+ begin
2
+ require 'jasmine'
3
+ load 'jasmine/tasks/jasmine.rake'
4
+ rescue LoadError
5
+ task :jasmine do
6
+ abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
7
+ end
8
+ end
@@ -0,0 +1,81 @@
1
+ # src_files
2
+ #
3
+ # Return an array of filepaths relative to src_dir to include before jasmine specs.
4
+ # Default: []
5
+ #
6
+ # EXAMPLE:
7
+ #
8
+ # src_files:
9
+ # - lib/source1.js
10
+ # - lib/source2.js
11
+ # - dist/**/*.js
12
+ #
13
+ src_files:
14
+ - public/javascripts/prototype.js
15
+ - public/javascripts/effects.js
16
+ - public/javascripts/controls.js
17
+ - public/javascripts/dragdrop.js
18
+ - public/javascripts/application.js
19
+ - public/javascripts/**/*.js
20
+
21
+ # stylesheets
22
+ #
23
+ # Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
24
+ # Default: []
25
+ #
26
+ # EXAMPLE:
27
+ #
28
+ # stylesheets:
29
+ # - css/style.css
30
+ # - stylesheets/*.css
31
+ #
32
+ stylesheets:
33
+ - stylesheets/**/*.css
34
+
35
+ # helpers
36
+ #
37
+ # Return an array of filepaths relative to spec_dir to include before jasmine specs.
38
+ # Default: ["helpers/**/*.js"]
39
+ #
40
+ # EXAMPLE:
41
+ #
42
+ # helpers:
43
+ # - helpers/**/*.js
44
+ #
45
+ helpers:
46
+ - helpers/**/*.js
47
+
48
+ # spec_files
49
+ #
50
+ # Return an array of filepaths relative to spec_dir to include.
51
+ # Default: ["**/*[sS]pec.js"]
52
+ #
53
+ # EXAMPLE:
54
+ #
55
+ # spec_files:
56
+ # - **/*[sS]pec.js
57
+ #
58
+ spec_files:
59
+ - '**/*[sS]pec.js'
60
+
61
+ # src_dir
62
+ #
63
+ # Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
64
+ # Default: project root
65
+ #
66
+ # EXAMPLE:
67
+ #
68
+ # src_dir: public
69
+ #
70
+ src_dir:
71
+
72
+ # spec_dir
73
+ #
74
+ # Spec directory path. Your spec_files must be returned relative to this path.
75
+ # Default: spec/javascripts
76
+ #
77
+ # EXAMPLE:
78
+ #
79
+ # spec_dir: spec/javascripts
80
+ #
81
+ spec_dir: spec/javascripts
@@ -0,0 +1,73 @@
1
+ # src_files
2
+ #
3
+ # Return an array of filepaths relative to src_dir to include before jasmine specs.
4
+ # Default: []
5
+ #
6
+ # EXAMPLE:
7
+ #
8
+ # src_files:
9
+ # - lib/source1.js
10
+ # - lib/source2.js
11
+ # - dist/**/*.js
12
+ #
13
+ src_files:
14
+ - public/javascripts/**/*.js
15
+
16
+ # stylesheets
17
+ #
18
+ # Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
19
+ # Default: []
20
+ #
21
+ # EXAMPLE:
22
+ #
23
+ # stylesheets:
24
+ # - css/style.css
25
+ # - stylesheets/*.css
26
+ #
27
+ stylesheets:
28
+
29
+ # helpers
30
+ #
31
+ # Return an array of filepaths relative to spec_dir to include before jasmine specs.
32
+ # Default: ["helpers/**/*.js"]
33
+ #
34
+ # EXAMPLE:
35
+ #
36
+ # helpers:
37
+ # - helpers/**/*.js
38
+ #
39
+ helpers:
40
+
41
+ # spec_files
42
+ #
43
+ # Return an array of filepaths relative to spec_dir to include.
44
+ # Default: ["**/*[sS]pec.js"]
45
+ #
46
+ # EXAMPLE:
47
+ #
48
+ # spec_files:
49
+ # - **/*[sS]pec.js
50
+ #
51
+ spec_files:
52
+
53
+ # src_dir
54
+ #
55
+ # Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
56
+ # Default: project root
57
+ #
58
+ # EXAMPLE:
59
+ #
60
+ # src_dir: public
61
+ #
62
+ src_dir:
63
+
64
+ # spec_dir
65
+ #
66
+ # Spec directory path. Your spec_files must be returned relative to this path.
67
+ # Default: spec/javascripts
68
+ #
69
+ # EXAMPLE:
70
+ #
71
+ # spec_dir: spec/javascripts
72
+ #
73
+ spec_dir:
@@ -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
@@ -0,0 +1,32 @@
1
+ $:.unshift(ENV['JASMINE_GEM_PATH']) if ENV['JASMINE_GEM_PATH'] # for gem testing purposes
2
+
3
+ require 'rubygems'
4
+ require 'jasmine'
5
+ jasmine_config_overrides = File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config.rb'))
6
+ require jasmine_config_overrides if File.exist?(jasmine_config_overrides)
7
+ if Jasmine::rspec2?
8
+ require 'rspec'
9
+ else
10
+ require 'spec'
11
+ end
12
+
13
+ jasmine_config = Jasmine::Config.new
14
+ spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
15
+
16
+ should_stop = false
17
+
18
+ if Jasmine::rspec2?
19
+ RSpec.configuration.after(:suite) do
20
+ spec_builder.stop if should_stop
21
+ end
22
+ else
23
+ Spec::Runner.configure do |config|
24
+ config.after(:suite) do
25
+ spec_builder.stop if should_stop
26
+ end
27
+ end
28
+ end
29
+
30
+ spec_builder.start
31
+ should_stop = true
32
+ spec_builder.declare_suites
data/jasmine/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source :rubygems
2
+
3
+ gem "json_pure", "~>1.4.3"
4
+ gem "frank"
5
+ gem "ragaskar-jsdoc_helper"
6
+ gem "rake", "0.8.7"
@@ -0,0 +1,33 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ daemons (1.0.10)
5
+ frank (1.0.8)
6
+ haml (>= 3.0)
7
+ mongrel (>= 1.2.0.pre2)
8
+ net-scp (>= 1.0)
9
+ net-ssh (>= 2.0)
10
+ rack (>= 1.0)
11
+ tilt (= 0.9)
12
+ gem_plugin (0.2.3)
13
+ haml (3.0.25)
14
+ json_pure (1.4.6)
15
+ mongrel (1.2.0.pre2)
16
+ daemons (~> 1.0.10)
17
+ gem_plugin (~> 0.2.3)
18
+ net-scp (1.0.4)
19
+ net-ssh (>= 1.99.1)
20
+ net-ssh (2.1.0)
21
+ rack (1.2.1)
22
+ ragaskar-jsdoc_helper (0.0.2.1)
23
+ rake (0.8.7)
24
+ tilt (0.9)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ frank
31
+ json_pure (~> 1.4.3)
32
+ ragaskar-jsdoc_helper
33
+ rake (= 0.8.7)