jasmine-multi_json 1.3.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/.gitignore +13 -0
  2. data/.rspec +1 -0
  3. data/.travis.yml +58 -0
  4. data/Gemfile +8 -0
  5. data/HOW_TO_TEST.markdown +9 -0
  6. data/MIT.LICENSE +20 -0
  7. data/README.markdown +77 -0
  8. data/RELEASE.markdown +22 -0
  9. data/RELEASE_NOTES.markdown +6 -0
  10. data/Rakefile +62 -0
  11. data/generators/jasmine/jasmine_generator.rb +24 -0
  12. data/generators/jasmine/templates/INSTALL +9 -0
  13. data/generators/jasmine/templates/jasmine-example/SpecRunner.html +54 -0
  14. data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +58 -0
  15. data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +9 -0
  16. data/generators/jasmine/templates/jasmine-example/src/Player.js +22 -0
  17. data/generators/jasmine/templates/jasmine-example/src/Song.js +7 -0
  18. data/generators/jasmine/templates/lib/tasks/jasmine.rake +8 -0
  19. data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
  20. data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +74 -0
  21. data/jasmine.gemspec +74 -0
  22. data/lib/generators/jasmine/examples/USAGE +11 -0
  23. data/lib/generators/jasmine/examples/examples_generator.rb +19 -0
  24. data/lib/generators/jasmine/examples/templates/app/assets/javascripts/jasmine_examples/Player.js +22 -0
  25. data/lib/generators/jasmine/examples/templates/app/assets/javascripts/jasmine_examples/Song.js +7 -0
  26. data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +9 -0
  27. data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +58 -0
  28. data/lib/generators/jasmine/install/USAGE +11 -0
  29. data/lib/generators/jasmine/install/install_generator.rb +18 -0
  30. data/lib/generators/jasmine/install/templates/spec/javascripts/helpers/.gitkeep +0 -0
  31. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +76 -0
  32. data/lib/jasmine.rb +31 -0
  33. data/lib/jasmine/application.rb +21 -0
  34. data/lib/jasmine/asset_expander.rb +19 -0
  35. data/lib/jasmine/asset_pipeline_mapper.rb +16 -0
  36. data/lib/jasmine/asset_pipeline_utility.rb +19 -0
  37. data/lib/jasmine/base.rb +54 -0
  38. data/lib/jasmine/command_line_tool.rb +70 -0
  39. data/lib/jasmine/config.rb +85 -0
  40. data/lib/jasmine/configuration.rb +83 -0
  41. data/lib/jasmine/core_configuration.rb +28 -0
  42. data/lib/jasmine/dependencies.rb +59 -0
  43. data/lib/jasmine/firebug/firebug-1.6.2.xpi +0 -0
  44. data/lib/jasmine/firebug/firebug-1.7.0.xpi +0 -0
  45. data/lib/jasmine/firebug/firebug-license.txt +30 -0
  46. data/lib/jasmine/firebug/firebug.rb +30 -0
  47. data/lib/jasmine/javascripts/boot.js +28 -0
  48. data/lib/jasmine/page.rb +11 -0
  49. data/lib/jasmine/path_expander.rb +18 -0
  50. data/lib/jasmine/path_mapper.rb +29 -0
  51. data/lib/jasmine/railtie.rb +21 -0
  52. data/lib/jasmine/results.rb +19 -0
  53. data/lib/jasmine/results_processor.rb +38 -0
  54. data/lib/jasmine/rspec_formatter.rb +92 -0
  55. data/lib/jasmine/run.html.erb +18 -0
  56. data/lib/jasmine/run_specs.rb +36 -0
  57. data/lib/jasmine/runners/http.rb +71 -0
  58. data/lib/jasmine/selenium_driver.rb +41 -0
  59. data/lib/jasmine/server.rb +20 -0
  60. data/lib/jasmine/tasks/jasmine.rake +55 -0
  61. data/lib/jasmine/tasks/jasmine_rails3.rake +1 -0
  62. data/lib/jasmine/version.rb +3 -0
  63. data/lib/jasmine/yaml_config_parser.rb +54 -0
  64. data/lib/rack/jasmine/cache_control.rb +20 -0
  65. data/lib/rack/jasmine/focused_suite.rb +17 -0
  66. data/lib/rack/jasmine/runner.rb +27 -0
  67. data/spec/application_integration_spec.rb +15 -0
  68. data/spec/application_spec.rb +44 -0
  69. data/spec/asset_expander_spec.rb +42 -0
  70. data/spec/asset_pipeline_mapper_spec.rb +19 -0
  71. data/spec/base_spec.rb +14 -0
  72. data/spec/configuration_spec.rb +163 -0
  73. data/spec/dependencies_spec.rb +315 -0
  74. data/spec/fixture/Rakefile +4 -0
  75. data/spec/jasmine_command_line_tool_rakeless_spec.rb +20 -0
  76. data/spec/jasmine_command_line_tool_spec.rb +29 -0
  77. data/spec/jasmine_pojs_spec.rb +47 -0
  78. data/spec/jasmine_rails2_spec.rb +89 -0
  79. data/spec/jasmine_rails3_spec.rb +69 -0
  80. data/spec/jasmine_self_test_spec.rb +29 -0
  81. data/spec/page_spec.rb +23 -0
  82. data/spec/path_expander_spec.rb +96 -0
  83. data/spec/path_mapper_spec.rb +33 -0
  84. data/spec/rack/jasmine/runner_spec.rb +25 -0
  85. data/spec/results_processor_spec.rb +3 -0
  86. data/spec/results_spec.rb +27 -0
  87. data/spec/rspec_formatter_spec.rb +88 -0
  88. data/spec/server_spec.rb +48 -0
  89. data/spec/spec_helper.rb +55 -0
  90. data/spec/yaml_config_parser_spec.rb +182 -0
  91. metadata +310 -0
@@ -0,0 +1,13 @@
1
+ .idea
2
+ pkg
3
+ bin
4
+ !bin/jasmine
5
+ .bundle
6
+ .DS_Store
7
+ .rvmrc
8
+ .pairs
9
+ *.swp
10
+ tags
11
+ Gemfile.lock
12
+ spec/reports
13
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -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,8 @@
1
+ source "http://rubygems.org"
2
+ gemspec
3
+
4
+ unless ENV["TRAVIS"]
5
+ group :debug do
6
+ gem 'debugger'
7
+ end
8
+ end
@@ -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
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008-2012 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,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.
@@ -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
@@ -0,0 +1,6 @@
1
+ #1.2.1
2
+
3
+ * asset manifests following the Rails defaults are included as individual src files
4
+ * Fix regression that required Jasmine restart to find new src/spec files
5
+ * Fixes compatibility with rspec > 2.1.0
6
+ * Internal refactorings/cleanup
@@ -0,0 +1,62 @@
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
+ task :server do
33
+ port = ENV['JASMINE_PORT'] || 8888
34
+ Jasmine.configure do |config|
35
+ root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
36
+ config.src_dir = File.join(root, 'src')
37
+ config.spec_dir = Jasmine::Core.path
38
+ config.spec_files = lambda { (Jasmine::Core.html_spec_files + Jasmine::Core.core_spec_files).map {|f| File.join(config.spec_dir, f) } }
39
+ end
40
+
41
+ config = Jasmine.config
42
+
43
+ server = Jasmine::Server.new(8888, Jasmine::Application.app(config))
44
+ server.start
45
+
46
+ puts "your tests are here:"
47
+ puts " http://localhost:#{port}/"
48
+ end
49
+
50
+ desc "Copy examples from Jasmine JS to the gem"
51
+ task :copy_examples_to_gem do
52
+ require "fileutils"
53
+
54
+ # copy jasmine's example tree into our generator templates dir
55
+ FileUtils.rm_r('generators/jasmine/templates/jasmine-example', :force => true)
56
+ FileUtils.cp_r(File.join(Jasmine::Core.path, 'example'), 'generators/jasmine/templates/jasmine-example', :preserve => true)
57
+ end
58
+ end
59
+
60
+ desc "Run specs via server"
61
+ task :jasmine => ['jasmine:server']
62
+
@@ -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,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,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,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
+ });