jasmine 2.0.0 → 2.99.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +27 -13
  3. data/Gemfile +9 -9
  4. data/HOW_TO_TEST.markdown +1 -0
  5. data/README.markdown +18 -11
  6. data/jasmine.gemspec +14 -6
  7. data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/jasmine_examples/SpecHelper.js +1 -1
  8. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +38 -5
  9. data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_helper.rb +14 -9
  10. data/lib/jasmine/application.rb +2 -2
  11. data/lib/jasmine/asset_expander.rb +56 -8
  12. data/lib/jasmine/base.rb +5 -5
  13. data/lib/jasmine/ci_runner.rb +50 -0
  14. data/lib/jasmine/command_line_tool.rb +4 -4
  15. data/lib/jasmine/config.rb +34 -5
  16. data/lib/jasmine/configuration.rb +31 -11
  17. data/lib/jasmine/dependencies.rb +8 -37
  18. data/lib/jasmine/formatters/console.rb +69 -4
  19. data/lib/jasmine/formatters/exit_code.rb +4 -6
  20. data/lib/jasmine/formatters/multi.rb +3 -11
  21. data/lib/jasmine/path_expander.rb +5 -1
  22. data/lib/jasmine/path_mapper.rb +11 -2
  23. data/lib/jasmine/railtie.rb +1 -1
  24. data/lib/jasmine/result.rb +21 -9
  25. data/lib/jasmine/ruby_versions.rb +11 -0
  26. data/lib/jasmine/run.html.erb +1 -1
  27. data/lib/jasmine/runners/phantom_boot.js +15 -0
  28. data/lib/jasmine/runners/phantom_jasmine_run.js +39 -43
  29. data/lib/jasmine/runners/phantom_js.rb +53 -8
  30. data/lib/jasmine/server.rb +7 -10
  31. data/lib/jasmine/tasks/jasmine.rake +29 -25
  32. data/lib/jasmine/version.rb +1 -1
  33. data/lib/jasmine/yaml_config_parser.rb +28 -0
  34. data/lib/jasmine.rb +1 -1
  35. data/release_notes/v2.0.1.md +31 -0
  36. data/release_notes/v2.0.2.md +17 -0
  37. data/release_notes/v2.0.3.md +31 -0
  38. data/release_notes/v2.1.0.md +11 -0
  39. data/release_notes/v2.2.0.md +31 -0
  40. data/release_notes/v2.3.0.md +27 -0
  41. data/release_notes/v2.3.1.md +14 -0
  42. data/release_notes/v2.4.0.md +20 -0
  43. data/release_notes/v2.5.0.md +35 -0
  44. data/release_notes/v2.5.1.md +12 -0
  45. data/release_notes/v2.5.2.md +22 -0
  46. data/release_notes/v2.6.0.md +17 -0
  47. data/release_notes/v2.6.1.md +11 -0
  48. data/release_notes/v2.7.0.md +28 -0
  49. data/release_notes/v2.8.0.md +21 -0
  50. data/release_notes/v2.9.0.md +22 -0
  51. data/release_notes/v2.99.md +13 -0
  52. data/spec/application_integration_spec.rb +3 -3
  53. data/spec/application_spec.rb +27 -11
  54. data/spec/base_spec.rb +27 -6
  55. data/spec/ci_runner_spec.rb +137 -0
  56. data/spec/configuration_spec.rb +57 -23
  57. data/spec/fixture/afterall_spec.js +8 -0
  58. data/spec/fixture/console_log_spec.js +5 -0
  59. data/spec/fixture/exception_test.js +1 -0
  60. data/spec/fixture/phantomConfig.js +6 -0
  61. data/spec/fixture/viewport_spec.js +6 -0
  62. data/spec/jasmine_command_line_tool_spec.rb +46 -27
  63. data/spec/jasmine_pojs_spec.rb +73 -12
  64. data/spec/jasmine_rails_spec.rb +107 -41
  65. data/spec/lib/jasmine/formatters/console_spec.rb +124 -26
  66. data/spec/lib/jasmine/formatters/exit_code_spec.rb +34 -0
  67. data/spec/lib/jasmine/formatters/multi_spec.rb +16 -6
  68. data/spec/page_spec.rb +2 -2
  69. data/spec/path_expander_spec.rb +22 -5
  70. data/spec/path_mapper_spec.rb +14 -9
  71. data/spec/performance/phantom_js_runner_performance_spec.rb +1 -1
  72. data/spec/phantom_js_spec.rb +14 -0
  73. data/spec/rack/jasmine/runner_spec.rb +2 -2
  74. data/spec/result_spec.rb +17 -7
  75. data/spec/server_spec.rb +13 -39
  76. data/spec/spec_helper.rb +54 -6
  77. data/spec/yaml_config_parser_spec.rb +21 -21
  78. metadata +75 -36
  79. data/lib/jasmine/asset_bundle.rb +0 -68
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a7ce607ec6c8a6bb64af21d08f21d8305dceb95
4
- data.tar.gz: c86fcfa19f64ff33754b2fd6251d1d4c8abc9073
3
+ metadata.gz: 7dca92f4ae805f2cc25a016c14ea264f01203015
4
+ data.tar.gz: 94e7e8bf349a37d47ae0ebfe935831f710b4fc5f
5
5
  SHA512:
6
- metadata.gz: d0013fece64deeb497579113f9004c4765a1040b6cd5b076c8876bde288488f2a08a0505df12f75bb7e1b48cbb4eb6deec0984c2dde5bfb8ef175a0c7d5abf86
7
- data.tar.gz: e613e70b7b99fd68da008e3f2ae2bba56cc145df85ae9c8053b4bdb062d7324562e9f6bd1561e85288122345a9cf7cecb66782717af663c54122a254a1aed4ec
6
+ metadata.gz: 5858e72e685a34c81be4a7e24dc9744c05c587fd8027f47dbf8654f44eb322471e82c01e276c483b509804569a558bc5ba68e7bc22f715ff4d00f2d471b26f19
7
+ data.tar.gz: cd60b36656f747677b4550a983adc23fa7e104950dca8f800a1d13d21e92965b7564941175b635374fe65b554db61596cd73665ccbd0b1177f88dc03bce880bd
data/.travis.yml CHANGED
@@ -1,22 +1,36 @@
1
- script: "if [ $PERFORMANCE_SPECS ];then bundle exec rake performance_specs --trace; else bundle exec rake --trace; fi"
1
+ language: ruby
2
2
 
3
3
  rvm:
4
4
  - "1.9.3"
5
5
  - "2.0.0"
6
- - "jruby"
7
- - "rbx-2"
6
+ - "2.3.1"
8
7
 
9
8
  env:
10
- - "RAILS_VERSION=rails3"
11
- - "RAILS_VERSION=rails4"
12
- - "RAILS_VERSION=pojs"
9
+ - "RAILS_VERSION=rails3"
10
+ - "RAILS_VERSION=rails4"
11
+ - "RAILS_VERSION=pojs"
12
+
13
+ sudo: false
14
+
15
+ script: "if [ $PERFORMANCE_SPECS ];then bundle exec rake performance_specs --trace; else bundle exec rake --trace; fi"
16
+
17
+ install:
18
+ - bundle install --retry=3
13
19
 
14
20
  matrix:
21
+ fast_finish: true
15
22
  include:
16
- - rvm: "2.0.0"
17
- env: "PERFORMANCE_SPECS=true"
18
- exclude:
19
- - rvm: "rbx"
20
- env: "RAILS_VERSION=pojs"
21
- - rvm: "jruby"
22
- env: "RAILS_VERSION=pojs"
23
+ - rvm: "2.3.1"
24
+ env:
25
+ - "PERFORMANCE_SPECS=true"
26
+ - "RAILS_VERSION=rails5"
27
+ - rvm: "2.3.1"
28
+ env: "RAILS_VERSION=rails5"
29
+ allow_failures:
30
+ - rvm: "jruby-9.1.5.0"
31
+ env:
32
+ - "RAILS_VERSION=rails4"
33
+ - "JRUBY_OPTS=''"
34
+
35
+ before_install:
36
+ - gem install bundler -v "= 1.15.4"
data/Gemfile CHANGED
@@ -2,27 +2,27 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- unless ENV['TRAVIS']
6
- group :debug do
7
- gem 'debugger', :platform => :mri
8
- gem 'ruby-debug', :platform => :jruby
9
- end
10
- end
11
-
12
5
  gem 'anchorman', :platform => :mri
6
+ gem 'octokit', '< 4.4', :platform => :mri
13
7
  # during development, do not release
14
8
  if ENV['TRAVIS']
15
- gem 'jasmine-core', :git => 'http://github.com/pivotal/jasmine.git'
9
+ gem 'jasmine-core', :git => 'http://github.com/jasmine/jasmine.git'
16
10
  else
17
11
  gem 'jasmine-core', :path => '../jasmine'
18
12
  end
19
13
 
20
14
  if ENV['RAILS_VERSION'] == "rails3"
21
15
  gem 'rack', '1.4.5'
22
- else
16
+ elsif ENV['RAILS_VERSION'] == "rails4"
23
17
  gem 'rack', '1.5.2'
18
+ elsif ENV['RAILS_VERSION'] == "pojs"
19
+ gem 'rack', '< 2.0'
20
+ else
21
+ gem 'rack', '>= 2.0'
24
22
  end
25
23
 
24
+ gem 'mime-types', '< 3.0', platform: [:mri_19, :jruby]
25
+
26
26
  platform :rbx do
27
27
  gem 'json'
28
28
  gem 'rubysl'
data/HOW_TO_TEST.markdown CHANGED
@@ -1,5 +1,6 @@
1
1
  To test changes to the jasmine-gem:
2
2
 
3
+ * You need to have the [jasmine project](https://github.com/jasmine/jasmine) checked out in `../jasmine`
3
4
  * Export RAILS_VERSION as either "pojs" (Plain Old JavaScript -- IE, no rails bindings), or "rails3" to test environments other than Rails 4.
4
5
  * Delete `Gemfile.lock`
5
6
  * Clear out your current gemset
data/README.markdown CHANGED
@@ -1,13 +1,13 @@
1
- # The Jasmine Gem [![Build Status](https://travis-ci.org/pivotal/jasmine-gem.png?branch=master)](https://travis-ci.org/pivotal/jasmine-gem)
1
+ # The Jasmine Gem [![Build Status](https://travis-ci.org/jasmine/jasmine-gem.png?branch=master)](https://travis-ci.org/jasmine/jasmine-gem)
2
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.
3
+ The [Jasmine](http://github.com/jasmine/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
4
 
5
5
  ## Contents
6
6
  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 3 and Rails 4)
10
+ * Generators for Ruby on Rails projects (Rails 3, 4, and 5)
11
11
 
12
12
  You can get all of this by: `gem install jasmine` or by adding Jasmine to your `Gemfile`.
13
13
 
@@ -19,15 +19,17 @@ end
19
19
 
20
20
  ## Init A Project
21
21
 
22
- To initialize a project for Jasmine
22
+ To initialize a rails project for Jasmine
23
23
 
24
- `rails g jasmine:install`
25
- `rails g jasmine:examples`
24
+ rails generate jasmine:install
25
+
26
+ rails generate jasmine:examples
26
27
 
27
28
  For any other project (Sinatra, Merb, or something we don't yet know about) use
28
29
 
29
- `jasmine init`
30
- `jasmine examples`
30
+ jasmine init
31
+
32
+ jasmine examples
31
33
 
32
34
  ## Usage
33
35
 
@@ -43,7 +45,11 @@ For Continuous Integration environments, add this task to the project build step
43
45
 
44
46
  This uses PhantomJS to load and run the Jasmine suite.
45
47
 
46
- Please note that PhantomJS will be auto-installed by the [phantomjs-gem][phantomjs-gem] at the first `rake jasmine:ci` run. If you have a PhantomJS somewhere on your path, it won't install.
48
+ Please note that PhantomJS will be auto-installed by the [phantomjs-gem][phantomjs-gem] at the first `rake jasmine:ci` run. If you have a matching PhantomJS version somewhere on your path, it won't install. You can disable automatic installation altogether (and use the PhantomJS on your path) via the config helper in your jasmine_helper.rb:
49
+
50
+ Jasmine.configure do |config|
51
+ config.prevent_phantom_js_auto_install = true
52
+ end
47
53
 
48
54
  [phantomjs-gem]: https://github.com/colszowka/phantomjs-gem#phantomjs-as-a-rubygem
49
55
 
@@ -57,7 +63,7 @@ Alternatively, you may specify the path to your `jasmine.yml` by setting an envi
57
63
  `rake jasmine:ci JASMINE_CONFIG_PATH=relative/path/to/your/jasmine.yml`
58
64
 
59
65
  In addition, the `spec_helper` key in your jasmine.yml specifies the path to a ruby file that can do programmatic configuration.
60
- After running `jasmine init` or `rails g jasmine:install` it will point to `spec/javascripts/support/jasmine_helper.rb` which you can modify to fit your needs.
66
+ After running `jasmine init` or `rails generate jasmine:install` it will point to `spec/javascripts/support/jasmine_helper.rb` which you can modify to fit your needs.
61
67
 
62
68
  ### Running Jasmine on a different port
63
69
 
@@ -81,9 +87,10 @@ In your jasmine_helper.rb:
81
87
 
82
88
  ## Support
83
89
 
90
+ Documentation: [jasmine.github.io](https://jasmine.github.io)
84
91
  Jasmine Mailing list: [jasmine-js@googlegroups.com](mailto:jasmine-js@googlegroups.com)
85
92
  Twitter: [@jasminebdd](http://twitter.com/jasminebdd)
86
93
 
87
94
  Please file issues here at Github
88
95
 
89
- Copyright (c) 2008-2013 Pivotal Labs. This software is licensed under the MIT License.
96
+ Copyright (c) 2008-2017 Pivotal Labs. This software is licensed under the MIT License.
data/jasmine.gemspec CHANGED
@@ -1,17 +1,18 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
3
  require "jasmine/version"
4
+ require "jasmine/ruby_versions"
4
5
 
5
6
  Gem::Specification.new do |s|
6
7
  s.name = %q{jasmine}
7
8
  s.version = Jasmine::VERSION
8
9
  s.platform = Gem::Platform::RUBY
9
10
 
10
- s.authors = ["Rajan Agaskar", "Christian Williams", "Davis Frank"]
11
+ s.authors = ["Gregg Van Hove"]
11
12
  s.summary = %q{JavaScript BDD framework}
12
13
  s.description = %q{Test your JavaScript without any framework dependencies, in any environment, and with a nice descriptive syntax.}
13
14
  s.email = %q{jasmine-js@googlegroups.com}
14
- s.homepage = "http://pivotal.github.com/jasmine/"
15
+ s.homepage = "http://jasmine.github.io/"
15
16
  s.license = "MIT"
16
17
 
17
18
  s.files = `git ls-files`.split("\n") | Dir.glob('jasmine/**/*')
@@ -24,16 +25,23 @@ Gem::Specification.new do |s|
24
25
  when 'rails3'
25
26
  s.add_development_dependency 'rails', '>= 3.0.0', '< 4.0.0'
26
27
  when 'pojs'
27
- else #default to rails 4
28
- s.add_development_dependency 'rails', '>= 4'
28
+ when 'rails4'
29
+ s.add_development_dependency 'rails', '>= 4', '< 5.0.0'
30
+ else #default to rails 5
31
+ s.add_development_dependency 'rails', '>= 5'
29
32
  end
30
33
 
31
34
  s.add_development_dependency 'rack-test'
32
35
  s.add_development_dependency 'multi_json'
33
36
  s.add_development_dependency 'rspec', '>= 2.5.0'
34
- s.add_development_dependency 'nokogiri'
35
37
 
36
- s.add_dependency 'jasmine-core', '~> 2.0.0'
38
+ if ruby_version_less_than([2,1,0])
39
+ s.add_development_dependency 'nokogiri', '< 1.7.0'
40
+ else
41
+ s.add_development_dependency 'nokogiri'
42
+ end
43
+
44
+ s.add_dependency 'jasmine-core', '>= 2.99.0', '< 3.0.0'
37
45
  s.add_dependency 'rack', '>= 1.2.1'
38
46
  s.add_dependency 'rake'
39
47
  s.add_dependency 'phantomjs'
@@ -7,7 +7,7 @@ beforeEach(function () {
7
7
 
8
8
  return {
9
9
  pass: player.currentlyPlayingSong === expected && player.isPlaying
10
- }
10
+ };
11
11
  }
12
12
  };
13
13
  }
@@ -8,7 +8,7 @@
8
8
  # src_files:
9
9
  # - lib/source1.js
10
10
  # - lib/source2.js
11
- # - dist/**/*.js
11
+ # - 'dist/**/*.js'
12
12
  #
13
13
  src_files:
14
14
  - assets/application.js
@@ -22,10 +22,10 @@ src_files:
22
22
  #
23
23
  # stylesheets:
24
24
  # - css/style.css
25
- # - stylesheets/*.css
25
+ # - 'stylesheets/*.css'
26
26
  #
27
27
  stylesheets:
28
- - stylesheets/**/*.css
28
+ - assets/application.css
29
29
 
30
30
  # helpers
31
31
  #
@@ -35,7 +35,7 @@ stylesheets:
35
35
  # EXAMPLE:
36
36
  #
37
37
  # helpers:
38
- # - helpers/**/*.js
38
+ # - 'helpers/**/*.js'
39
39
  #
40
40
  helpers:
41
41
  - 'helpers/**/*.js'
@@ -48,7 +48,7 @@ helpers:
48
48
  # EXAMPLE:
49
49
  #
50
50
  # spec_files:
51
- # - **/*[sS]pec.js
51
+ # - '**/*[sS]pec.js'
52
52
  #
53
53
  spec_files:
54
54
  - '**/*[sS]pec.js'
@@ -110,3 +110,36 @@ boot_dir:
110
110
  #
111
111
  boot_files:
112
112
 
113
+ # rack_options
114
+ #
115
+ # Extra options to be passed to the rack server
116
+ # by default, Port and AccessLog are passed.
117
+ #
118
+ # This is an advanced options, and left empty by default
119
+ #
120
+ # EXAMPLE
121
+ #
122
+ # rack_options:
123
+ # server: 'thin'
124
+
125
+ # phantom_cli_options
126
+ #
127
+ # Extra options to be passed to the phantomjs cli,
128
+ # e.g. to enable localStorage in PhantomJs 2.5
129
+ #
130
+ # EXAMPLE
131
+ #
132
+ # phantom_cli_options:
133
+ # local-storage-quota: 5000
134
+
135
+ # random
136
+ #
137
+ # Run specs in semi-random order.
138
+ # Default: false
139
+ #
140
+ # EXAMPLE:
141
+ #
142
+ # random: true
143
+ #
144
+ random:
145
+
@@ -1,11 +1,16 @@
1
- #Use this file to set/override Jasmine configuration options
2
- #You can remove it if you don't need it.
3
- #This file is loaded *after* jasmine.yml is interpreted.
1
+ # Use this file to set/override Jasmine configuration options
2
+ # You can remove it if you don't need it.
3
+ # This file is loaded *after* jasmine.yml is interpreted.
4
4
  #
5
- #Example: using a different boot file.
6
- #Jasmine.configure do |config|
7
- # config.boot_dir = '/absolute/path/to/boot_dir'
8
- # config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] }
9
- #end
5
+ # Example: using a different boot file.
6
+ # Jasmine.configure do |config|
7
+ # config.boot_dir = '/absolute/path/to/boot_dir'
8
+ # config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] }
9
+ # end
10
10
  #
11
-
11
+ # Example: prevent PhantomJS auto install, uses PhantomJS already on your path.
12
+ Jasmine.configure do |config|
13
+ if ENV['TRAVIS']
14
+ config.prevent_phantom_js_auto_install = true
15
+ end
16
+ end
@@ -9,8 +9,8 @@ require 'ostruct'
9
9
  module Jasmine
10
10
  class Application
11
11
  def self.app(config, builder = Rack::Builder.new)
12
- config.rack_apps.each do |(app, config_block)|
13
- builder.use(app, &config_block)
12
+ config.rack_apps.each do |app_config|
13
+ builder.use(app_config[:app], *app_config[:args], &app_config[:block])
14
14
  end
15
15
  config.rack_path_map.each do |path, handler|
16
16
  builder.map(path) { run handler.call }
@@ -1,18 +1,66 @@
1
1
  module Jasmine
2
2
  class AssetExpander
3
- def initialize(bundled_asset_factory)
4
- @bundled_asset_factory = bundled_asset_factory
5
- end
6
-
7
3
  def expand(src_dir, src_path)
8
4
  pathname = src_path.gsub(/^\/?assets\//, '').gsub(/\.js$/, '')
9
- bundled_asset = bundled_asset_factory.new(pathname)
10
- bundled_asset.assets.map do |asset|
5
+
6
+ asset_bundle.assets(pathname).flat_map { |asset|
11
7
  "/#{asset.gsub(/^\//, '')}?body=true"
12
- end.flatten
8
+ }
13
9
  end
14
10
 
15
11
  private
16
- attr_reader :bundled_asset_factory
12
+
13
+ UnsupportedRailsVersion = Class.new(StandardError)
14
+
15
+ def asset_bundle
16
+ return Rails3AssetBundle.new if Jasmine::Dependencies.rails3?
17
+ return Rails4Or5AssetBundle.new if Jasmine::Dependencies.rails4? || Jasmine::Dependencies.rails5?
18
+ raise UnsupportedRailsVersion, "Jasmine only supports the asset pipeline for Rails 3 - 5"
19
+ end
20
+
21
+ class Rails3AssetBundle
22
+ def assets(pathname)
23
+ context.asset_paths.asset_for(pathname, nil).to_a.map do |path|
24
+ context.asset_path(path)
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def context
31
+ @context ||= get_asset_context
32
+ end
33
+
34
+ def get_asset_context
35
+ context = ::Rails.application.assets.context_class
36
+ context.extend(::Sprockets::Helpers::IsolatedHelper)
37
+ context.extend(::Sprockets::Helpers::RailsHelper)
38
+ end
39
+ end
40
+
41
+ class Rails4Or5AssetBundle
42
+ def assets(pathname)
43
+ context.get_original_assets(pathname)
44
+ end
45
+
46
+ private
47
+
48
+ def context
49
+ @context ||= ActionView::Base.new.extend(GetOriginalAssetsHelper)
50
+ end
51
+
52
+ module GetOriginalAssetsHelper
53
+ def get_original_assets(pathname)
54
+ Array(assets_environment.find_asset(pathname)).map do |processed_asset|
55
+ case processed_asset.content_type
56
+ when "text/css"
57
+ path_to_stylesheet(processed_asset.logical_path, debug: true)
58
+ when "application/javascript"
59
+ path_to_javascript(processed_asset.logical_path, debug: true)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
17
65
  end
18
66
  end
data/lib/jasmine/base.rb CHANGED
@@ -23,19 +23,19 @@ module Jasmine
23
23
  require 'socket'
24
24
  begin
25
25
  socket = TCPSocket.open(hostname, port)
26
- rescue Errno::ECONNREFUSED
26
+ rescue Errno::ECONNREFUSED, Errno::ENETUNREACH, Errno::EAFNOSUPPORT, Errno::EADDRNOTAVAIL, Errno::EHOSTUNREACH
27
27
  return false
28
28
  end
29
29
  socket.close
30
30
  true
31
31
  end
32
32
 
33
- def self.wait_for_listener(port, name = "required process", seconds_to_wait = 20)
33
+ def self.wait_for_listener(port, hostname = "localhost", seconds_to_wait = 20)
34
34
  time_out_at = Time.now + seconds_to_wait
35
- until server_is_listening_on "localhost", port
35
+ until server_is_listening_on hostname, port
36
36
  sleep 0.1
37
- puts "Waiting for #{name} on #{port}..."
38
- raise "#{name} didn't show up on port #{port} after #{seconds_to_wait} seconds." if Time.now > time_out_at
37
+ puts "Waiting for server on #{hostname}:#{port}..."
38
+ raise "jasmine server didn't show up on port #{hostname}:#{port} after #{seconds_to_wait} seconds." if Time.now > time_out_at
39
39
  end
40
40
  end
41
41
 
@@ -0,0 +1,50 @@
1
+ module Jasmine
2
+ class CiRunner
3
+ def initialize(config, options={})
4
+ @config = config
5
+ @thread = options.fetch(:thread, Thread)
6
+ @application_factory = options.fetch(:application_factory, Jasmine::Application)
7
+ @server_factory = options.fetch(:server_factory, Jasmine::Server)
8
+ @outputter = options.fetch(:outputter, Kernel)
9
+ @random = options.fetch(:random, config.random)
10
+ @seed = options.has_key?(:seed) ? "&seed=#{options[:seed]}" : ''
11
+ end
12
+
13
+ def run
14
+ formatters = config.formatters.map { |formatter_class| formatter_class.new }
15
+
16
+ exit_code_formatter = Jasmine::Formatters::ExitCode.new
17
+ formatters << exit_code_formatter
18
+
19
+ url = "#{config.host}:#{config.port(:ci)}/?throwFailures=#{config.stop_spec_on_expectation_failure}&random=#{@random}#{@seed}"
20
+ runner = config.runner.call(Jasmine::Formatters::Multi.new(formatters), url)
21
+
22
+ if runner.respond_to?(:boot_js)
23
+ config.runner_boot_dir = File.dirname(runner.boot_js)
24
+ config.runner_boot_files = lambda { [runner.boot_js] }
25
+ end
26
+
27
+ server = @server_factory.new(config.port(:ci), app, config.rack_options)
28
+
29
+ t = @thread.new do
30
+ server.start
31
+ end
32
+ t.abort_on_exception = true
33
+
34
+ Jasmine::wait_for_listener(config.port(:ci), config.host.sub(/\Ahttps?:\/\//, ''))
35
+ @outputter.puts 'jasmine server started'
36
+
37
+ runner.run
38
+
39
+ exit_code_formatter.succeeded?
40
+ end
41
+
42
+ private
43
+
44
+ attr_reader :config
45
+
46
+ def app
47
+ @application_factory.app(@config)
48
+ end
49
+ end
50
+ end
@@ -5,7 +5,7 @@ module Jasmine
5
5
  def process(argv)
6
6
  @argv = argv
7
7
 
8
- if respond_to?(@argv[0])
8
+ if @argv.size > 0 && respond_to?(@argv[0])
9
9
  public_send(@argv[0])
10
10
  else
11
11
  print_help
@@ -50,7 +50,7 @@ module Jasmine
50
50
  end
51
51
 
52
52
  def print_help
53
- puts "unknown command #{@argv.join(' ')}"
53
+ puts "unknown command #{@argv.join(' ')}" unless @argv.empty?
54
54
  puts "Usage: jasmine init"
55
55
  puts " examples"
56
56
  puts " copy_boot_js"
@@ -76,7 +76,7 @@ module Jasmine
76
76
  FileUtils.mkdir_p(File.dirname(dest_path))
77
77
  FileUtils.copy(source_path, dest_path)
78
78
  if File.basename(dest_path) == 'jasmine.yml'
79
- replaced = File.read(dest_path).gsub("assets/application.js", "public/javascripts/**/*.js")
79
+ replaced = File.read(dest_path).gsub("assets/application.js", "public/javascripts/**/*.js").gsub("assets/application.css", "stylesheets/**/*.css")
80
80
  File.open(dest_path, 'w') do |file|
81
81
  file.write(replaced)
82
82
  end
@@ -94,7 +94,7 @@ module Jasmine
94
94
  puts <<-EOF
95
95
 
96
96
  You're attempting to run jasmine init in a Rails project. You probably want to use the Rails generator like so:
97
- rails g jasmine:init
97
+ rails g jasmine:install
98
98
 
99
99
  If you're not actually in a Rails application, just run this command again with --force
100
100
  jasmine init --force
@@ -17,6 +17,7 @@ module Jasmine
17
17
  @config.src_path = src_path = '/'
18
18
  @config.spec_path = spec_path = '/__spec__'
19
19
  @config.boot_path = boot_path = '/__boot__'
20
+ @config.runner_boot_path = runner_boot_path = '/__runner_boot__'
20
21
  @config.image_path = image_path = '/__images__'
21
22
 
22
23
  @config.jasmine_dir = core_config.path
@@ -26,10 +27,14 @@ module Jasmine
26
27
  @config.jasmine_css_files = lambda { core_config.css_files }
27
28
  @config.add_rack_path(jasmine_path, lambda { Rack::File.new(config.jasmine_dir) })
28
29
  @config.add_rack_path(boot_path, lambda { Rack::File.new(config.boot_dir) })
30
+ @config.add_rack_path(runner_boot_path, lambda { Rack::File.new(config.runner_boot_dir) })
29
31
  if Jasmine::Dependencies.use_asset_pipeline?
30
32
  @config.add_rack_path(spec_path, lambda {
31
33
  sprockets_spec_env = Sprockets::Environment.new
32
34
  sprockets_spec_env.append_path @config.spec_dir
35
+ Rails.application.assets.paths.each do |path|
36
+ sprockets_spec_env.append_path(path)
37
+ end
33
38
  sprockets_spec_env
34
39
  })
35
40
  else
@@ -48,19 +53,20 @@ module Jasmine
48
53
 
49
54
  if Jasmine::Dependencies.use_asset_pipeline?
50
55
  @config.add_path_mapper(lambda { |config|
51
- asset_expander = Jasmine::AssetExpander.new(Jasmine::AssetBundle.factory)
56
+ asset_expander = Jasmine::AssetExpander.new
52
57
  Jasmine::AssetPipelineMapper.new(config, asset_expander.method(:expand))
53
58
  })
54
59
  # In order to have asset helpers like asset_path and image_path, we need to require 'action_view/base'. This
55
60
  # triggers run_load_hooks on action_view which, in turn, causes sprockets/railtie to load the Sprockets asset
56
- # helpers. Alternatively, you can include the helpers yourself without loading action_view/base:
61
+ # helpers and set some configuration options.
57
62
  Rails.application.assets.context_class.instance_eval do
58
63
  if Jasmine::Dependencies.rails3?
59
64
  include ::Sprockets::Helpers::IsolatedHelper
60
65
  include ::Sprockets::Helpers::RailsHelper
61
66
  end
62
67
  if Jasmine::Dependencies.rails4?
63
- include ::Sprockets::Rails::Helper
68
+ require 'action_view/base'
69
+ Rails.application.assets.context_class.assets_prefix = Rails.application.config.assets.prefix
64
70
  end
65
71
  end
66
72
  @config.add_rack_path(Rails.application.config.assets.prefix, lambda {
@@ -68,7 +74,15 @@ module Jasmine
68
74
  })
69
75
  end
70
76
 
71
- @config.runner = lambda { |formatter, jasmine_server_url| Jasmine::Runners::PhantomJs.new(formatter, jasmine_server_url, 50) }
77
+ @config.runner = lambda do |formatter, jasmine_server_url|
78
+ Jasmine::Runners::PhantomJs.new(formatter,
79
+ jasmine_server_url,
80
+ @config.prevent_phantom_js_auto_install,
81
+ @config.show_console_log,
82
+ @config.phantom_config_script,
83
+ @config.show_full_stack_trace,
84
+ @config.phantom_cli_options)
85
+ end
72
86
  end
73
87
 
74
88
  def self.config
@@ -95,7 +109,16 @@ module Jasmine
95
109
  config.css_files = lambda { yaml_config.css_files }
96
110
 
97
111
  config.spec_dir = yaml_config.spec_dir
98
- config.spec_files = lambda { yaml_config.helpers + yaml_config.spec_files }
112
+ config.helper_files = lambda { yaml_config.helpers }
113
+ config.spec_files = lambda { yaml_config.spec_files }
114
+
115
+ config.show_console_log = yaml_config.show_console_log
116
+ config.stop_spec_on_expectation_failure = yaml_config.stop_spec_on_expectation_failure
117
+ config.random = yaml_config.random
118
+ config.phantom_config_script = yaml_config.phantom_config_script
119
+ config.phantom_cli_options = yaml_config.phantom_cli_options
120
+
121
+ config.rack_options = yaml_config.rack_options
99
122
  end
100
123
  require yaml_config.spec_helper if File.exist?(yaml_config.spec_helper)
101
124
  else
@@ -103,4 +126,10 @@ module Jasmine
103
126
  end
104
127
  end
105
128
 
129
+ def self.load_spec(spec_path)
130
+ return if spec_path.nil?
131
+ Jasmine.configure do |c|
132
+ c.spec_files = lambda { [spec_path] }
133
+ end
134
+ end
106
135
  end