jasmine 2.0.0 → 2.0.1

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.
@@ -20,3 +20,6 @@ matrix:
20
20
  env: "RAILS_VERSION=pojs"
21
21
  - rvm: "jruby"
22
22
  env: "RAILS_VERSION=pojs"
23
+
24
+ before_install:
25
+ - gem install bundler -v "= 1.5.1"
@@ -25,7 +25,7 @@ src_files:
25
25
  # - stylesheets/*.css
26
26
  #
27
27
  stylesheets:
28
- - stylesheets/**/*.css
28
+ - assets/application.css
29
29
 
30
30
  # helpers
31
31
  #
@@ -110,3 +110,15 @@ 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
+
@@ -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 }
@@ -23,7 +23,7 @@ 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
27
27
  return false
28
28
  end
29
29
  socket.close
@@ -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,6 +27,7 @@ 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
@@ -96,6 +98,8 @@ module Jasmine
96
98
 
97
99
  config.spec_dir = yaml_config.spec_dir
98
100
  config.spec_files = lambda { yaml_config.helpers + yaml_config.spec_files }
101
+
102
+ config.rack_options = yaml_config.rack_options
99
103
  end
100
104
  require yaml_config.spec_helper if File.exist?(yaml_config.spec_helper)
101
105
  else
@@ -1,13 +1,14 @@
1
1
  module Jasmine
2
2
  class Configuration
3
3
  attr_writer :jasmine_css_files, :css_files
4
- attr_writer :jasmine_files, :boot_files, :src_files, :spec_files
5
- attr_accessor :jasmine_path, :spec_path, :boot_path, :src_path, :image_path
6
- attr_accessor :jasmine_dir, :spec_dir, :boot_dir, :src_dir, :images_dir
4
+ attr_writer :jasmine_files, :boot_files, :src_files, :spec_files, :runner_boot_files
5
+ attr_accessor :jasmine_path, :spec_path, :boot_path, :src_path, :image_path, :runner_boot_path
6
+ attr_accessor :jasmine_dir, :spec_dir, :boot_dir, :src_dir, :images_dir, :runner_boot_dir
7
7
  attr_accessor :formatters
8
8
  attr_accessor :host
9
9
  attr_accessor :spec_format
10
10
  attr_accessor :runner
11
+ attr_accessor :rack_options
11
12
 
12
13
  def initialize()
13
14
  @rack_paths = {}
@@ -17,9 +18,11 @@ module Jasmine
17
18
  @css_files = lambda { [] }
18
19
  @jasmine_files = lambda { [] }
19
20
  @boot_files = lambda { [] }
21
+ @runner_boot_files = lambda { [] }
20
22
  @src_files = lambda { [] }
21
23
  @spec_files = lambda { [] }
22
24
  @runner = lambda { |config| }
25
+ @rack_options = {}
23
26
 
24
27
  @formatters = [Jasmine::Formatters::Console]
25
28
 
@@ -34,6 +37,7 @@ module Jasmine
34
37
  def js_files
35
38
  map(@jasmine_files, :jasmine) +
36
39
  map(@boot_files, :boot) +
40
+ map(@runner_boot_files, :runner_boot) +
37
41
  map(@src_files, :src) +
38
42
  map(@spec_files, :spec)
39
43
  end
@@ -50,8 +54,12 @@ module Jasmine
50
54
  [] + @apps
51
55
  end
52
56
 
53
- def add_rack_app(app, &block)
54
- @apps << [app, block]
57
+ def add_rack_app(app, *args, &block)
58
+ @apps << {
59
+ :app => app,
60
+ :args => args,
61
+ :block => block
62
+ }
55
63
  end
56
64
 
57
65
  def add_path_mapper(mapper)
@@ -7,7 +7,7 @@ module Jasmine
7
7
  end
8
8
 
9
9
  def rails4?
10
- safe_gem_check("rails", "~> 4.0.0.rc1") && running_rails4?
10
+ safe_gem_check("rails", "~> 4") && running_rails4?
11
11
  end
12
12
 
13
13
  def rails?
@@ -1,17 +1,19 @@
1
1
  module Jasmine
2
2
  module Formatters
3
3
  class Console
4
- def initialize(outputter = Kernel.method(:puts))
4
+ def initialize(outputter = Kernel)
5
5
  @results = []
6
6
  @outputter = outputter
7
7
  end
8
8
 
9
9
  def format(results_batch)
10
- outputter.call(failures(results_batch))
10
+ outputter.print(chars(results_batch))
11
11
  @results += results_batch
12
12
  end
13
13
 
14
14
  def done
15
+ outputter.puts
16
+ outputter.puts(failures(@results))
15
17
  failure_count = results.count(&:failed?)
16
18
  pending_count = results.count(&:pending?)
17
19
  summary = "#{pluralize(results.size, 'spec')}, " +
@@ -19,7 +21,7 @@ module Jasmine
19
21
 
20
22
  summary += ", #{pluralize(pending_count, 'pending spec')}" if pending_count > 0
21
23
 
22
- outputter.call(summary)
24
+ outputter.puts(summary)
23
25
  end
24
26
 
25
27
  private
@@ -29,6 +31,18 @@ module Jasmine
29
31
  results.select(&:failed?).map { |f| failure_message(f) }.join("\n\n")
30
32
  end
31
33
 
34
+ def chars(results)
35
+ results.map do |result|
36
+ if result.succeeded?
37
+ "\e[32m.\e[0m"
38
+ elsif result.pending?
39
+ "\e[33m*\e[0m"
40
+ else
41
+ "\e[31mF\e[0m"
42
+ end
43
+ end.join('')
44
+ end
45
+
32
46
  def pluralize(count, str)
33
47
  word = (count == 1) ? str : str + 's'
34
48
  "#{count} #{word}"
@@ -7,7 +7,11 @@ module Jasmine
7
7
  patterns.map do |path|
8
8
  files = globber.call(File.join(base_directory, path.gsub(/^!/, '')))
9
9
  if files.empty? && !(path =~ /\*|^\!/)
10
- files = [File.join(base_directory, path)]
10
+ if path[0..3] == 'http'
11
+ files << path
12
+ else
13
+ files = [File.join(base_directory, path)]
14
+ end
11
15
  end
12
16
  files.sort
13
17
  end.flatten.uniq
@@ -16,14 +16,23 @@ module Jasmine
16
16
  map(paths, @config.boot_dir, @config.boot_path)
17
17
  end
18
18
 
19
+ def map_runner_boot_paths(paths)
20
+ map(paths, @config.runner_boot_dir, @config.runner_boot_path)
21
+ end
22
+
19
23
  def map_jasmine_paths(paths)
20
24
  map(paths, @config.jasmine_dir, @config.jasmine_path)
21
25
  end
22
26
 
23
27
  private
24
28
  def map(paths, remove_path, add_path)
25
- paths.map { |path| File.join(add_path, (path.gsub(remove_path, ''))) }
29
+ paths.map do |path|
30
+ if path[0..3] == 'http'
31
+ path
32
+ else
33
+ File.join(add_path, (path.gsub(remove_path, '')))
34
+ end
35
+ end
26
36
  end
27
-
28
37
  end
29
38
  end
@@ -3,7 +3,7 @@ require 'rails/railtie'
3
3
  module Jasmine
4
4
  class Railtie < Rails::Railtie
5
5
 
6
- config.before_configuration do
6
+ initializer "jasmine.initializer", :before => :load_environment_hook do
7
7
  old_jasmine_rakefile = ::Rails.root.join('lib', 'tasks', 'jasmine.rake')
8
8
  if old_jasmine_rakefile.exist? && !ENV['USE_JASMINE_RAKE']
9
9
  puts '
@@ -0,0 +1,11 @@
1
+ function PhantomReporter() {
2
+ this.jasmineDone = function() {
3
+ window.callPhantom({ state: 'jasmineDone' });
4
+ };
5
+
6
+ this.specDone = function(results) {
7
+ window.callPhantom({ state: 'specDone', results: results});
8
+ };
9
+ }
10
+
11
+ jasmine.getEnv().addReporter(new PhantomReporter());
@@ -1,54 +1,18 @@
1
1
  (function() {
2
- /**
3
- * Wait until the test condition is true or a timeout occurs. Useful for waiting
4
- * on a server response or for a ui change (fadeIn, etc.) to occur.
5
- *
6
- * @param testFx javascript condition that evaluates to a boolean,
7
- * it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
8
- * as a callback function.
9
- * @param onReady what to do when testFx condition is fulfilled,
10
- * it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
11
- * as a callback function.
12
- */
13
- function waitFor(testFx, onReady) {
14
- var condition = false,
15
- interval = setInterval(function() {
16
- if (!condition) {
17
- condition = (typeof(testFx) === 'string' ? eval(testFx) : testFx());
18
- } else {
19
- if (typeof(onReady) === 'string') {
20
- eval(onReady);
21
- } else {
22
- onReady();
23
- }
24
- clearInterval(interval);
25
- }
26
- }, 100);
27
- }
28
-
29
2
  var url = phantom.args[0];
30
- var batchSize = parseInt(phantom.args[1], 10);
31
3
  var page = require('webpage').create();
32
4
 
5
+ page.onCallback = function(data) {
6
+ if(data.state === 'specDone') {
7
+ console.log('jasmine_result' + JSON.stringify([].concat(data.results)));
8
+ } else {
9
+ phantom.exit(0);
10
+ }
11
+ };
12
+
33
13
  page.open(url, function(status) {
34
14
  if (status !== "success") {
35
15
  phantom.exit(1);
36
- } else {
37
- waitFor(function() {
38
- return page.evaluate(function() {
39
- return jsApiReporter && jsApiReporter.finished
40
- });
41
- }, function() {
42
- var index = 0, results;
43
- do {
44
- results = page.evaluate(function(index, batchSize) {
45
- return jsApiReporter.specResults(index, batchSize)
46
- }, index, batchSize);
47
- console.log(JSON.stringify(results));
48
- index += batchSize;
49
- } while (results && results.length == batchSize)
50
- phantom.exit(0);
51
- });
52
16
  }
53
17
  });
54
18
  }).call(this);
@@ -13,14 +13,21 @@ module Jasmine
13
13
  command = "#{Phantomjs.path} '#{File.join(File.dirname(__FILE__), 'phantom_jasmine_run.js')}' #{jasmine_server_url} #{result_batch_size}"
14
14
  IO.popen(command) do |output|
15
15
  output.each do |line|
16
- raw_results = JSON.parse(line, :max_nesting => false)
17
- results = raw_results.map { |r| Result.new(r) }
18
- formatter.format(results)
16
+ if line =~ /^jasmine_result/
17
+ line = line.sub(/^jasmine_result/, '')
18
+ raw_results = JSON.parse(line, :max_nesting => false)
19
+ results = raw_results.map { |r| Result.new(r) }
20
+ formatter.format(results)
21
+ end
19
22
  end
20
23
  end
21
24
  formatter.done
22
25
  end
23
26
 
27
+ def boot_js
28
+ File.expand_path('phantom_boot.js', File.dirname(__FILE__))
29
+ end
30
+
24
31
  private
25
32
  attr_reader :formatter, :jasmine_server_url, :result_batch_size
26
33
  end
@@ -1,8 +1,9 @@
1
1
  module Jasmine
2
2
  class Server
3
- def initialize(port = 8888, application = nil)
3
+ def initialize(port = 8888, application = nil, rack_options = nil)
4
4
  @port = port
5
5
  @application = application
6
+ @rack_options = rack_options || {}
6
7
  end
7
8
 
8
9
  def start
@@ -10,7 +11,7 @@ module Jasmine
10
11
  handler = Rack::Handler.get('webrick')
11
12
  handler.run(@application, :Port => @port, :AccessLog => [])
12
13
  else
13
- server = Rack::Server.new(:Port => @port, :AccessLog => [])
14
+ server = Rack::Server.new(@rack_options.merge(:Port => @port, :AccessLog => []))
14
15
  # workaround for Rack bug, when Rack > 1.2.1 is released Rack::Server.start(:app => Jasmine.app(self)) will work
15
16
  server.instance_variable_set(:@app, @application)
16
17
  server.start
@@ -23,22 +23,12 @@ namespace :jasmine do
23
23
  end
24
24
  end
25
25
 
26
+ task :configure_plugins
27
+
26
28
  desc 'Run continuous integration tests'
27
- task :ci => %w(jasmine:require_json jasmine:require jasmine:configure) do
29
+ task :ci => %w(jasmine:require_json jasmine:require jasmine:configure jasmine:configure_plugins) do
28
30
  config = Jasmine.config
29
31
 
30
- server = Jasmine::Server.new(config.port(:ci), Jasmine::Application.app(config))
31
- t = Thread.new do
32
- begin
33
- server.start
34
- rescue ChildProcess::TimeoutError
35
- end
36
- # # ignore bad exits
37
- end
38
- t.abort_on_exception = true
39
- Jasmine::wait_for_listener(config.port(:ci), 'jasmine server')
40
- puts 'jasmine server started.'
41
-
42
32
  formatters = config.formatters.map { |formatter_class| formatter_class.new }
43
33
 
44
34
  exit_code_formatter = Jasmine::Formatters::ExitCode.new
@@ -46,15 +36,28 @@ namespace :jasmine do
46
36
 
47
37
  url = "#{config.host}:#{config.port(:ci)}/"
48
38
  runner = config.runner.call(Jasmine::Formatters::Multi.new(formatters), url)
39
+ if runner.respond_to?(:boot_js)
40
+ config.runner_boot_dir = File.dirname(runner.boot_js)
41
+ config.runner_boot_files = lambda { [runner.boot_js] }
42
+ end
43
+
44
+ server = Jasmine::Server.new(config.port(:ci), Jasmine::Application.app(config), config.rack_options)
45
+ t = Thread.new do
46
+ server.start
47
+ end
48
+ t.abort_on_exception = true
49
+ Jasmine::wait_for_listener(config.port(:ci), 'jasmine server')
50
+ puts 'jasmine server started.'
51
+
49
52
  runner.run
50
53
 
51
54
  break unless exit_code_formatter.succeeded?
52
55
  end
53
56
 
54
- task :server => %w(jasmine:require jasmine:configure) do
57
+ task :server => %w(jasmine:require jasmine:configure jasmine:configure_plugins) do
55
58
  config = Jasmine.config
56
59
  port = config.port(:server)
57
- server = Jasmine::Server.new(port, Jasmine::Application.app(Jasmine.config))
60
+ server = Jasmine::Server.new(port, Jasmine::Application.app(Jasmine.config), config.rack_options)
58
61
  puts "your server is running here: http://localhost:#{port}/"
59
62
  puts "your tests are here: #{config.spec_dir}"
60
63
  puts "your source files are here: #{config.src_dir}"
@@ -1,3 +1,3 @@
1
1
  module Jasmine
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
@@ -59,6 +59,13 @@ module Jasmine
59
59
  File.join(@pwd, loaded_yaml['spec_helper'] || File.join('spec', 'javascripts', 'support', 'jasmine_helper.rb'))
60
60
  end
61
61
 
62
+ def rack_options
63
+ loaded_yaml.fetch('rack_options', {}).inject({}) do |memo, (key, value)|
64
+ memo[key.to_sym] = value
65
+ memo
66
+ end
67
+ end
68
+
62
69
  private
63
70
  def loaded_yaml
64
71
  @yaml_loader.call(@path)
@@ -26,14 +26,24 @@ describe 'Jasmine::Application' do
26
26
 
27
27
  Jasmine::Application.app(config, builder).should == builder
28
28
  end
29
+
29
30
  it 'should run rack apps provided by the config' do
30
31
  app1 = double(:app1)
31
32
  app2 = double(:app2)
33
+ app3 = double(:app3)
34
+ app4 = double(:app4)
32
35
  block = lambda { 'foo' }
33
- config = double(:config, :rack_path_map => [], :rack_apps => [[app1, nil], [app2, block]])
36
+ config = double(:config, :rack_path_map => [], :rack_apps => [
37
+ { :app => app1 },
38
+ { :app => app2, :block => block },
39
+ { :app => app3, :args => [:foo], :block => block },
40
+ { :app => app4, :args => [:bar] }
41
+ ])
34
42
  builder = double('Rack::Builder.new')
35
43
  builder.should_receive(:use).with(app1)
36
44
  builder.should_receive(:use).with(app2, &block)
45
+ builder.should_receive(:use).with(app3, :foo, &block)
46
+ builder.should_receive(:use).with(app4, :bar)
37
47
  Jasmine::Application.app(config, builder).should == builder
38
48
  end
39
49
  end
@@ -94,14 +94,30 @@ describe Jasmine::Configuration do
94
94
  config = Jasmine::Configuration.new()
95
95
  app = double
96
96
  config.add_rack_app(app)
97
- config.rack_apps.should == [[app, nil]]
97
+ config.rack_apps.should == [{ :app => app, :args => [], :block => nil }]
98
98
  end
99
- it 'permits the addition of arbitary rack apps with arbitrary config' do
99
+
100
+ it 'permits the addition of arbitary rack apps with a config block' do
100
101
  config = Jasmine::Configuration.new()
101
102
  app = double
102
103
  block = lambda { 'foo' }
103
104
  config.add_rack_app(app, &block)
104
- config.rack_apps.should == [[app, block]]
105
+ config.rack_apps.should == [{ :app => app, :args => [], :block => block }]
106
+ end
107
+
108
+ it 'permits the addition of arbitary rack apps with arbitrary config' do
109
+ config = Jasmine::Configuration.new()
110
+ app = double
111
+ config.add_rack_app(app, { :foo => 'bar' })
112
+ config.rack_apps.should == [{ :app => app, :args => [{ :foo => 'bar' }], :block => nil }]
113
+ end
114
+
115
+ it 'permits the addition of arbitary rack apps with arbitrary config and a config block' do
116
+ config = Jasmine::Configuration.new()
117
+ app = double
118
+ block = lambda { 'foo' }
119
+ config.add_rack_app(app, { :foo => 'bar' }, &block)
120
+ config.rack_apps.should == [{ :app => app, :args => [{ :foo => 'bar' }], :block => block }]
105
121
  end
106
122
  end
107
123
 
@@ -0,0 +1 @@
1
+ desibe('oops', function() {});
@@ -23,6 +23,15 @@ describe 'Jasmine command line tool' do
23
23
  ci_output.should =~ (/0 specs, 0 failures/)
24
24
  end
25
25
 
26
+ it 'should not have rails-like paths' do
27
+ output = capture_stdout { Jasmine::CommandLineTool.new.process ['init'] }
28
+ output.should =~ /Jasmine has been installed\./
29
+
30
+ config = YAML.load_file(File.join(@tmp, 'spec/javascripts/support/jasmine.yml'))
31
+ config['src_files'].should == ['public/javascripts/**/*.js']
32
+ config['stylesheets'].should == ['stylesheets/**/*.css']
33
+ end
34
+
26
35
  it 'should create a new Rakefile if it does not exist' do
27
36
  output = capture_stdout { Jasmine::CommandLineTool.new.process ["init"] }
28
37
  output.should =~ /Jasmine has been installed\./
@@ -120,4 +129,14 @@ describe 'Jasmine command line tool' do
120
129
 
121
130
  output.should =~ /already exists/
122
131
  end
132
+
133
+ it 'should show help' do
134
+ no_arg_output = capture_stdout { Jasmine::CommandLineTool.new.process [] }
135
+ no_arg_output.should_not =~ /unknown command/
136
+ no_arg_output.should =~ /Usage:/
137
+
138
+ unknown_arg_output = capture_stdout { Jasmine::CommandLineTool.new.process ['blurgh', 'blargh'] }
139
+ unknown_arg_output.should =~ /unknown command blurgh blargh/
140
+ unknown_arg_output.should =~ /Usage:/
141
+ end
123
142
  end
@@ -26,11 +26,17 @@ if Jasmine::Dependencies.rails_available?
26
26
 
27
27
  base = File.absolute_path(File.join(__FILE__, '../..'))
28
28
 
29
- open('Gemfile', 'a') { |f|
29
+ # sqlite3 v 1.3.9 is broken on rbx, so restrict to 1.3.8 for now until they fix it.
30
+ # see: https://github.com/sparklemotion/sqlite3-ruby/issues/122
31
+ file_contents = File.read('Gemfile')
32
+
33
+ open('Gemfile', 'w') { |f|
34
+ f.puts file_contents.sub("gem 'sqlite3'", "gem 'sqlite3', '1.3.8'")
30
35
  f.puts "gem 'jasmine', :path => '#{base}'"
31
36
  f.puts "gem 'jasmine-core', :github => 'pivotal/jasmine'"
32
37
  f.puts "gem 'rubysl', :platform => :rbx"
33
38
  f.puts "gem 'racc', :platform => :rbx"
39
+ f.puts "gem 'thin'" unless RUBY_PLATFORM == 'java'
34
40
  f.flush
35
41
  }
36
42
 
@@ -81,6 +87,18 @@ if Jasmine::Dependencies.rails_available?
81
87
  end
82
88
  end
83
89
 
90
+ it "rake jasmine:ci runs specs when an error occurs in the javascript" do
91
+ Bundler.with_clean_env do
92
+ FileUtils.cp(File.join(@root, 'spec', 'fixture', 'exception_test.js'), File.join('spec', 'javascripts'))
93
+ exception_yaml = custom_jasmine_config('exception') do |jasmine_config|
94
+ jasmine_config['spec_files'] << 'exception_test.js'
95
+ end
96
+ output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{exception_yaml}`
97
+ $?.should be_success
98
+ output.should include('5 specs, 0 failures')
99
+ end
100
+ end
101
+
84
102
  it "runs specs written in coffeescript" do
85
103
  coffee_yaml = custom_jasmine_config('coffee') do |jasmine_config|
86
104
  jasmine_config['spec_files'] << 'coffee_spec.coffee'
@@ -100,7 +118,7 @@ if Jasmine::Dependencies.rails_available?
100
118
  }
101
119
 
102
120
  css_yaml = custom_jasmine_config('css') do |jasmine_config|
103
- jasmine_config['src_files'] = ['assets/application.js']
121
+ jasmine_config['src_files'] = %w[assets/application.js http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js]
104
122
  jasmine_config['stylesheets'] = ['assets/application.css']
105
123
  end
106
124
 
@@ -120,9 +138,10 @@ if Jasmine::Dependencies.rails_available?
120
138
  end
121
139
 
122
140
  output = Net::HTTP.get(URI.parse('http://localhost:8888/'))
123
- output.should match(%r{script src.*/assets/jasmine_examples/Player.js})
124
- output.should match(%r{script src.*/assets/jasmine_examples/Song.js})
125
- output.should match(%r{<link rel=.stylesheet.*?href=./assets/foo.css\?.*?>})
141
+ output.should match(%r{script src.*/assets/jasmine_examples/Player\.js})
142
+ output.should match(%r{script src=['"]http://ajax\.googleapis\.com/ajax/libs/jquery/1\.11\.0/jquery\.min\.js})
143
+ output.should match(%r{script src.*/assets/jasmine_examples/Song\.js})
144
+ output.should match(%r{<link rel=.stylesheet.*?href=./assets/foo\.css\?.*?>})
126
145
  ensure
127
146
  Process.kill(:SIGINT, pid)
128
147
  begin
@@ -147,5 +166,20 @@ if Jasmine::Dependencies.rails_available?
147
166
  output.should include('1 spec, 0 failures')
148
167
  end
149
168
  end
169
+
170
+ it "should pass custom rack options from jasmine.yml" do
171
+ pending "we're testing this with thin, which doesn't work in jruby" if RUBY_PLATFORM == 'java'
172
+ rack_yaml = custom_jasmine_config('custom_rack') do |jasmine_config|
173
+ jasmine_config['rack_options'] = { 'server' => 'webrick' }
174
+ end
175
+
176
+ Bundler.with_clean_env do
177
+ default_output = `bundle exec rake jasmine:ci`
178
+ default_output.should include('Thin web server')
179
+
180
+ custom_output = `bundle exec rake jasmine:ci JASMINE_CONFIG_PATH=#{rack_yaml} 2>&1`
181
+ custom_output.should include("WEBrick")
182
+ end
183
+ end
150
184
  end
151
185
  end
@@ -3,19 +3,24 @@ require 'spec_helper'
3
3
  describe Jasmine::Formatters::Console do
4
4
 
5
5
  let(:outputter_output) { '' }
6
- let(:outputter) { lambda { |str| outputter_output << str } }
7
- describe '#failures' do
6
+ let(:outputter) do
7
+ double(:outputter).tap do |o|
8
+ o.stub(:print) { |str| outputter_output << str }
9
+ o.stub(:puts) { |str| outputter_output << "#{str}\n" }
10
+ end
11
+ end
12
+
13
+ describe '#summary' do
8
14
  it 'shows the failure messages' do
9
15
  results = [failing_result, failing_result]
10
- Jasmine::Formatters::Console.new(outputter).format(results)
11
-
16
+ formatter = Jasmine::Formatters::Console.new(outputter)
17
+ formatter.format(results)
18
+ formatter.done
12
19
  outputter_output.should match(/a suite with a failing spec/)
13
20
  outputter_output.should match(/a failure message/)
14
21
  outputter_output.should match(/a stack trace/)
15
22
  end
16
- end
17
23
 
18
- describe '#summary' do
19
24
  describe 'when the full suite passes' do
20
25
  it 'shows the spec counts' do
21
26
  results = [passing_result]
@@ -118,4 +118,21 @@ describe Jasmine::PathExpander do
118
118
  File.join('some_base', 'src2.js')
119
119
  ]
120
120
  end
121
+
122
+ it "passes through files that are not found by the globber and look like urls" do
123
+ #this is designed to support cdn files
124
+ dir_glob = lambda do |pattern|
125
+ []
126
+ end
127
+
128
+ expanded_files = Jasmine::PathExpander.expand(
129
+ 'some_base',
130
+ ['http://www.google.com'],
131
+ dir_glob
132
+ )
133
+
134
+ expanded_files.should == [
135
+ 'http://www.google.com'
136
+ ]
137
+ end
121
138
  end
@@ -44,5 +44,12 @@ describe Jasmine::Server do
44
44
  Jasmine::Server.new(1234, app).start
45
45
  server.instance_variable_get(:@app).should == app
46
46
  end
47
+
48
+ it "should pass rack options when starting the server" do
49
+ app = double('application')
50
+ server = double(:server)
51
+ Rack::Server.should_receive(:new).with(hash_including(:Port => 1234, :foo => 'bar')).and_return(double(:server).as_null_object)
52
+ Jasmine::Server.new(1234, app, {:foo => 'bar', :Port => 4321}).start
53
+ end
47
54
  end
48
55
  end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jasmine
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Rajan Agaskar
@@ -10,81 +11,92 @@ authors:
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2013-12-17 00:00:00.000000000 Z
14
+ date: 2014-04-17 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: rails
17
18
  requirement: !ruby/object:Gem::Requirement
19
+ none: false
18
20
  requirements:
19
- - - '>='
21
+ - - ! '>='
20
22
  - !ruby/object:Gem::Version
21
23
  version: '4'
22
24
  type: :development
23
25
  prerelease: false
24
26
  version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
25
28
  requirements:
26
- - - '>='
29
+ - - ! '>='
27
30
  - !ruby/object:Gem::Version
28
31
  version: '4'
29
32
  - !ruby/object:Gem::Dependency
30
33
  name: rack-test
31
34
  requirement: !ruby/object:Gem::Requirement
35
+ none: false
32
36
  requirements:
33
- - - '>='
37
+ - - ! '>='
34
38
  - !ruby/object:Gem::Version
35
39
  version: '0'
36
40
  type: :development
37
41
  prerelease: false
38
42
  version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
39
44
  requirements:
40
- - - '>='
45
+ - - ! '>='
41
46
  - !ruby/object:Gem::Version
42
47
  version: '0'
43
48
  - !ruby/object:Gem::Dependency
44
49
  name: multi_json
45
50
  requirement: !ruby/object:Gem::Requirement
51
+ none: false
46
52
  requirements:
47
- - - '>='
53
+ - - ! '>='
48
54
  - !ruby/object:Gem::Version
49
55
  version: '0'
50
56
  type: :development
51
57
  prerelease: false
52
58
  version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
53
60
  requirements:
54
- - - '>='
61
+ - - ! '>='
55
62
  - !ruby/object:Gem::Version
56
63
  version: '0'
57
64
  - !ruby/object:Gem::Dependency
58
65
  name: rspec
59
66
  requirement: !ruby/object:Gem::Requirement
67
+ none: false
60
68
  requirements:
61
- - - '>='
69
+ - - ! '>='
62
70
  - !ruby/object:Gem::Version
63
71
  version: 2.5.0
64
72
  type: :development
65
73
  prerelease: false
66
74
  version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
67
76
  requirements:
68
- - - '>='
77
+ - - ! '>='
69
78
  - !ruby/object:Gem::Version
70
79
  version: 2.5.0
71
80
  - !ruby/object:Gem::Dependency
72
81
  name: nokogiri
73
82
  requirement: !ruby/object:Gem::Requirement
83
+ none: false
74
84
  requirements:
75
- - - '>='
85
+ - - ! '>='
76
86
  - !ruby/object:Gem::Version
77
87
  version: '0'
78
88
  type: :development
79
89
  prerelease: false
80
90
  version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
81
92
  requirements:
82
- - - '>='
93
+ - - ! '>='
83
94
  - !ruby/object:Gem::Version
84
95
  version: '0'
85
96
  - !ruby/object:Gem::Dependency
86
97
  name: jasmine-core
87
98
  requirement: !ruby/object:Gem::Requirement
99
+ none: false
88
100
  requirements:
89
101
  - - ~>
90
102
  - !ruby/object:Gem::Version
@@ -92,6 +104,7 @@ dependencies:
92
104
  type: :runtime
93
105
  prerelease: false
94
106
  version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
95
108
  requirements:
96
109
  - - ~>
97
110
  - !ruby/object:Gem::Version
@@ -99,43 +112,49 @@ dependencies:
99
112
  - !ruby/object:Gem::Dependency
100
113
  name: rack
101
114
  requirement: !ruby/object:Gem::Requirement
115
+ none: false
102
116
  requirements:
103
- - - '>='
117
+ - - ! '>='
104
118
  - !ruby/object:Gem::Version
105
119
  version: 1.2.1
106
120
  type: :runtime
107
121
  prerelease: false
108
122
  version_requirements: !ruby/object:Gem::Requirement
123
+ none: false
109
124
  requirements:
110
- - - '>='
125
+ - - ! '>='
111
126
  - !ruby/object:Gem::Version
112
127
  version: 1.2.1
113
128
  - !ruby/object:Gem::Dependency
114
129
  name: rake
115
130
  requirement: !ruby/object:Gem::Requirement
131
+ none: false
116
132
  requirements:
117
- - - '>='
133
+ - - ! '>='
118
134
  - !ruby/object:Gem::Version
119
135
  version: '0'
120
136
  type: :runtime
121
137
  prerelease: false
122
138
  version_requirements: !ruby/object:Gem::Requirement
139
+ none: false
123
140
  requirements:
124
- - - '>='
141
+ - - ! '>='
125
142
  - !ruby/object:Gem::Version
126
143
  version: '0'
127
144
  - !ruby/object:Gem::Dependency
128
145
  name: phantomjs
129
146
  requirement: !ruby/object:Gem::Requirement
147
+ none: false
130
148
  requirements:
131
- - - '>='
149
+ - - ! '>='
132
150
  - !ruby/object:Gem::Version
133
151
  version: '0'
134
152
  type: :runtime
135
153
  prerelease: false
136
154
  version_requirements: !ruby/object:Gem::Requirement
155
+ none: false
137
156
  requirements:
138
- - - '>='
157
+ - - ! '>='
139
158
  - !ruby/object:Gem::Version
140
159
  version: '0'
141
160
  description: Test your JavaScript without any framework dependencies, in any environment,
@@ -189,6 +208,7 @@ files:
189
208
  - lib/jasmine/railtie.rb
190
209
  - lib/jasmine/result.rb
191
210
  - lib/jasmine/run.html.erb
211
+ - lib/jasmine/runners/phantom_boot.js
192
212
  - lib/jasmine/runners/phantom_jasmine_run.js
193
213
  - lib/jasmine/runners/phantom_js.rb
194
214
  - lib/jasmine/server.rb
@@ -208,6 +228,7 @@ files:
208
228
  - spec/configuration_spec.rb
209
229
  - spec/fixture/Rakefile
210
230
  - spec/fixture/coffee_spec.coffee
231
+ - spec/fixture/exception_test.js
211
232
  - spec/fixture/failing_runner.rb
212
233
  - spec/fixture/failing_test.js
213
234
  - spec/fixture/large_test_suite_spec.js
@@ -230,27 +251,34 @@ files:
230
251
  homepage: http://pivotal.github.com/jasmine/
231
252
  licenses:
232
253
  - MIT
233
- metadata: {}
234
254
  post_install_message:
235
255
  rdoc_options:
236
256
  - --charset=UTF-8
237
257
  require_paths:
238
258
  - lib
239
259
  required_ruby_version: !ruby/object:Gem::Requirement
260
+ none: false
240
261
  requirements:
241
- - - '>='
262
+ - - ! '>='
242
263
  - !ruby/object:Gem::Version
243
264
  version: '0'
265
+ segments:
266
+ - 0
267
+ hash: 1868816023203409385
244
268
  required_rubygems_version: !ruby/object:Gem::Requirement
269
+ none: false
245
270
  requirements:
246
- - - '>='
271
+ - - ! '>='
247
272
  - !ruby/object:Gem::Version
248
273
  version: '0'
274
+ segments:
275
+ - 0
276
+ hash: 1868816023203409385
249
277
  requirements: []
250
278
  rubyforge_project:
251
- rubygems_version: 2.0.6
279
+ rubygems_version: 1.8.23
252
280
  signing_key:
253
- specification_version: 4
281
+ specification_version: 3
254
282
  summary: JavaScript BDD framework
255
283
  test_files:
256
284
  - spec/application_integration_spec.rb
@@ -259,6 +287,7 @@ test_files:
259
287
  - spec/configuration_spec.rb
260
288
  - spec/fixture/Rakefile
261
289
  - spec/fixture/coffee_spec.coffee
290
+ - spec/fixture/exception_test.js
262
291
  - spec/fixture/failing_runner.rb
263
292
  - spec/fixture/failing_test.js
264
293
  - spec/fixture/large_test_suite_spec.js
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 3a7ce607ec6c8a6bb64af21d08f21d8305dceb95
4
- data.tar.gz: c86fcfa19f64ff33754b2fd6251d1d4c8abc9073
5
- SHA512:
6
- metadata.gz: d0013fece64deeb497579113f9004c4765a1040b6cd5b076c8876bde288488f2a08a0505df12f75bb7e1b48cbb4eb6deec0984c2dde5bfb8ef175a0c7d5abf86
7
- data.tar.gz: e613e70b7b99fd68da008e3f2ae2bba56cc145df85ae9c8053b4bdb062d7324562e9f6bd1561e85288122345a9cf7cecb66782717af663c54122a254a1aed4ec