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
@@ -0,0 +1,29 @@
1
+ # Making a Release of Jasmine Core
2
+
3
+ 'Jasmine' is the Github repo for Jasmine Core and contains all the JavaScript code for the Jasmine BDD framework.
4
+
5
+ It also contains two HTML pages for the Github Pages at http://pivotal.github.com/jasmine.
6
+
7
+ ## The Repo
8
+
9
+ All of the JS for Jasmine is in the src directory. The specs for each file are in the specs directory. There are rake tasks to build the various files for distribution.
10
+
11
+ ## Running Specs
12
+
13
+ There are rake tasks to help with getting green:
14
+
15
+ * `rake spec:browser` opens `spec/runner.html` in the default browser. Please run this in at least Firefox and Chrome before comitting
16
+ * `rake spec:node` runs all the Jasmine specs in Node.js
17
+ * `rake jasmine:lint` runs all the files through JSHint and will complain about potential viable issues with your code. Fix them.
18
+
19
+ ## The Pages
20
+
21
+ Github pages have to exist in a branch called gh-pages in order for their app to serve them. This repo adds that branch as a submodule under the `pages` directory. This is a bit of a hack, but it allows us to work with the pages and the source at the same time and with one set of rake tasks.
22
+
23
+ If you want to submit changes to this repo and aren't a Pivotal Labs employee, you can fork and work in the gh-pages branch. You won't be able to edit the pages in the submodule off of master.
24
+
25
+ The pages are built with [Frank](https://github.com/blahed/frank). All the source for these pages live in the pages_source directory.
26
+
27
+ ## Releasing
28
+
29
+ Once all specs are green and you've updated the version in `version.json`, you need to run the rake task to make a distribution: `rake jasmine:dist`.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008-2011 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,50 @@
1
+ <a name="README">[Jasmine](http://pivotal.github.com/jasmine/)</a>
2
+ =======
3
+ **A JavaScript Testing Framework**
4
+
5
+ Jasmine is a Behavior Driven Development testing framework for JavaScript. It does not rely on browsers, DOM, or any JavaScript framework. Thus it's suited for websites, [Node.js](http://nodejs.org) projects, or anywhere that JavaScript can run.
6
+
7
+ Documentation & guides live here: [http://pivotal.github.com/jasmine/](http://pivotal.github.com/jasmine/)
8
+
9
+ ## Support
10
+
11
+ * Search past discussions: [http://groups.google.com/group/jasmine-js](http://groups.google.com/group/jasmine-js)
12
+ * Send an email to the list: [jasmine-js@googlegroups.com](jasmine-js@googlegroups.com)
13
+ * Check the current build status: [ci.pivotallabs.com](http://ci.pivotallabs.com)
14
+ * View the project backlog at Pivotal Tracker: [http://www.pivotaltracker.com/projects/10606](http://www.pivotaltracker.com/projects/10606)
15
+ * Follow us on Twitter: [@JasmineBDD](http://twitter.com/JasmineBDD)
16
+
17
+ ## How to Contribute
18
+
19
+ We welcome your contributions - Thanks for helping make Jasmine a better project for everyone. Please review the backlog and discussion lists (the main group - [http://groups.google.com/group/jasmine-js](http://groups.google.com/group/jasmine-js) and the developer's list - [http://groups.google.com/group/jasmine-js-dev](http://groups.google.com/group/jasmine-js-dev)) before starting work - what you're looking for may already have been done. If it hasn't, the community can help make your contribution better.
20
+
21
+ ### Development Environment
22
+
23
+ Jasmine Core relies on Ruby for executing the test suite and building the project for release. The spec suite runs in any major, modern browser (Firefox, Safari, Chrome, and yes various IE's) and in [Node.js](http://nodejs.org). While you probably have browsers installed, you want to make sure that Ruby and Node are present.
24
+
25
+ ### How to Develop for Jasmine Core
26
+
27
+ * Write specs
28
+ * Make them pass in a browser (or three):
29
+ * open `spec/runner.html` in your browsers
30
+ * `rake spec:browser` will run in the default browser on MacOS
31
+ * Make them pass in Node: `rake spec:node`
32
+ * Fix any warnings or errors from JSHint: `rake jasmine:lint`
33
+
34
+ Running `rake spec` will run the browser tests, then run specs in Node, then run JSHint. But this will only run in the default browser and only on MacOS (for now).
35
+
36
+
37
+ ### Making a Successful Pull Request
38
+
39
+ * __Include specs for your work__ - it helps us understand your intent and makes sure that future development doesn't break your work
40
+ * __Ensure the full test suite is green__ in all the big browsers, Node, and JSHint - your contribution shouldn't break Jasmine for other users
41
+
42
+ Do these things and we'll take a look.
43
+
44
+ ## Maintainers
45
+
46
+ * [Davis W. Frank](mailto:dwfrank@pivotallabs.com), Pivotal Labs
47
+ * [Rajan Agaskar](mailto:rajan@pivotallabs.com), Pivotal Labs
48
+ * [Christian Williams](mailto:antixian666@gmail.com), Square
49
+
50
+ Copyright (c) 2008-2011 Pivotal Labs. This software is licensed under the MIT License.
data/jasmine/Rakefile ADDED
@@ -0,0 +1,166 @@
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
+
21
+ def substitute_jasmine_version(filename)
22
+ contents = File.read(filename)
23
+ contents = contents.gsub(/##JASMINE_VERSION##/, (jasmine_version))
24
+ contents = contents.gsub(/[^\n]*REMOVE_THIS_LINE_FROM_BUILD[^\n]*/, '')
25
+ File.open(filename, 'w') { |f| f.write(contents) }
26
+ end
27
+
28
+ task :default => :spec
29
+
30
+ desc "Run spec suite: Browser, Node, JSHint"
31
+ task :spec => ["spec:node", "spec:browser", "jasmine:hint"]
32
+
33
+ namespace :spec do
34
+ desc 'Run specs in Node.js'
35
+ task :node do
36
+ raise "Node is required to run all jasmine specs" unless system("node spec/node_suite.js")
37
+ end
38
+
39
+ desc "Run specs in the default browser (MacOS only)"
40
+ task :browser do
41
+ system("open spec/runner.html")
42
+ end
43
+ end
44
+
45
+ namespace :jasmine do
46
+
47
+ desc 'Prepares for distribution'
48
+ task :dist => ['jasmine:build',
49
+ 'jasmine:doc',
50
+ 'jasmine:build_pages',
51
+ 'jasmine:build_example_project',
52
+ 'jasmine:fill_index_downloads']
53
+
54
+ desc 'Check jasmine sources for coding problems'
55
+ task :lint do
56
+ puts "Running JSHint via Node.js"
57
+ system("node jshint/run.js") || exit(1)
58
+ end
59
+
60
+ desc "Alias to JSHint"
61
+ task :hint => :lint
62
+
63
+ desc 'Builds lib/jasmine from source'
64
+ task :build => :lint do
65
+ puts 'Building Jasmine from source'
66
+
67
+ sources = jasmine_sources
68
+ version = version_hash
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'
95
+ task :need_pages_submodule do
96
+ unless File.exist?(downloads_file)
97
+ raise "Jasmine pages submodule isn't present. Run git submodule update --init"
98
+ end
99
+ end
100
+
101
+ desc "Build the Github pages HTML"
102
+ task :build_pages => :need_pages_submodule do
103
+ Dir.chdir("pages") do
104
+ FileUtils.rm_r('pages_output') if File.exist?('pages_output')
105
+ Dir.chdir('pages_source') do
106
+ system("frank export ../pages_output")
107
+ end
108
+ puts "\nCopying Frank output to the root of the gh-pages branch\n\n"
109
+ system("cp -r pages_output/* .")
110
+ end
111
+ end
112
+
113
+ desc "Build jasmine documentation"
114
+ task :doc => :need_pages_submodule do
115
+ puts 'Creating Jasmine Documentation'
116
+ require 'rubygems'
117
+ require 'jsdoc_helper'
118
+
119
+ FileUtils.rm_r "pages/jsdoc", :force => true
120
+
121
+ JsdocHelper::Rake::Task.new(:lambda_jsdoc) do |t|
122
+ t[:files] = jasmine_sources << jasmine_html_sources
123
+ t[:options] = "-a"
124
+ t[:out] = "pages/jsdoc"
125
+ # JsdocHelper bug: template must be relative to the JsdocHelper gem, ick
126
+ t[:template] = File.join("../".*(100), Dir::getwd, "jsdoc-template")
127
+ end
128
+ Rake::Task[:lambda_jsdoc].invoke
129
+ end
130
+
131
+ desc "Build example project"
132
+ task :build_example_project => :need_pages_submodule do
133
+ require 'tmpdir'
134
+
135
+ temp_dir = File.join(Dir.tmpdir, 'jasmine-standalone-project')
136
+ puts "Building Example Project in #{temp_dir}"
137
+ FileUtils.rm_r temp_dir if File.exist?(temp_dir)
138
+ Dir.mkdir(temp_dir)
139
+
140
+ root = File.expand_path(File.dirname(__FILE__))
141
+ FileUtils.cp_r File.join(root, 'example/.'), File.join(temp_dir)
142
+ substitute_jasmine_version(File.join(temp_dir, "SpecRunner.html"))
143
+
144
+ lib_dir = File.join(temp_dir, "lib/jasmine-#{jasmine_version}")
145
+ FileUtils.mkdir_p(lib_dir)
146
+ {
147
+ "lib/jasmine.js" => "jasmine.js",
148
+ "lib/jasmine-html.js" => "jasmine-html.js",
149
+ "src/html/jasmine.css" => "jasmine.css",
150
+ "MIT.LICENSE" => "MIT.LICENSE"
151
+ }.each_pair do |src, dest|
152
+ FileUtils.cp(File.join(root, src), File.join(lib_dir, dest))
153
+ end
154
+
155
+ dist_dir = File.join(root, 'pages/downloads')
156
+ zip_file_name = File.join(dist_dir, "jasmine-standalone-#{jasmine_version}.zip")
157
+ puts "Zipping Example Project and moving to #{zip_file_name}"
158
+ FileUtils.mkdir(dist_dir) unless File.exist?(dist_dir)
159
+ if File.exist?(zip_file_name)
160
+ puts "WARNING!!! #{zip_file_name} already exists!"
161
+ FileUtils.rm(zip_file_name)
162
+ end
163
+ exec "cd #{temp_dir} && zip -r #{zip_file_name} . -x .[a-zA-Z0-9]*"
164
+ end
165
+
166
+ end
@@ -0,0 +1,21 @@
1
+ # Project-specific configuration for CruiseControl.rb
2
+ Project.configure do |project|
3
+
4
+ # Send email notifications about broken and fixed builds to email1@your.site, email2@your.site (default: send to nobody)
5
+ # project.email_notifier.emails = ['email1@your.site', 'email2@your.site']
6
+
7
+ # Set email 'from' field to john@doe.com:
8
+ # project.email_notifier.from = 'john@doe.com'
9
+
10
+ # Build the project by invoking rake task 'custom'
11
+ project.rake_task = 'jasmine:test:ci:saucelabs'
12
+
13
+ # Build the project by invoking shell script "build_my_app.sh". Keep in mind that when the script is invoked,
14
+ # current working directory is <em>[cruise&nbsp;data]</em>/projects/your_project/work, so if you do not keep build_my_app.sh
15
+ # in version control, it should be '../build_my_app.sh' instead
16
+ #project.build_command = 'cp ../saucelabs.yml .'
17
+
18
+ # Ping Subversion for new revisions every 5 minutes (default: 30 seconds)
19
+ # project.scheduler.polling_interval = 5.minutes
20
+
21
+ end
@@ -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
+ };
Binary file
@@ -0,0 +1,17 @@
1
+ <div align="center">{+new Link().toFile("index.html").withText("Class Index")+}
2
+ | {+new Link().toFile("files.html").withText("File Index")+}</div>
3
+ <hr />
4
+ <h2>Classes</h2>
5
+ <ul class="classList">
6
+ <for each="thisClass" in="data">
7
+ <li>{!
8
+ if (thisClass.alias == "_global_") {
9
+ output += "<i>"+new Link().toClass(thisClass.alias)+"</i>";
10
+ }
11
+ else {
12
+ output += new Link().toClass(thisClass.alias);
13
+ }
14
+ !}</li>
15
+ </for>
16
+ </ul>
17
+ <hr />
@@ -0,0 +1,56 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="content-type" content="text/html; charset={+IO.encoding+}"" />
6
+ {! Link.base = ""; /* all generated links will be relative to this */ !}
7
+ <title>JsDoc Reference - File Index</title>
8
+ <meta name="generator" content="JsDoc Toolkit" />
9
+
10
+ <style type="text/css">
11
+ {+include("static/default.css")+}
12
+ </style>
13
+ </head>
14
+
15
+ <body>
16
+ {+include("static/header.html")+}
17
+
18
+ <div id="index">
19
+ {+publish.classesIndex+}
20
+ </div>
21
+
22
+ <div id="content">
23
+ <h1 class="classTitle">File Index</h1>
24
+
25
+ <for each="item" in="data">
26
+ <div>
27
+ <h2>{+new Link().toSrc(item.alias).withText(item.name)+}</h2>
28
+ <if test="item.desc">{+resolveLinks(summarize(item.desc))+}</if>
29
+ <dl>
30
+ <if test="item.author">
31
+ <dt class="heading">Author:</dt>
32
+ <dd>{+item.author+}</dd>
33
+ </if>
34
+ <if test="item.version">
35
+ <dt class="heading">Version:</dt>
36
+ <dd>{+item.version+}</dd>
37
+ </if>
38
+ {! var locations = item.comment.getTag('location').map(function($){return $.toString().replace(/(^\$ ?| ?\$$)/g, '').replace(/^HeadURL: https:/g, 'http:');}) !}
39
+ <if test="locations.length">
40
+ <dt class="heading">Location:</dt>
41
+ <for each="location" in="locations">
42
+ <dd><a href="{+location+}">{+location+}</a></dd>
43
+ </for>
44
+ </if>
45
+ </dl>
46
+ </div>
47
+ <hr />
48
+ </for>
49
+
50
+ </div>
51
+ <div class="fineprint" style="clear:both">
52
+ <if test="JSDOC.opt.D.copyright">&copy;{+JSDOC.opt.D.copyright+}<br /></if>
53
+ Documentation generated by <a href="http://www.jsdoctoolkit.org/" target="_blankt">JsDoc Toolkit</a> {+JSDOC.VERSION+} on {+new Date()+}
54
+ </div>
55
+ </body>
56
+ </html>