rally-jasmine 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +13 -0
- data/.rspec +1 -0
- data/.travis.yml +58 -0
- data/Gemfile +8 -0
- data/HOW_TO_TEST.markdown +9 -0
- data/MIT.LICENSE +20 -0
- data/README.markdown +77 -0
- data/RELEASE.markdown +22 -0
- data/RELEASE_NOTES.markdown +6 -0
- data/Rakefile +53 -0
- data/bin/jasmine +6 -0
- data/generators/jasmine/jasmine_generator.rb +24 -0
- data/generators/jasmine/templates/INSTALL +9 -0
- data/generators/jasmine/templates/jasmine-example/SpecRunner.html +54 -0
- data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +58 -0
- data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +9 -0
- data/generators/jasmine/templates/jasmine-example/src/Player.js +22 -0
- data/generators/jasmine/templates/jasmine-example/src/Song.js +7 -0
- data/generators/jasmine/templates/lib/tasks/jasmine.rake +8 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +73 -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/app/assets/javascripts/jasmine_examples/Player.js +22 -0
- data/lib/generators/jasmine/examples/templates/app/assets/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 +76 -0
- data/lib/jasmine/application.rb +43 -0
- data/lib/jasmine/asset_pipeline_mapper.rb +19 -0
- data/lib/jasmine/base.rb +50 -0
- data/lib/jasmine/command_line_tool.rb +70 -0
- data/lib/jasmine/config.rb +121 -0
- data/lib/jasmine/dependencies.rb +59 -0
- data/lib/jasmine/firebug/firebug-1.6.2.xpi +0 -0
- data/lib/jasmine/firebug/firebug-1.7.0.xpi +0 -0
- data/lib/jasmine/firebug/firebug-license.txt +30 -0
- data/lib/jasmine/firebug/firebug.rb +30 -0
- data/lib/jasmine/page.rb +11 -0
- data/lib/jasmine/railtie.rb +21 -0
- data/lib/jasmine/results.rb +19 -0
- data/lib/jasmine/results_processor.rb +37 -0
- data/lib/jasmine/rspec_formatter.rb +92 -0
- data/lib/jasmine/run.html.erb +55 -0
- data/lib/jasmine/run_specs.rb +32 -0
- data/lib/jasmine/runner_config.rb +71 -0
- data/lib/jasmine/runners/http.rb +71 -0
- data/lib/jasmine/selenium_driver.rb +52 -0
- data/lib/jasmine/server.rb +20 -0
- data/lib/jasmine/sprockets_mapper.rb +13 -0
- data/lib/jasmine/tasks/jasmine.rake +56 -0
- data/lib/jasmine/tasks/jasmine_rails3.rake +1 -0
- data/lib/jasmine/version.rb +3 -0
- data/lib/jasmine.rb +23 -0
- data/lib/rack/jasmine/cache_control.rb +20 -0
- data/lib/rack/jasmine/focused_suite.rb +17 -0
- data/lib/rack/jasmine/redirect.rb +20 -0
- data/lib/rack/jasmine/runner.rb +27 -0
- data/spec/application_spec.rb +99 -0
- data/spec/asset_pipeline_mapper_spec.rb +18 -0
- data/spec/config_spec.rb +309 -0
- data/spec/dependencies_spec.rb +327 -0
- data/spec/fixture/Rakefile +4 -0
- data/spec/fixture/jasmine.erb.yml +4 -0
- data/spec/fixture/spec/example_spec.js +5 -0
- data/spec/fixture/src/example.js +3 -0
- data/spec/jasmine_command_line_tool_rakeless_spec.rb +20 -0
- data/spec/jasmine_command_line_tool_spec.rb +29 -0
- data/spec/jasmine_pojs_spec.rb +47 -0
- data/spec/jasmine_rails2_spec.rb +89 -0
- data/spec/jasmine_rails3_spec.rb +69 -0
- data/spec/jasmine_self_test_config.rb +19 -0
- data/spec/jasmine_self_test_spec.rb +22 -0
- data/spec/page_spec.rb +25 -0
- data/spec/rack/jasmine/runner_spec.rb +25 -0
- data/spec/results_processor_spec.rb +3 -0
- data/spec/results_spec.rb +27 -0
- data/spec/rspec_formatter_spec.rb +88 -0
- data/spec/runner_config_spec.rb +136 -0
- data/spec/server_spec.rb +48 -0
- data/spec/spec_helper.rb +55 -0
- data/spec/sprockets_mapper_spec.rb +17 -0
- metadata +319 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
before_script:
|
2
|
+
- "sh -e /etc/init.d/xvfb start"
|
3
|
+
script: "DISPLAY=:99.0 bundle exec rake"
|
4
|
+
|
5
|
+
rvm:
|
6
|
+
- "1.8.7"
|
7
|
+
- "1.9.2"
|
8
|
+
- "1.9.3"
|
9
|
+
- "ree"
|
10
|
+
- "jruby"
|
11
|
+
- "rbx"
|
12
|
+
|
13
|
+
env:
|
14
|
+
- "RAILS_VERSION=rails2"
|
15
|
+
- "RAILS_VERSION=rails2_3_5"
|
16
|
+
- "RAILS_VERSION=rails3"
|
17
|
+
- "RAILS_VERSION=pojs-rspec1"
|
18
|
+
- "RAILS_VERSION=pojs-rspec2"
|
19
|
+
|
20
|
+
matrix:
|
21
|
+
exclude:
|
22
|
+
- rvm: rbx
|
23
|
+
env: RAILS_VERSION=rails2
|
24
|
+
- rvm: rbx
|
25
|
+
env: RAILS_VERSION=rails2_3_5
|
26
|
+
- rvm: rbx
|
27
|
+
env: RAILS_VERSION=pojs-rspec1
|
28
|
+
- rvm: rbx
|
29
|
+
env: RAILS_VERSION=pojs-rspec2
|
30
|
+
- rvm: jruby
|
31
|
+
env: RAILS_VERSION=rails2
|
32
|
+
- rvm: jruby
|
33
|
+
env: RAILS_VERSION=rails2_3_5
|
34
|
+
- rvm: jruby
|
35
|
+
env: RAILS_VERSION=pojs-rspec1
|
36
|
+
- rvm: jruby
|
37
|
+
env: RAILS_VERSION=pojs-rspec2
|
38
|
+
- rvm: 1.9.2
|
39
|
+
env: RAILS_VERSION=rails2
|
40
|
+
- rvm: 1.9.2
|
41
|
+
env: RAILS_VERSION=rails2_3_5
|
42
|
+
- rvm: 1.9.2
|
43
|
+
env: RAILS_VERSION=pojs-rspec1
|
44
|
+
- rvm: 1.9.2
|
45
|
+
env: RAILS_VERSION=pojs-rspec2
|
46
|
+
- rvm: ree
|
47
|
+
env: RAILS_VERSION=pojs-rspec2
|
48
|
+
- rvm: 1.8.7
|
49
|
+
env: RAILS_VERSION=rails2
|
50
|
+
- rvm: 1.8.7
|
51
|
+
env: RAILS_VERSION=rails2_3_5
|
52
|
+
- rvm: 1.8.7
|
53
|
+
env: RAILS_VERSION=pojs-rspec1
|
54
|
+
- rvm: 1.8.7
|
55
|
+
env: RAILS_VERSION=pojs-rspec2
|
56
|
+
allow_failures:
|
57
|
+
- rvm: rbx
|
58
|
+
- rvm: jruby
|
data/Gemfile
ADDED
@@ -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,77 @@
|
|
1
|
+
# The Jasmine Gem <a title="Build at Travis CI" href="http://travis-ci.org/#!/pivotal/jasmine-gem"><img src="https://secure.travis-ci.org/pivotal/jasmine-gem.png" /></a>
|
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
|
+
Start Jasmine on a different port:
|
40
|
+
|
41
|
+
`rake jasmine JASMINE_PORT=1337`
|
42
|
+
|
43
|
+
Point your browser to `localhost:1337`.
|
44
|
+
|
45
|
+
For Continuous Integration environments, add this task to the project build steps:
|
46
|
+
|
47
|
+
`rake jasmine:ci`
|
48
|
+
|
49
|
+
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. The browser used by selenium can be changed by setting the JASMINE_BROWSER environment variable (this might require additional webdriver dependencies).
|
50
|
+
|
51
|
+
## Configuration
|
52
|
+
|
53
|
+
Customize `spec/javascripts/support/jasmine.yml` to enumerate the source files, stylesheets, and spec files you would like the Jasmine runner to include.
|
54
|
+
You may use dir glob strings.
|
55
|
+
|
56
|
+
For more complex configuration (e.g., port number), edit `spec/javascripts/support/jasmine_config.rb` file directly.
|
57
|
+
|
58
|
+
## Note about the CI task and RSpec
|
59
|
+
|
60
|
+
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.
|
61
|
+
|
62
|
+
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.
|
63
|
+
|
64
|
+
If you're using another Ruby framework, or don't care about Ruby, then run
|
65
|
+
|
66
|
+
`gem install rspec`
|
67
|
+
|
68
|
+
before you attempt the CI task.
|
69
|
+
|
70
|
+
## Support
|
71
|
+
|
72
|
+
Jasmine Mailing list: [jasmine-js@googlegroups.com](mailto:jasmine-js@googlegroups.com)
|
73
|
+
Twitter: [@jasminebdd](http://twitter.com/jasminebdd)
|
74
|
+
|
75
|
+
Please file issues here at Github
|
76
|
+
|
77
|
+
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,53 @@
|
|
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::GemHelper.install_tasks
|
5
|
+
|
6
|
+
require "jasmine"
|
7
|
+
if Jasmine::Dependencies.rspec2?
|
8
|
+
require 'rspec'
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
else
|
11
|
+
require 'spec'
|
12
|
+
require 'spec/rake/spectask'
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Run all examples"
|
16
|
+
if Jasmine::Dependencies.rspec2?
|
17
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
18
|
+
t.pattern = 'spec/**/*_spec.rb'
|
19
|
+
end
|
20
|
+
else
|
21
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
22
|
+
t.spec_files = FileList['spec/**/*.rb']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
task :spec => ['jasmine:copy_examples_to_gem']
|
27
|
+
|
28
|
+
task :default => :spec
|
29
|
+
|
30
|
+
namespace :jasmine do
|
31
|
+
require "jasmine-core"
|
32
|
+
require './spec/jasmine_self_test_config'
|
33
|
+
task :server do
|
34
|
+
port = ENV['JASMINE_PORT'] || 8888
|
35
|
+
JasmineSelfTestConfig.new.start_server(port)
|
36
|
+
|
37
|
+
puts "your tests are here:"
|
38
|
+
puts " http://localhost:#{port}/"
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Copy examples from Jasmine JS to the gem"
|
42
|
+
task :copy_examples_to_gem do
|
43
|
+
require "fileutils"
|
44
|
+
|
45
|
+
# copy jasmine's example tree into our generator templates dir
|
46
|
+
FileUtils.rm_r('generators/jasmine/templates/jasmine-example', :force => true)
|
47
|
+
FileUtils.cp_r(File.join(Jasmine::Core.path, 'example'), 'generators/jasmine/templates/jasmine-example', :preserve => true)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "Run specs via server"
|
52
|
+
task :jasmine => ['jasmine:server']
|
53
|
+
|
data/bin/jasmine
ADDED
@@ -0,0 +1,24 @@
|
|
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-rails.yml", "spec/javascripts/support/jasmine.yml"
|
17
|
+
m.readme "INSTALL"
|
18
|
+
|
19
|
+
m.directory "lib/tasks"
|
20
|
+
m.file "lib/tasks/jasmine.rake", "lib/tasks/jasmine.rake"
|
21
|
+
m
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,54 @@
|
|
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 Spec Runner</title>
|
6
|
+
|
7
|
+
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.1.0.rc1/jasmine_favicon.png">
|
8
|
+
|
9
|
+
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.1.0.rc1/jasmine.css">
|
10
|
+
<script type="text/javascript" src="lib/jasmine-1.1.0.rc1/jasmine.js"></script>
|
11
|
+
<script type="text/javascript" src="lib/jasmine-1.1.0.rc1/jasmine-html.js"></script>
|
12
|
+
|
13
|
+
<!-- include spec files here... -->
|
14
|
+
<script type="text/javascript" src="spec/SpecHelper.js"></script>
|
15
|
+
<script type="text/javascript" src="spec/PlayerSpec.js"></script>
|
16
|
+
|
17
|
+
<!-- include source files here... -->
|
18
|
+
<script type="text/javascript" src="src/Player.js"></script>
|
19
|
+
<script type="text/javascript" src="src/Song.js"></script>
|
20
|
+
|
21
|
+
<script type="text/javascript">
|
22
|
+
(function() {
|
23
|
+
var jasmineEnv = jasmine.getEnv();
|
24
|
+
jasmineEnv.updateInterval = 1000;
|
25
|
+
|
26
|
+
var trivialReporter = new jasmine.TrivialReporter();
|
27
|
+
|
28
|
+
jasmineEnv.addReporter(trivialReporter);
|
29
|
+
|
30
|
+
jasmineEnv.specFilter = function(spec) {
|
31
|
+
return trivialReporter.specFilter(spec);
|
32
|
+
};
|
33
|
+
|
34
|
+
var currentWindowOnload = window.onload;
|
35
|
+
|
36
|
+
window.onload = function() {
|
37
|
+
if (currentWindowOnload) {
|
38
|
+
currentWindowOnload();
|
39
|
+
}
|
40
|
+
execJasmine();
|
41
|
+
};
|
42
|
+
|
43
|
+
function execJasmine() {
|
44
|
+
jasmineEnv.execute();
|
45
|
+
}
|
46
|
+
|
47
|
+
})();
|
48
|
+
</script>
|
49
|
+
|
50
|
+
</head>
|
51
|
+
|
52
|
+
<body>
|
53
|
+
</body>
|
54
|
+
</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,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,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,11 @@
|
|
1
|
+
Description:
|
2
|
+
Install jasmine examples
|
3
|
+
|
4
|
+
Example:
|
5
|
+
rails generate jasmine:examples
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
public/javascripts/jasmine_examples/PlayerSpec.js
|
9
|
+
public/javascripts/jasmine_examples/SpecHelper.js
|
10
|
+
spec/javascripts/jasmine_examples/PlayerSpec.js
|
11
|
+
spec/javascripts/jasmine_examples/SpecHelper.js
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Jasmine
|
2
|
+
module Generators
|
3
|
+
class ExamplesGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
def self.source_root
|
6
|
+
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
7
|
+
end
|
8
|
+
|
9
|
+
def copy_example_files
|
10
|
+
directory 'app'
|
11
|
+
directory 'spec'
|
12
|
+
end
|
13
|
+
|
14
|
+
def app_name
|
15
|
+
Rails.application.class.name
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|