jasmine 1.3.2 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +3 -37
  3. data/Gemfile +11 -2
  4. data/HOW_TO_TEST.markdown +1 -1
  5. data/README.markdown +10 -10
  6. data/Rakefile +18 -29
  7. data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +2 -2
  8. data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +14 -8
  9. data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +3 -3
  10. data/generators/jasmine/templates/spec/javascripts/support/jasmine_helper.rb +1 -0
  11. data/jasmine.gemspec +11 -41
  12. data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +15 -9
  13. data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +1 -1
  14. data/lib/jasmine.rb +10 -7
  15. data/lib/jasmine/asset_bundle.rb +69 -0
  16. data/lib/jasmine/asset_expander.rb +7 -7
  17. data/lib/jasmine/command_line_tool.rb +18 -0
  18. data/lib/jasmine/config.rb +23 -15
  19. data/lib/jasmine/configuration.rb +14 -8
  20. data/lib/jasmine/core_configuration.rb +7 -4
  21. data/lib/jasmine/dependencies.rb +14 -18
  22. data/lib/jasmine/formatters/base.rb +9 -0
  23. data/lib/jasmine/formatters/console.rb +45 -0
  24. data/lib/jasmine/formatters/junit_xml.rb +47 -0
  25. data/lib/jasmine/path_expander.rb +1 -1
  26. data/lib/jasmine/railtie.rb +7 -6
  27. data/lib/jasmine/reporters/api_reporter.rb +38 -0
  28. data/lib/jasmine/results.rb +28 -9
  29. data/lib/jasmine/results_processor.rb +1 -1
  30. data/lib/jasmine/run.html.erb +1 -1
  31. data/lib/jasmine/run_specs.rb +12 -15
  32. data/lib/jasmine/runners/http.rb +11 -49
  33. data/lib/jasmine/selenium_driver.rb +17 -14
  34. data/lib/jasmine/tasks/jasmine.rake +21 -30
  35. data/lib/jasmine/tasks/{jasmine_rails3.rake → jasmine_rails.rake} +0 -0
  36. data/lib/jasmine/version.rb +1 -1
  37. data/lib/jasmine/yaml_config_parser.rb +9 -0
  38. data/release_notes/v2.0.0.rc2.md +44 -0
  39. data/spec/application_spec.rb +33 -38
  40. data/spec/asset_expander_spec.rb +4 -32
  41. data/spec/configuration_spec.rb +95 -35
  42. data/spec/jasmine_command_line_tool_spec.rb +63 -11
  43. data/spec/jasmine_rails_spec.rb +94 -0
  44. data/spec/lib/jasmine/formatters/base_spec.rb +9 -0
  45. data/spec/lib/jasmine/formatters/console_spec.rb +92 -0
  46. data/spec/lib/jasmine/formatters/junit_xml_spec.rb +55 -0
  47. data/spec/lib/jasmine/reporters/api_reporter_spec.rb +53 -0
  48. data/spec/lib/jasmine/runners/http_spec.rb +21 -0
  49. data/spec/path_expander_spec.rb +25 -0
  50. data/spec/results_spec.rb +59 -17
  51. data/spec/spec_helper.rb +36 -18
  52. data/spec/support/fake_selenium_driver.rb +35 -0
  53. data/spec/yaml_config_parser_spec.rb +37 -0
  54. metadata +65 -103
  55. data/generators/jasmine/templates/jasmine-example/SpecRunner.html +0 -54
  56. data/lib/jasmine/asset_pipeline_utility.rb +0 -19
  57. data/lib/jasmine/javascripts/boot.js +0 -28
  58. data/lib/jasmine/rspec_formatter.rb +0 -92
  59. data/spec/dependencies_spec.rb +0 -315
  60. data/spec/jasmine_rails2_spec.rb +0 -89
  61. data/spec/jasmine_rails3_spec.rb +0 -69
  62. data/spec/jasmine_self_test_spec.rb +0 -29
  63. data/spec/rspec_formatter_spec.rb +0 -88
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 829cb8b7df0ab6b49277bd1ff57726df9def1ad5
4
+ data.tar.gz: 8b35c826f0dce1001cfb2f572139b104f1d0cfa8
5
+ SHA512:
6
+ metadata.gz: c88cd5229bba530394d60d17a6221812e71623b9f44f88ff4d480280a7c0a92ca29942635bbb02b5c89b0eb386bfd79ba01f4a7b053d8f3628be13cab48dd9f1
7
+ data.tar.gz: ca5e0e70008293b2c96f142df85aa0d7a014a7dfea1a71c93151d13115c81f746210e6698b1da7dacbdab2d2b72bf400546b33822ce700ea4880c137dbff65cc
data/.travis.yml CHANGED
@@ -3,55 +3,21 @@ before_script:
3
3
  script: "DISPLAY=:99.0 bundle exec rake"
4
4
 
5
5
  rvm:
6
- - "1.8.7"
7
- - "1.9.2"
8
6
  - "1.9.3"
9
- - "ree"
7
+ - "2.0.0"
10
8
  - "jruby"
11
- - "rbx"
9
+ - "rbx-19mode"
12
10
 
13
11
  env:
14
- - "RAILS_VERSION=rails2"
15
- - "RAILS_VERSION=rails2_3_5"
16
12
  - "RAILS_VERSION=rails3"
17
- - "RAILS_VERSION=pojs-rspec1"
13
+ - "RAILS_VERSION=rails4"
18
14
  - "RAILS_VERSION=pojs-rspec2"
19
15
 
20
16
  matrix:
21
17
  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
18
  - rvm: rbx
29
19
  env: RAILS_VERSION=pojs-rspec2
30
20
  - 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
21
  env: RAILS_VERSION=pojs-rspec2
56
22
  allow_failures:
57
23
  - rvm: rbx
data/Gemfile CHANGED
@@ -1,8 +1,17 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
+
2
3
  gemspec
3
4
 
4
- unless ENV["TRAVIS"]
5
+ unless ENV['TRAVIS']
5
6
  group :debug do
6
7
  gem 'debugger'
7
8
  end
8
9
  end
10
+
11
+
12
+ # during development, do not release
13
+ if ENV['TRAVIS']
14
+ gem 'jasmine-core', :git => 'http://github.com/pivotal/jasmine.git'
15
+ else
16
+ gem 'jasmine-core', :path => '../jasmine'
17
+ end
data/HOW_TO_TEST.markdown CHANGED
@@ -1,6 +1,6 @@
1
1
  To test changes to the jasmine-gem:
2
2
 
3
- * Export RAILS_VERSION as either "pojs-rspec1", "pojs-rspec2", or "rails2" to test environments other than Rails 3.
3
+ * Export RAILS_VERSION as either "pojs-rspec2", or "rails3" to test environments other than Rails 4.
4
4
  * Delete `Gemfile.lock`
5
5
  * Clear out your current gemset
6
6
  * exec a `bundle install`
data/README.markdown CHANGED
@@ -7,19 +7,19 @@ This gem contains:
7
7
 
8
8
  * A small server that builds and executes a Jasmine suite for a project
9
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)
10
+ * Generators for Ruby on Rails projects (Rails 3 and Rails 4)
11
11
 
12
12
  You can get all of this by: `gem install jasmine` or by adding Jasmine to your `Gemfile`.
13
13
 
14
- ## Init A Project
15
-
16
- To initialize a project for Jasmine, it depends on your web framework
14
+ ```ruby
15
+ group :development, :test do
16
+ gem 'jasmine'
17
+ end
18
+ ```
17
19
 
18
- For Rails2 support, use
19
-
20
- `script/generate jasmine`
20
+ ## Init A Project
21
21
 
22
- For Rails3 support, use
22
+ To initialize a project for Jasmine
23
23
 
24
24
  `rails g jasmine:install`
25
25
  `rails g jasmine:examples`
@@ -46,7 +46,7 @@ For Continuous Integration environments, add this task to the project build step
46
46
 
47
47
  `rake jasmine:ci`
48
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).
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 configuration in spec_helper file (this might require additional webdriver dependencies).
50
50
 
51
51
  ## Configuration
52
52
 
@@ -72,4 +72,4 @@ Twitter: [@jasminebdd](http://twitter.com/jasminebdd)
72
72
 
73
73
  Please file issues here at Github
74
74
 
75
- Copyright (c) 2008-2010 Pivotal Labs. This software is licensed under the MIT License.
75
+ Copyright (c) 2008-2013 Pivotal Labs. This software is licensed under the MIT License.
data/Rakefile CHANGED
@@ -1,55 +1,44 @@
1
1
  $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/lib")
3
- require "bundler"
3
+ require 'bundler'
4
4
  Bundler::GemHelper.install_tasks
5
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
6
+ require 'jasmine'
7
+ require 'rspec'
8
+ require 'rspec/core/rake_task'
14
9
 
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
10
+ desc 'Run all examples'
11
+ RSpec::Core::RakeTask.new(:spec) do |t|
12
+ t.pattern = 'spec/**/*_spec.rb'
24
13
  end
25
14
 
26
- task :spec => ['jasmine:copy_examples_to_gem']
15
+ task :spec => %w(jasmine:copy_examples_to_gem)
27
16
 
28
17
  task :default => :spec
29
18
 
30
19
  namespace :jasmine do
31
- require "jasmine-core"
20
+ require 'jasmine-core'
32
21
  task :server do
33
- port = ENV['JASMINE_PORT'] || 8888
34
22
  Jasmine.configure do |config|
35
- root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
23
+ root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
36
24
  config.src_dir = File.join(root, 'src')
37
25
  config.spec_dir = Jasmine::Core.path
38
26
  config.spec_files = lambda { (Jasmine::Core.html_spec_files + Jasmine::Core.core_spec_files).map {|f| File.join(config.spec_dir, f) } }
27
+ config.jasmine_port = ENV['JASMINE_PORT'] || 8888
39
28
  end
40
29
 
41
30
  config = Jasmine.config
42
31
 
43
- server = Jasmine::Server.new(8888, Jasmine::Application.app(config))
32
+ server = Jasmine::Server.new(config.jasmine_port, Jasmine::Application.app(config))
44
33
  server.start
45
34
 
46
- puts "your tests are here:"
47
- puts " http://localhost:#{port}/"
35
+ puts 'your tests are here:'
36
+ puts " http://localhost:#{config.jasmine_port}/"
48
37
  end
49
38
 
50
- desc "Copy examples from Jasmine JS to the gem"
39
+ desc 'Copy examples from Jasmine JS to the gem'
51
40
  task :copy_examples_to_gem do
52
- require "fileutils"
41
+ require 'fileutils'
53
42
 
54
43
  # copy jasmine's example tree into our generator templates dir
55
44
  FileUtils.rm_r('generators/jasmine/templates/jasmine-example', :force => true)
@@ -57,6 +46,6 @@ namespace :jasmine do
57
46
  end
58
47
  end
59
48
 
60
- desc "Run specs via server"
61
- task :jasmine => ['jasmine:server']
49
+ desc 'Run specs via server'
50
+ task :jasmine => %w(jasmine:server)
62
51
 
@@ -52,7 +52,7 @@ describe("Player", function() {
52
52
 
53
53
  expect(function() {
54
54
  player.resume();
55
- }).toThrow("song is already playing");
55
+ }).toThrowError("song is already playing");
56
56
  });
57
57
  });
58
- });
58
+ });
@@ -1,9 +1,15 @@
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
- });
1
+ beforeEach(function () {
2
+ jasmine.Expectation.addMatchers({
3
+ toBePlaying: function () {
4
+ return {
5
+ compare: function (actual, expected) {
6
+ var player = actual;
7
+
8
+ return {
9
+ pass: player.currentlyPlayingSong === expected && player.isPlaying
10
+ }
11
+ }
12
+ };
13
+ }
14
+ });
9
15
  });
@@ -77,12 +77,12 @@ spec_dir:
77
77
  #
78
78
  # Ruby file that Jasmine server will require before starting.
79
79
  # Returned relative to your root path
80
- # Default spec/support/jasmine_helper.rb
80
+ # Default spec/javascripts/support/jasmine_helper.rb
81
81
  #
82
82
  # EXAMPLE:
83
83
  #
84
- # spec_helper: spec/support/jasmine_helper.rb
84
+ # spec_helper: spec/javascripts/support/jasmine_helper.rb
85
85
  #
86
- spec_helper: spec/support/jasmine_helper.rb
86
+ spec_helper: spec/javascripts/support/jasmine_helper.rb
87
87
 
88
88
 
@@ -6,6 +6,7 @@
6
6
  #Jasmine.configure do |config|
7
7
  # config.boot_dir = '/absolute/path/to/boot_dir'
8
8
  # config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] }
9
+ # config.browser = :firefox
9
10
  #end
10
11
  #
11
12
 
data/jasmine.gemspec CHANGED
@@ -20,57 +20,27 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
  s.rdoc_options = ["--charset=UTF-8"]
22
22
 
23
- if ENV['RAILS_VERSION'] == 'pojs-rspec1'
24
- if ENV["RUBY_VERSION"] =~ /1\.8\.6/
25
- #1.3.2 buffer overflows
26
- s.add_development_dependency 'rspec', '= 1.3.1'
27
- s.add_development_dependency 'rack', "1.1"
28
- else
29
- s.add_development_dependency 'rspec', '>= 1.3.1', '< 2'
30
- end
31
- s.add_development_dependency 'rake-tasks'
32
- elsif ENV['RAILS_VERSION'] == 'pojs-rspec2'
33
- if ENV["RUBY_VERSION"] =~ /1\.8\.6/
34
- #2.7.0 uses reduce vs inject, non 1.8.6 compatible
35
- s.add_development_dependency 'rspec', '2.6.0'
36
- else
37
- s.add_development_dependency 'rspec', '>= 2.5.0'
38
- end
23
+ if ENV['RAILS_VERSION'] == 'pojs-rspec2'
24
+ s.add_development_dependency 'rspec', '>= 2.5.0'
39
25
  s.add_development_dependency 'rake-tasks'
40
- s.add_development_dependency 'rack', "1.1" if ENV["RUBY_VERSION"] =~ /1\.8\.6/
41
- elsif ENV['RAILS_VERSION'] == 'rails2'
42
- if ENV["RUBY_VERSION"] =~ /1\.8\.6/
43
- #1.3.2 buffer overflows
44
- s.add_development_dependency 'rspec', '= 1.3.1'
45
- else
46
- s.add_development_dependency 'rspec', '>= 1.3.1', '< 2'
47
- end
48
- # for development & test of Rails 2 Generators
49
- s.add_development_dependency 'rails', '2.3.11', "< 3"
50
- elsif ENV['RAILS_VERSION'] == 'rails2_3_5'
51
- if ENV["RUBY_VERSION"] =~ /1\.8\.6/
52
- #1.3.2 buffer overflows
53
- s.add_development_dependency 'rspec', '= 1.3.1'
54
- else
55
- s.add_development_dependency 'rspec', '>= 1.3.1', '< 2'
56
- end
57
- # for development & test of Rails 2 Generators
58
- s.add_development_dependency 'rails', '= 2.3.5'
59
- else
26
+ elsif ENV['RAILS_VERSION'] == 'rails3'
60
27
  # for development & test of Rails 3 Generators
61
28
  s.add_development_dependency 'rspec', '>= 2.5.0'
62
- s.add_development_dependency 'rails', '>= 3.0.0'
63
- s.add_development_dependency 'rack', '>= 1.2.1'
29
+ s.add_development_dependency 'rails', '>= 3.0.0', '< 4.0.0'
30
+ s.add_development_dependency 'sqlite3'
31
+ else
32
+ s.add_development_dependency 'rspec', '>= 2.5.0'
33
+ s.add_development_dependency 'rails', '>= 4'
64
34
  end
65
35
 
66
36
  s.add_development_dependency 'rack-test'
67
37
  s.add_development_dependency 'json_pure'
68
- s.add_development_dependency 'nokogiri'
69
38
 
70
39
  s.add_development_dependency 'anchorman'
71
40
 
72
- s.add_dependency 'jasmine-core', "~> 1.3.1"
73
- s.add_dependency 'rack', '~> 1.0'
41
+ s.add_dependency 'jasmine-core', '~> 2.0.0.alpha'
42
+ s.add_dependency 'rack'
74
43
  s.add_dependency 'rspec', '>= 1.3.1'
75
44
  s.add_dependency 'selenium-webdriver', '>= 0.1.3'
45
+ s.add_dependency 'nokogiri'
76
46
  end
@@ -1,9 +1,15 @@
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
- });
1
+ beforeEach(function () {
2
+ jasmine.Expectation.addMatchers({
3
+ toBePlaying: function () {
4
+ return {
5
+ compare: function (actual, expected) {
6
+ var player = actual;
7
+
8
+ return {
9
+ pass: player.currentlyPlayingSong === expected && player.isPlaying
10
+ }
11
+ }
12
+ };
13
+ }
14
+ });
15
+ });
@@ -52,7 +52,7 @@ describe("Player", function() {
52
52
 
53
53
  expect(function() {
54
54
  player.resume();
55
- }).toThrow("song is already playing");
55
+ }).toThrowError("song is already playing");
56
56
  });
57
57
  });
58
58
  });
data/lib/jasmine.rb CHANGED
@@ -6,26 +6,29 @@ jasmine_files = ['base',
6
6
  'application',
7
7
  'server',
8
8
  'selenium_driver',
9
- 'rspec_formatter',
10
9
  'command_line_tool',
11
10
  'page',
12
11
  'path_mapper',
13
- 'asset_pipeline_utility',
12
+ 'asset_bundle',
14
13
  'asset_pipeline_mapper',
15
14
  'asset_expander',
16
15
  'results_processor',
17
16
  'results',
18
17
  'path_expander',
19
18
  'yaml_config_parser',
20
- File.join('runners', 'http')]
19
+ File.join('formatters', 'base'),
20
+ File.join('formatters', 'console'),
21
+ File.join('formatters', 'junit_xml'),
22
+ File.join('runners', 'http'),
23
+ File.join('reporters', 'api_reporter')]
24
+
21
25
 
22
26
  jasmine_files.each do |file|
23
27
  require File.join('jasmine', file)
24
28
  end
25
- # jasmine_rack_files.each do |file|
26
- # require File.join('rack', 'jasmine', file)
27
- # end
28
29
 
29
- require File.join('jasmine', "railtie") if Jasmine::Dependencies.rails3?
30
+ if Jasmine::Dependencies.rails?
31
+ require File.join('jasmine', 'railtie')
32
+ end
30
33
 
31
34
 
@@ -0,0 +1,69 @@
1
+ module Jasmine
2
+
3
+ class AssetBundle
4
+ def self.factory
5
+ if Jasmine::Dependencies.rails3?
6
+ return Rails3AssetBundle
7
+ end
8
+ if Jasmine::Dependencies.rails4?
9
+ return Rails4AssetBundle
10
+ end
11
+ end
12
+
13
+ class RailsAssetBundle
14
+ def initialize(pathname)
15
+ @pathname = pathname
16
+ end
17
+
18
+ private
19
+
20
+ attr_reader :pathname
21
+ end
22
+
23
+ class Rails3AssetBundle < RailsAssetBundle
24
+
25
+ def assets
26
+ context = get_asset_context
27
+ context.asset_paths.asset_for(pathname, 'js').to_a.map do |path|
28
+ context.asset_path(path)
29
+ end
30
+ end
31
+
32
+ private
33
+ def get_asset_context
34
+ context = ::Rails.application.assets.context_class
35
+ context.extend(::Sprockets::Helpers::IsolatedHelper)
36
+ context.extend(::Sprockets::Helpers::RailsHelper)
37
+ end
38
+ end
39
+
40
+ class Rails4AssetBundle
41
+
42
+ def initialize(pathname)
43
+ @pathname = pathname
44
+ end
45
+
46
+ def assets
47
+ context.get_original_assets(pathname)
48
+ end
49
+
50
+ private
51
+ attr_reader :pathname
52
+
53
+ def context
54
+ return @context if @context
55
+ @context = ActionView::Base.new
56
+ @context.instance_eval do
57
+ def get_original_assets(pathname)
58
+ lookup_asset_for_path(pathname, :type => :javascript).to_a.map do |processed_asset|
59
+ path_to_javascript(processed_asset.logical_path)
60
+ end
61
+ end
62
+ end
63
+ @context
64
+
65
+ end
66
+ end
67
+ end
68
+
69
+ end