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.
- checksums.yaml +4 -4
- data/.travis.yml +27 -13
- data/Gemfile +9 -9
- data/HOW_TO_TEST.markdown +1 -0
- data/README.markdown +18 -11
- data/jasmine.gemspec +14 -6
- data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/jasmine_examples/SpecHelper.js +1 -1
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +38 -5
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_helper.rb +14 -9
- data/lib/jasmine/application.rb +2 -2
- data/lib/jasmine/asset_expander.rb +56 -8
- data/lib/jasmine/base.rb +5 -5
- data/lib/jasmine/ci_runner.rb +50 -0
- data/lib/jasmine/command_line_tool.rb +4 -4
- data/lib/jasmine/config.rb +34 -5
- data/lib/jasmine/configuration.rb +31 -11
- data/lib/jasmine/dependencies.rb +8 -37
- data/lib/jasmine/formatters/console.rb +69 -4
- data/lib/jasmine/formatters/exit_code.rb +4 -6
- data/lib/jasmine/formatters/multi.rb +3 -11
- data/lib/jasmine/path_expander.rb +5 -1
- data/lib/jasmine/path_mapper.rb +11 -2
- data/lib/jasmine/railtie.rb +1 -1
- data/lib/jasmine/result.rb +21 -9
- data/lib/jasmine/ruby_versions.rb +11 -0
- data/lib/jasmine/run.html.erb +1 -1
- data/lib/jasmine/runners/phantom_boot.js +15 -0
- data/lib/jasmine/runners/phantom_jasmine_run.js +39 -43
- data/lib/jasmine/runners/phantom_js.rb +53 -8
- data/lib/jasmine/server.rb +7 -10
- data/lib/jasmine/tasks/jasmine.rake +29 -25
- data/lib/jasmine/version.rb +1 -1
- data/lib/jasmine/yaml_config_parser.rb +28 -0
- data/lib/jasmine.rb +1 -1
- data/release_notes/v2.0.1.md +31 -0
- data/release_notes/v2.0.2.md +17 -0
- data/release_notes/v2.0.3.md +31 -0
- data/release_notes/v2.1.0.md +11 -0
- data/release_notes/v2.2.0.md +31 -0
- data/release_notes/v2.3.0.md +27 -0
- data/release_notes/v2.3.1.md +14 -0
- data/release_notes/v2.4.0.md +20 -0
- data/release_notes/v2.5.0.md +35 -0
- data/release_notes/v2.5.1.md +12 -0
- data/release_notes/v2.5.2.md +22 -0
- data/release_notes/v2.6.0.md +17 -0
- data/release_notes/v2.6.1.md +11 -0
- data/release_notes/v2.7.0.md +28 -0
- data/release_notes/v2.8.0.md +21 -0
- data/release_notes/v2.9.0.md +22 -0
- data/release_notes/v2.99.md +13 -0
- data/spec/application_integration_spec.rb +3 -3
- data/spec/application_spec.rb +27 -11
- data/spec/base_spec.rb +27 -6
- data/spec/ci_runner_spec.rb +137 -0
- data/spec/configuration_spec.rb +57 -23
- data/spec/fixture/afterall_spec.js +8 -0
- data/spec/fixture/console_log_spec.js +5 -0
- data/spec/fixture/exception_test.js +1 -0
- data/spec/fixture/phantomConfig.js +6 -0
- data/spec/fixture/viewport_spec.js +6 -0
- data/spec/jasmine_command_line_tool_spec.rb +46 -27
- data/spec/jasmine_pojs_spec.rb +73 -12
- data/spec/jasmine_rails_spec.rb +107 -41
- data/spec/lib/jasmine/formatters/console_spec.rb +124 -26
- data/spec/lib/jasmine/formatters/exit_code_spec.rb +34 -0
- data/spec/lib/jasmine/formatters/multi_spec.rb +16 -6
- data/spec/page_spec.rb +2 -2
- data/spec/path_expander_spec.rb +22 -5
- data/spec/path_mapper_spec.rb +14 -9
- data/spec/performance/phantom_js_runner_performance_spec.rb +1 -1
- data/spec/phantom_js_spec.rb +14 -0
- data/spec/rack/jasmine/runner_spec.rb +2 -2
- data/spec/result_spec.rb +17 -7
- data/spec/server_spec.rb +13 -39
- data/spec/spec_helper.rb +54 -6
- data/spec/yaml_config_parser_spec.rb +21 -21
- metadata +75 -36
- data/lib/jasmine/asset_bundle.rb +0 -68
|
@@ -1,25 +1,44 @@
|
|
|
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, :
|
|
5
|
-
attr_accessor :
|
|
6
|
-
attr_accessor :
|
|
4
|
+
attr_writer :jasmine_files, :boot_files, :src_files, :runner_boot_files
|
|
5
|
+
attr_accessor :helper_files, :spec_files
|
|
6
|
+
attr_accessor :jasmine_path, :spec_path, :boot_path, :src_path, :image_path, :runner_boot_path
|
|
7
|
+
attr_accessor :jasmine_dir, :spec_dir, :boot_dir, :src_dir, :images_dir, :runner_boot_dir
|
|
7
8
|
attr_accessor :formatters
|
|
8
9
|
attr_accessor :host
|
|
9
10
|
attr_accessor :spec_format
|
|
10
11
|
attr_accessor :runner
|
|
12
|
+
attr_accessor :rack_options
|
|
13
|
+
attr_accessor :prevent_phantom_js_auto_install
|
|
14
|
+
attr_accessor :show_console_log
|
|
15
|
+
attr_accessor :stop_spec_on_expectation_failure
|
|
16
|
+
attr_accessor :random
|
|
17
|
+
attr_accessor :phantom_config_script
|
|
18
|
+
attr_accessor :phantom_cli_options
|
|
19
|
+
attr_accessor :show_full_stack_trace
|
|
20
|
+
attr_reader :rack_apps
|
|
11
21
|
|
|
12
22
|
def initialize()
|
|
13
23
|
@rack_paths = {}
|
|
14
|
-
@
|
|
24
|
+
@rack_apps = []
|
|
15
25
|
@path_mappers = []
|
|
16
26
|
@jasmine_css_files = lambda { [] }
|
|
17
27
|
@css_files = lambda { [] }
|
|
18
28
|
@jasmine_files = lambda { [] }
|
|
19
29
|
@boot_files = lambda { [] }
|
|
30
|
+
@runner_boot_files = lambda { [] }
|
|
20
31
|
@src_files = lambda { [] }
|
|
32
|
+
@helper_files = lambda { [] }
|
|
21
33
|
@spec_files = lambda { [] }
|
|
34
|
+
@testing_files = lambda { helper_files.call + spec_files.call}
|
|
22
35
|
@runner = lambda { |config| }
|
|
36
|
+
@rack_options = {}
|
|
37
|
+
@show_console_log = false
|
|
38
|
+
@stop_spec_on_expectation_failure = false
|
|
39
|
+
@random = false
|
|
40
|
+
@phantom_config_script = nil
|
|
41
|
+
@phantom_cli_options = {}
|
|
23
42
|
|
|
24
43
|
@formatters = [Jasmine::Formatters::Console]
|
|
25
44
|
|
|
@@ -34,8 +53,9 @@ module Jasmine
|
|
|
34
53
|
def js_files
|
|
35
54
|
map(@jasmine_files, :jasmine) +
|
|
36
55
|
map(@boot_files, :boot) +
|
|
56
|
+
map(@runner_boot_files, :runner_boot) +
|
|
37
57
|
map(@src_files, :src) +
|
|
38
|
-
map(@
|
|
58
|
+
map(@testing_files, :spec)
|
|
39
59
|
end
|
|
40
60
|
|
|
41
61
|
def rack_path_map
|
|
@@ -46,12 +66,12 @@ module Jasmine
|
|
|
46
66
|
@rack_paths[path] = rack_app_lambda
|
|
47
67
|
end
|
|
48
68
|
|
|
49
|
-
def
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
69
|
+
def add_rack_app(app, *args, &block)
|
|
70
|
+
@rack_apps << {
|
|
71
|
+
:app => app,
|
|
72
|
+
:args => args,
|
|
73
|
+
:block => block
|
|
74
|
+
}
|
|
55
75
|
end
|
|
56
76
|
|
|
57
77
|
def add_path_mapper(mapper)
|
data/lib/jasmine/dependencies.rb
CHANGED
|
@@ -3,55 +3,26 @@ module Jasmine
|
|
|
3
3
|
|
|
4
4
|
class << self
|
|
5
5
|
def rails3?
|
|
6
|
-
|
|
6
|
+
rails? && Rails.version.to_i == 3
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def rails4?
|
|
10
|
-
|
|
10
|
+
rails? && Rails.version.to_i == 4
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def
|
|
14
|
-
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def rails_available?
|
|
18
|
-
safe_gem_check("rails", '>= 3')
|
|
13
|
+
def rails5?
|
|
14
|
+
rails? && Rails.version.to_i == 5
|
|
19
15
|
end
|
|
20
16
|
|
|
21
|
-
def
|
|
22
|
-
|
|
17
|
+
def rails?
|
|
18
|
+
defined?(Rails) && Rails.respond_to?(:version)
|
|
23
19
|
end
|
|
24
20
|
|
|
25
21
|
def use_asset_pipeline?
|
|
26
|
-
assets_pipeline_available = (rails3? || rails4?) && Rails.respond_to?(:application) && Rails.application.respond_to?(:assets)
|
|
22
|
+
assets_pipeline_available = (rails3? || rails4? || rails5?) && Rails.respond_to?(:application) && Rails.application.respond_to?(:assets) && !Rails.application.assets.nil?
|
|
27
23
|
rails3_assets_enabled = rails3? && assets_pipeline_available && Rails.application.config.assets.enabled != false
|
|
28
|
-
assets_pipeline_available && (rails4? || rails3_assets_enabled)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
private
|
|
32
|
-
|
|
33
|
-
def running_rails3?
|
|
34
|
-
running_rails? && Rails.version.to_i == 3
|
|
24
|
+
assets_pipeline_available && (rails4? || rails5? || rails3_assets_enabled)
|
|
35
25
|
end
|
|
36
|
-
|
|
37
|
-
def running_rails4?
|
|
38
|
-
running_rails? && Rails.version.to_i == 4
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def running_rails?
|
|
42
|
-
defined?(Rails) && Rails.respond_to?(:version)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def safe_gem_check(gem_name, version_string)
|
|
46
|
-
if Gem::Specification.respond_to?(:find_by_name)
|
|
47
|
-
Gem::Specification.find_by_name(gem_name, version_string)
|
|
48
|
-
elsif Gem.respond_to?(:available?)
|
|
49
|
-
Gem.available?(gem_name, version_string)
|
|
50
|
-
end
|
|
51
|
-
rescue Gem::LoadError
|
|
52
|
-
false
|
|
53
|
-
end
|
|
54
|
-
|
|
55
26
|
end
|
|
56
27
|
end
|
|
57
28
|
end
|
|
@@ -1,25 +1,52 @@
|
|
|
1
1
|
module Jasmine
|
|
2
2
|
module Formatters
|
|
3
3
|
class Console
|
|
4
|
-
def initialize(outputter = Kernel
|
|
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.
|
|
10
|
+
outputter.print(chars(results_batch))
|
|
11
11
|
@results += results_batch
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def done
|
|
14
|
+
def done(run_details)
|
|
15
|
+
outputter.puts
|
|
16
|
+
|
|
17
|
+
run_result = global_failure_details(run_details)
|
|
18
|
+
|
|
15
19
|
failure_count = results.count(&:failed?)
|
|
20
|
+
if failure_count > 0
|
|
21
|
+
outputter.puts('Failures:')
|
|
22
|
+
outputter.puts(failures(@results))
|
|
23
|
+
outputter.puts
|
|
24
|
+
end
|
|
25
|
+
|
|
16
26
|
pending_count = results.count(&:pending?)
|
|
27
|
+
if pending_count > 0
|
|
28
|
+
outputter.puts('Pending:')
|
|
29
|
+
outputter.puts(pending(@results))
|
|
30
|
+
outputter.puts
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
deprecationWarnings = (@results + [run_result]).map(&:deprecation_warnings).flatten
|
|
34
|
+
if deprecationWarnings.size > 0
|
|
35
|
+
outputter.puts('Deprecations:')
|
|
36
|
+
outputter.puts(deprecations(deprecationWarnings))
|
|
37
|
+
outputter.puts
|
|
38
|
+
end
|
|
39
|
+
|
|
17
40
|
summary = "#{pluralize(results.size, 'spec')}, " +
|
|
18
41
|
"#{pluralize(failure_count, 'failure')}"
|
|
19
42
|
|
|
20
43
|
summary += ", #{pluralize(pending_count, 'pending spec')}" if pending_count > 0
|
|
21
44
|
|
|
22
|
-
outputter.
|
|
45
|
+
outputter.puts(summary)
|
|
46
|
+
|
|
47
|
+
if run_details['order'] && run_details['order']['random']
|
|
48
|
+
outputter.puts("Randomized with seed #{run_details['order']['seed']}")
|
|
49
|
+
end
|
|
23
50
|
end
|
|
24
51
|
|
|
25
52
|
private
|
|
@@ -29,11 +56,49 @@ module Jasmine
|
|
|
29
56
|
results.select(&:failed?).map { |f| failure_message(f) }.join("\n\n")
|
|
30
57
|
end
|
|
31
58
|
|
|
59
|
+
def pending(results)
|
|
60
|
+
results.select(&:pending?).map { |spec| pending_message(spec) }.join("\n\n")
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def deprecations(warnings)
|
|
64
|
+
warnings.map { |w| expectation_message(w) }.join("\n\n")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def global_failure_details(run_details)
|
|
68
|
+
result = Jasmine::Result.new(run_details.merge('fullName' => 'Error occurred in afterAll', 'description' => ''))
|
|
69
|
+
if (result.failed_expectations.size > 0)
|
|
70
|
+
outputter.puts(failure_message(result))
|
|
71
|
+
outputter.puts
|
|
72
|
+
end
|
|
73
|
+
result
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def chars(results)
|
|
77
|
+
results.map do |result|
|
|
78
|
+
if result.succeeded?
|
|
79
|
+
"\e[32m.\e[0m"
|
|
80
|
+
elsif result.pending?
|
|
81
|
+
"\e[33m*\e[0m"
|
|
82
|
+
elsif result.disabled?
|
|
83
|
+
""
|
|
84
|
+
else
|
|
85
|
+
"\e[31mF\e[0m"
|
|
86
|
+
end
|
|
87
|
+
end.join('')
|
|
88
|
+
end
|
|
89
|
+
|
|
32
90
|
def pluralize(count, str)
|
|
33
91
|
word = (count == 1) ? str : str + 's'
|
|
34
92
|
"#{count} #{word}"
|
|
35
93
|
end
|
|
36
94
|
|
|
95
|
+
def pending_message(spec)
|
|
96
|
+
reason = 'No reason given'
|
|
97
|
+
reason = spec.pending_reason if spec.pending_reason && spec.pending_reason != ''
|
|
98
|
+
|
|
99
|
+
"\t#{spec.full_name}\n\t \e[33m#{reason}\e[0m"
|
|
100
|
+
end
|
|
101
|
+
|
|
37
102
|
def failure_message(failure)
|
|
38
103
|
template = <<-FM
|
|
39
104
|
#{failure.full_name}\n
|
|
@@ -3,21 +3,19 @@ module Jasmine
|
|
|
3
3
|
class ExitCode
|
|
4
4
|
def initialize
|
|
5
5
|
@results = []
|
|
6
|
+
@global_failure = false
|
|
6
7
|
end
|
|
7
8
|
|
|
8
9
|
def format(results)
|
|
9
10
|
@results += results
|
|
10
11
|
end
|
|
11
12
|
|
|
12
|
-
def done
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def exit_code
|
|
16
|
-
@results.detect(&:failed?) ? 1 : 0
|
|
13
|
+
def done(details)
|
|
14
|
+
@global_failure = details.fetch('failedExpectations', []).size > 0
|
|
17
15
|
end
|
|
18
16
|
|
|
19
17
|
def succeeded?
|
|
20
|
-
!@results.detect(&:failed?)
|
|
18
|
+
!@results.detect(&:failed?) && !@global_failure
|
|
21
19
|
end
|
|
22
20
|
end
|
|
23
21
|
end
|
|
@@ -6,19 +6,11 @@ module Jasmine
|
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def format(results)
|
|
9
|
-
|
|
9
|
+
@formatters.each { |formatter| formatter.format(results) }
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def done
|
|
13
|
-
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
def go(method, *args)
|
|
19
|
-
(@formatters || []).each do |formatter|
|
|
20
|
-
formatter.public_send(method, *args)
|
|
21
|
-
end
|
|
12
|
+
def done(details = {})
|
|
13
|
+
@formatters.each { |formatter| formatter.done(details) }
|
|
22
14
|
end
|
|
23
15
|
end
|
|
24
16
|
end
|
|
@@ -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
|
-
|
|
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
|
data/lib/jasmine/path_mapper.rb
CHANGED
|
@@ -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
|
|
29
|
+
paths.map do |path|
|
|
30
|
+
if path[0..3] == 'http'
|
|
31
|
+
path
|
|
32
|
+
else
|
|
33
|
+
File.join(add_path, (path.sub(remove_path, '')))
|
|
34
|
+
end
|
|
35
|
+
end
|
|
26
36
|
end
|
|
27
|
-
|
|
28
37
|
end
|
|
29
38
|
end
|
data/lib/jasmine/railtie.rb
CHANGED
|
@@ -3,7 +3,7 @@ require 'rails/railtie'
|
|
|
3
3
|
module Jasmine
|
|
4
4
|
class Railtie < Rails::Railtie
|
|
5
5
|
|
|
6
|
-
|
|
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 '
|
data/lib/jasmine/result.rb
CHANGED
|
@@ -6,11 +6,14 @@ module Jasmine
|
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def initialize(attrs)
|
|
9
|
+
@show_full_stack_trace = attrs["show_full_stack_trace"]
|
|
9
10
|
@status = attrs["status"]
|
|
10
11
|
@full_name = attrs["fullName"]
|
|
11
12
|
@description = attrs["description"]
|
|
12
|
-
@failed_expectations = map_failures(attrs
|
|
13
|
+
@failed_expectations = map_failures(attrs.fetch("failedExpectations", []))
|
|
14
|
+
@deprecation_warnings = map_failures(attrs.fetch("deprecationWarnings", []))
|
|
13
15
|
@suite_name = full_name.slice(0, full_name.size - description.size - 1)
|
|
16
|
+
@pending_reason = attrs["pendingReason"]
|
|
14
17
|
end
|
|
15
18
|
|
|
16
19
|
def succeeded?
|
|
@@ -25,19 +28,28 @@ module Jasmine
|
|
|
25
28
|
status == 'pending'
|
|
26
29
|
end
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
def disabled?
|
|
32
|
+
status == 'disabled'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
attr_reader :full_name, :description, :failed_expectations, :deprecation_warnings, :suite_name, :pending_reason
|
|
29
36
|
|
|
30
37
|
private
|
|
31
|
-
attr_reader :status
|
|
38
|
+
attr_reader :status, :show_full_stack_trace
|
|
32
39
|
|
|
33
40
|
def map_failures(failures)
|
|
34
41
|
failures.map do |e|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
if e["stack"]
|
|
43
|
+
if show_full_stack_trace
|
|
44
|
+
stack = e["stack"]
|
|
45
|
+
else
|
|
46
|
+
stack = e["stack"].split("\n").slice(0, 7).join("\n")
|
|
47
|
+
end
|
|
48
|
+
else
|
|
49
|
+
stack = "No stack trace present."
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
Failure.new(e["message"], stack)
|
|
41
53
|
end
|
|
42
54
|
end
|
|
43
55
|
|
data/lib/jasmine/run.html.erb
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function PhantomReporter() {
|
|
2
|
+
this.jasmineDone = function(details) {
|
|
3
|
+
window.callPhantom({ state: 'jasmineDone', details: details });
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
this.specDone = function(results) {
|
|
7
|
+
window.callPhantom({ state: 'specDone', results: results });
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
this.suiteDone = function(results) {
|
|
11
|
+
window.callPhantom({ state: 'suiteDone', results: results });
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
jasmine.getEnv().addReporter(new PhantomReporter());
|
|
@@ -1,54 +1,50 @@
|
|
|
1
1
|
(function() {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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);
|
|
2
|
+
|
|
3
|
+
if (phantom.version.major >= 2) {
|
|
4
|
+
var system = require('system');
|
|
5
|
+
var url = system.args[1];
|
|
6
|
+
var showConsoleLog = system.args[2] === 'true';
|
|
7
|
+
var configScript = system.args[3];
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
var url = phantom.args[0];
|
|
11
|
+
var showConsoleLog = phantom.args[1] === 'true';
|
|
12
|
+
var configScript = phantom.args[2];
|
|
27
13
|
}
|
|
28
14
|
|
|
29
|
-
var url = phantom.args[0];
|
|
30
|
-
var batchSize = parseInt(phantom.args[1], 10);
|
|
31
15
|
var page = require('webpage').create();
|
|
16
|
+
configScript = configScript.replace(/['"]{2}/,"");
|
|
17
|
+
|
|
18
|
+
if (configScript !== '') {
|
|
19
|
+
try {
|
|
20
|
+
require(configScript).configure(page);
|
|
21
|
+
} catch(e) {
|
|
22
|
+
console.error('Failed to configure phantom');
|
|
23
|
+
console.error(e.stack);
|
|
24
|
+
phantom.exit(1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
page.onCallback = function(data) {
|
|
29
|
+
if(data.state === 'specDone') {
|
|
30
|
+
console.log('jasmine_spec_result' + JSON.stringify([].concat(data.results)));
|
|
31
|
+
} else if (data.state === 'suiteDone') {
|
|
32
|
+
console.log('jasmine_suite_result' + JSON.stringify([].concat(data.results)));
|
|
33
|
+
} else {
|
|
34
|
+
console.log('jasmine_done' + JSON.stringify(data.details));
|
|
35
|
+
phantom.exit(0);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (showConsoleLog) {
|
|
40
|
+
page.onConsoleMessage = function(message) {
|
|
41
|
+
console.log(message);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
32
44
|
|
|
33
45
|
page.open(url, function(status) {
|
|
34
46
|
if (status !== "success") {
|
|
35
47
|
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
48
|
}
|
|
53
49
|
});
|
|
54
50
|
}).call(this);
|
|
@@ -3,26 +3,71 @@ require 'phantomjs'
|
|
|
3
3
|
module Jasmine
|
|
4
4
|
module Runners
|
|
5
5
|
class PhantomJs
|
|
6
|
-
def initialize(formatter, jasmine_server_url,
|
|
6
|
+
def initialize(formatter, jasmine_server_url, prevent_phantom_js_auto_install, show_console_log, phantom_config_script, show_full_stack_trace, cli_options = nil)
|
|
7
7
|
@formatter = formatter
|
|
8
8
|
@jasmine_server_url = jasmine_server_url
|
|
9
|
-
@
|
|
9
|
+
@prevent_phantom_js_auto_install = prevent_phantom_js_auto_install
|
|
10
|
+
@show_console_log = show_console_log
|
|
11
|
+
@phantom_config_script = phantom_config_script
|
|
12
|
+
@show_full_stack_trace = show_full_stack_trace
|
|
13
|
+
@cli_options = cli_options || {}
|
|
10
14
|
end
|
|
11
15
|
|
|
12
16
|
def run
|
|
13
|
-
|
|
17
|
+
phantom_script = File.join(File.dirname(__FILE__), 'phantom_jasmine_run.js')
|
|
18
|
+
command = "\"#{phantom_js_path}\" \"#{cli_options_string}\" \"#{phantom_script}\" \"#{jasmine_server_url}\" \"#{show_console_log}\" \"#{@phantom_config_script}\""
|
|
19
|
+
run_details = { 'random' => false }
|
|
14
20
|
IO.popen(command) do |output|
|
|
15
21
|
output.each do |line|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
if line =~ /^jasmine_spec_result/
|
|
23
|
+
line = line.sub(/^jasmine_spec_result/, '')
|
|
24
|
+
raw_results = JSON.parse(line, :max_nesting => false)
|
|
25
|
+
results = raw_results.map { |r| Result.new(r.merge!("show_full_stack_trace" => @show_full_stack_trace)) }
|
|
26
|
+
formatter.format(results)
|
|
27
|
+
elsif line =~ /^jasmine_suite_result/
|
|
28
|
+
line = line.sub(/^jasmine_suite_result/, '')
|
|
29
|
+
raw_results = JSON.parse(line, :max_nesting => false)
|
|
30
|
+
results = raw_results.map { |r| Result.new(r.merge!("show_full_stack_trace" => @show_full_stack_trace)) }
|
|
31
|
+
failures = results.select(&:failed?)
|
|
32
|
+
if failures.any?
|
|
33
|
+
formatter.format(failures)
|
|
34
|
+
end
|
|
35
|
+
elsif line =~ /^jasmine_done/
|
|
36
|
+
line = line.sub(/^jasmine_done/, '')
|
|
37
|
+
run_details = JSON.parse(line, :max_nesting => false)
|
|
38
|
+
elsif line =~ /^Failed to configure phantom$/
|
|
39
|
+
config_failure = Result.new('fullName' => line,
|
|
40
|
+
'failedExpectations' => [],
|
|
41
|
+
'description' => '',
|
|
42
|
+
'status' => 'failed',
|
|
43
|
+
'show_full_stack_trace' => @show_full_stack_trace)
|
|
44
|
+
formatter.format([config_failure])
|
|
45
|
+
@show_console_log = true
|
|
46
|
+
puts line
|
|
47
|
+
elsif show_console_log
|
|
48
|
+
puts line
|
|
49
|
+
end
|
|
19
50
|
end
|
|
20
51
|
end
|
|
21
|
-
formatter.done
|
|
52
|
+
formatter.done(run_details)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def phantom_js_path
|
|
56
|
+
prevent_phantom_js_auto_install ? 'phantomjs' : Phantomjs.path
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def boot_js
|
|
60
|
+
File.expand_path('phantom_boot.js', File.dirname(__FILE__))
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def cli_options_string
|
|
64
|
+
@cli_options.
|
|
65
|
+
map {|(k, v)| "--#{k}=#{v}"}.
|
|
66
|
+
join(' ')
|
|
22
67
|
end
|
|
23
68
|
|
|
24
69
|
private
|
|
25
|
-
attr_reader :formatter, :jasmine_server_url, :
|
|
70
|
+
attr_reader :formatter, :jasmine_server_url, :prevent_phantom_js_auto_install, :show_console_log
|
|
26
71
|
end
|
|
27
72
|
end
|
|
28
73
|
end
|
data/lib/jasmine/server.rb
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
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, env = ENV)
|
|
4
4
|
@port = port
|
|
5
5
|
@application = application
|
|
6
|
+
@rack_options = rack_options || {}
|
|
7
|
+
@env = env
|
|
6
8
|
end
|
|
7
9
|
|
|
8
10
|
def start
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
server = Rack::Server.new(:Port => @port, :AccessLog => [])
|
|
14
|
-
# workaround for Rack bug, when Rack > 1.2.1 is released Rack::Server.start(:app => Jasmine.app(self)) will work
|
|
15
|
-
server.instance_variable_set(:@app, @application)
|
|
16
|
-
server.start
|
|
17
|
-
end
|
|
11
|
+
@env['PORT'] = @port.to_s
|
|
12
|
+
Rack::Server.start(@rack_options.merge(:Port => @port,
|
|
13
|
+
:AccessLog => [],
|
|
14
|
+
:app => @application))
|
|
18
15
|
end
|
|
19
16
|
end
|
|
20
17
|
end
|