rally-jasmine 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +13 -0
- data/.rspec +1 -0
- data/.travis.yml +58 -0
- data/Gemfile +8 -0
- data/HOW_TO_TEST.markdown +9 -0
- data/MIT.LICENSE +20 -0
- data/README.markdown +77 -0
- data/RELEASE.markdown +22 -0
- data/RELEASE_NOTES.markdown +6 -0
- data/Rakefile +53 -0
- data/bin/jasmine +6 -0
- data/generators/jasmine/jasmine_generator.rb +24 -0
- data/generators/jasmine/templates/INSTALL +9 -0
- data/generators/jasmine/templates/jasmine-example/SpecRunner.html +54 -0
- data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +58 -0
- data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +9 -0
- data/generators/jasmine/templates/jasmine-example/src/Player.js +22 -0
- data/generators/jasmine/templates/jasmine-example/src/Song.js +7 -0
- data/generators/jasmine/templates/lib/tasks/jasmine.rake +8 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +73 -0
- data/lib/generators/jasmine/examples/USAGE +11 -0
- data/lib/generators/jasmine/examples/examples_generator.rb +19 -0
- data/lib/generators/jasmine/examples/templates/app/assets/javascripts/jasmine_examples/Player.js +22 -0
- data/lib/generators/jasmine/examples/templates/app/assets/javascripts/jasmine_examples/Song.js +7 -0
- data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +9 -0
- data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +58 -0
- data/lib/generators/jasmine/install/USAGE +11 -0
- data/lib/generators/jasmine/install/install_generator.rb +18 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/helpers/.gitkeep +0 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +76 -0
- data/lib/jasmine/application.rb +43 -0
- data/lib/jasmine/asset_pipeline_mapper.rb +19 -0
- data/lib/jasmine/base.rb +50 -0
- data/lib/jasmine/command_line_tool.rb +70 -0
- data/lib/jasmine/config.rb +121 -0
- data/lib/jasmine/dependencies.rb +59 -0
- data/lib/jasmine/firebug/firebug-1.6.2.xpi +0 -0
- data/lib/jasmine/firebug/firebug-1.7.0.xpi +0 -0
- data/lib/jasmine/firebug/firebug-license.txt +30 -0
- data/lib/jasmine/firebug/firebug.rb +30 -0
- data/lib/jasmine/page.rb +11 -0
- data/lib/jasmine/railtie.rb +21 -0
- data/lib/jasmine/results.rb +19 -0
- data/lib/jasmine/results_processor.rb +37 -0
- data/lib/jasmine/rspec_formatter.rb +92 -0
- data/lib/jasmine/run.html.erb +55 -0
- data/lib/jasmine/run_specs.rb +32 -0
- data/lib/jasmine/runner_config.rb +71 -0
- data/lib/jasmine/runners/http.rb +71 -0
- data/lib/jasmine/selenium_driver.rb +52 -0
- data/lib/jasmine/server.rb +20 -0
- data/lib/jasmine/sprockets_mapper.rb +13 -0
- data/lib/jasmine/tasks/jasmine.rake +56 -0
- data/lib/jasmine/tasks/jasmine_rails3.rake +1 -0
- data/lib/jasmine/version.rb +3 -0
- data/lib/jasmine.rb +23 -0
- data/lib/rack/jasmine/cache_control.rb +20 -0
- data/lib/rack/jasmine/focused_suite.rb +17 -0
- data/lib/rack/jasmine/redirect.rb +20 -0
- data/lib/rack/jasmine/runner.rb +27 -0
- data/spec/application_spec.rb +99 -0
- data/spec/asset_pipeline_mapper_spec.rb +18 -0
- data/spec/config_spec.rb +309 -0
- data/spec/dependencies_spec.rb +327 -0
- data/spec/fixture/Rakefile +4 -0
- data/spec/fixture/jasmine.erb.yml +4 -0
- data/spec/fixture/spec/example_spec.js +5 -0
- data/spec/fixture/src/example.js +3 -0
- data/spec/jasmine_command_line_tool_rakeless_spec.rb +20 -0
- data/spec/jasmine_command_line_tool_spec.rb +29 -0
- data/spec/jasmine_pojs_spec.rb +47 -0
- data/spec/jasmine_rails2_spec.rb +89 -0
- data/spec/jasmine_rails3_spec.rb +69 -0
- data/spec/jasmine_self_test_config.rb +19 -0
- data/spec/jasmine_self_test_spec.rb +22 -0
- data/spec/page_spec.rb +25 -0
- data/spec/rack/jasmine/runner_spec.rb +25 -0
- data/spec/results_processor_spec.rb +3 -0
- data/spec/results_spec.rb +27 -0
- data/spec/rspec_formatter_spec.rb +88 -0
- data/spec/runner_config_spec.rb +136 -0
- data/spec/server_spec.rb +48 -0
- data/spec/spec_helper.rb +55 -0
- data/spec/sprockets_mapper_spec.rb +17 -0
- metadata +319 -0
data/lib/generators/jasmine/examples/templates/app/assets/javascripts/jasmine_examples/Player.js
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
function Player() {
|
2
|
+
}
|
3
|
+
Player.prototype.play = function(song) {
|
4
|
+
this.currentlyPlayingSong = song;
|
5
|
+
this.isPlaying = true;
|
6
|
+
};
|
7
|
+
|
8
|
+
Player.prototype.pause = function() {
|
9
|
+
this.isPlaying = false;
|
10
|
+
};
|
11
|
+
|
12
|
+
Player.prototype.resume = function() {
|
13
|
+
if (this.isPlaying) {
|
14
|
+
throw new Error("song is already playing");
|
15
|
+
}
|
16
|
+
|
17
|
+
this.isPlaying = true;
|
18
|
+
};
|
19
|
+
|
20
|
+
Player.prototype.makeFavorite = function() {
|
21
|
+
this.currentlyPlayingSong.persistFavoriteStatus(true);
|
22
|
+
};
|
data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
describe("Player", function() {
|
2
|
+
var player;
|
3
|
+
var song;
|
4
|
+
|
5
|
+
beforeEach(function() {
|
6
|
+
player = new Player();
|
7
|
+
song = new Song();
|
8
|
+
});
|
9
|
+
|
10
|
+
it("should be able to play a Song", function() {
|
11
|
+
player.play(song);
|
12
|
+
expect(player.currentlyPlayingSong).toEqual(song);
|
13
|
+
|
14
|
+
//demonstrates use of custom matcher
|
15
|
+
expect(player).toBePlaying(song);
|
16
|
+
});
|
17
|
+
|
18
|
+
describe("when song has been paused", function() {
|
19
|
+
beforeEach(function() {
|
20
|
+
player.play(song);
|
21
|
+
player.pause();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("should indicate that the song is currently paused", function() {
|
25
|
+
expect(player.isPlaying).toBeFalsy();
|
26
|
+
|
27
|
+
// demonstrates use of 'not' with a custom matcher
|
28
|
+
expect(player).not.toBePlaying(song);
|
29
|
+
});
|
30
|
+
|
31
|
+
it("should be possible to resume", function() {
|
32
|
+
player.resume();
|
33
|
+
expect(player.isPlaying).toBeTruthy();
|
34
|
+
expect(player.currentlyPlayingSong).toEqual(song);
|
35
|
+
});
|
36
|
+
});
|
37
|
+
|
38
|
+
// demonstrates use of spies to intercept and test method calls
|
39
|
+
it("tells the current song if the user has made it a favorite", function() {
|
40
|
+
spyOn(song, 'persistFavoriteStatus');
|
41
|
+
|
42
|
+
player.play(song);
|
43
|
+
player.makeFavorite();
|
44
|
+
|
45
|
+
expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
|
46
|
+
});
|
47
|
+
|
48
|
+
//demonstrates use of expected exceptions
|
49
|
+
describe("#resume", function() {
|
50
|
+
it("should throw an exception if song is already playing", function() {
|
51
|
+
player.play(song);
|
52
|
+
|
53
|
+
expect(function() {
|
54
|
+
player.resume();
|
55
|
+
}).toThrow("song is already playing");
|
56
|
+
});
|
57
|
+
});
|
58
|
+
});
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Description:
|
2
|
+
Install jasmine
|
3
|
+
|
4
|
+
Example:
|
5
|
+
rails generate jasmine:install
|
6
|
+
|
7
|
+
This will create:
|
8
|
+
spec/javascripts/support/jasmine.yml
|
9
|
+
spec/javascripts/support/jasmine_config.rb
|
10
|
+
spec/javascripts/support/jasmine_runner.rb
|
11
|
+
spec/javascripts/helpers/.gitkeep
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Jasmine
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
def self.source_root
|
6
|
+
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
7
|
+
end
|
8
|
+
|
9
|
+
def copy_spec_files
|
10
|
+
directory 'spec'
|
11
|
+
end
|
12
|
+
|
13
|
+
def app_name
|
14
|
+
Rails.application.class.name
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
File without changes
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# src_files
|
2
|
+
#
|
3
|
+
# Return an array of filepaths relative to src_dir to include before jasmine specs.
|
4
|
+
# Default: []
|
5
|
+
#
|
6
|
+
# EXAMPLE:
|
7
|
+
#
|
8
|
+
# src_files:
|
9
|
+
# - lib/source1.js
|
10
|
+
# - lib/source2.js
|
11
|
+
# - dist/**/*.js
|
12
|
+
#
|
13
|
+
src_files:
|
14
|
+
- assets/application.js
|
15
|
+
|
16
|
+
# stylesheets
|
17
|
+
#
|
18
|
+
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
|
19
|
+
# Default: []
|
20
|
+
#
|
21
|
+
# EXAMPLE:
|
22
|
+
#
|
23
|
+
# stylesheets:
|
24
|
+
# - css/style.css
|
25
|
+
# - stylesheets/*.css
|
26
|
+
#
|
27
|
+
stylesheets:
|
28
|
+
- stylesheets/**/*.css
|
29
|
+
|
30
|
+
# helpers
|
31
|
+
#
|
32
|
+
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
|
33
|
+
# Default: ["helpers/**/*.js"]
|
34
|
+
#
|
35
|
+
# EXAMPLE:
|
36
|
+
#
|
37
|
+
# helpers:
|
38
|
+
# - helpers/**/*.js
|
39
|
+
#
|
40
|
+
helpers:
|
41
|
+
- helpers/**/*.js
|
42
|
+
|
43
|
+
# spec_files
|
44
|
+
#
|
45
|
+
# Return an array of filepaths relative to spec_dir to include.
|
46
|
+
# Default: ["**/*[sS]pec.js"]
|
47
|
+
#
|
48
|
+
# EXAMPLE:
|
49
|
+
#
|
50
|
+
# spec_files:
|
51
|
+
# - **/*[sS]pec.js
|
52
|
+
#
|
53
|
+
spec_files:
|
54
|
+
- '**/*[sS]pec.js'
|
55
|
+
|
56
|
+
# src_dir
|
57
|
+
#
|
58
|
+
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
|
59
|
+
# Default: project root
|
60
|
+
#
|
61
|
+
# EXAMPLE:
|
62
|
+
#
|
63
|
+
# src_dir: public
|
64
|
+
#
|
65
|
+
src_dir:
|
66
|
+
|
67
|
+
# spec_dir
|
68
|
+
#
|
69
|
+
# Spec directory path. Your spec_files must be returned relative to this path.
|
70
|
+
# Default: spec/javascripts
|
71
|
+
#
|
72
|
+
# EXAMPLE:
|
73
|
+
#
|
74
|
+
# spec_dir: spec/javascripts
|
75
|
+
#
|
76
|
+
spec_dir: spec/javascripts
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rack'
|
2
|
+
require 'rack/utils'
|
3
|
+
require 'jasmine-core'
|
4
|
+
require 'rack/jasmine/runner'
|
5
|
+
require 'rack/jasmine/focused_suite'
|
6
|
+
require 'rack/jasmine/redirect'
|
7
|
+
require 'rack/jasmine/cache_control'
|
8
|
+
require 'ostruct'
|
9
|
+
|
10
|
+
module Jasmine
|
11
|
+
class Application
|
12
|
+
def self.app(config = Jasmine::RunnerConfig.new)
|
13
|
+
page = Jasmine::Page.new(config)
|
14
|
+
if Jasmine::Dependencies.rails_3_asset_pipeline?
|
15
|
+
config.src_mapper = Jasmine::AssetPipelineMapper.new
|
16
|
+
end
|
17
|
+
Rack::Builder.app do
|
18
|
+
use Rack::Head
|
19
|
+
use Rack::Jasmine::CacheControl
|
20
|
+
if Jasmine::Dependencies.rails_3_asset_pipeline?
|
21
|
+
map('/assets') do
|
22
|
+
run Rails.application.assets
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
map('/run.html') { run Rack::Jasmine::Redirect.new('/') }
|
27
|
+
map('/__suite__') { run Rack::Jasmine::FocusedSuite.new(config) }
|
28
|
+
|
29
|
+
#TODO: These path mappings should come from the config.
|
30
|
+
map('/__JASMINE_ROOT__') { run Rack::File.new(Jasmine::Core.path) }
|
31
|
+
map(config.spec_path) { run Rack::File.new(config.spec_dir) }
|
32
|
+
map(config.root_path) { run Rack::File.new(config.project_root) }
|
33
|
+
|
34
|
+
map('/') do
|
35
|
+
run Rack::Cascade.new([
|
36
|
+
Rack::URLMap.new('/' => Rack::File.new(config.src_dir)),
|
37
|
+
Rack::Jasmine::Runner.new(page)
|
38
|
+
])
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Jasmine::AssetPipelineMapper
|
2
|
+
|
3
|
+
def self.context
|
4
|
+
context = ::Rails.application.assets.context_class
|
5
|
+
context.extend(::Sprockets::Helpers::IsolatedHelper)
|
6
|
+
context.extend(::Sprockets::Helpers::RailsHelper)
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(context = Jasmine::AssetPipelineMapper.context)
|
10
|
+
@context = context
|
11
|
+
end
|
12
|
+
|
13
|
+
def files(src_files)
|
14
|
+
src_files.map do |src_file|
|
15
|
+
filename = src_file.gsub(/^assets\//, '').gsub(/\.js$/, '')
|
16
|
+
@context.asset_paths.asset_for(filename, 'js').to_a.map { |p| @context.asset_path(p).gsub(/^\//, '') + "?body=true" }
|
17
|
+
end.flatten.uniq
|
18
|
+
end
|
19
|
+
end
|
data/lib/jasmine/base.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
module Jasmine
|
5
|
+
# this seemingly-over-complex method is necessary to get an open port on at least some of our Macs
|
6
|
+
def self.open_socket_on_unused_port
|
7
|
+
infos = Socket::getaddrinfo("localhost", nil, Socket::AF_UNSPEC, Socket::SOCK_STREAM, 0, Socket::AI_PASSIVE)
|
8
|
+
families = Hash[*infos.collect { |af, *_| af }.uniq.zip([]).flatten]
|
9
|
+
|
10
|
+
return TCPServer.open('0.0.0.0', 0) if families.has_key?('AF_INET')
|
11
|
+
return TCPServer.open('::', 0) if families.has_key?('AF_INET6')
|
12
|
+
return TCPServer.open(0)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.find_unused_port
|
16
|
+
socket = open_socket_on_unused_port
|
17
|
+
port = socket.addr[1]
|
18
|
+
socket.close
|
19
|
+
port
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.server_is_listening_on(hostname, port)
|
23
|
+
require 'socket'
|
24
|
+
begin
|
25
|
+
socket = TCPSocket.open(hostname, port)
|
26
|
+
rescue Errno::ECONNREFUSED
|
27
|
+
return false
|
28
|
+
end
|
29
|
+
socket.close
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.wait_for_listener(port, name = "required process", seconds_to_wait = 20)
|
34
|
+
time_out_at = Time.now + seconds_to_wait
|
35
|
+
until server_is_listening_on "localhost", port
|
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
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.runner_filepath
|
43
|
+
File.expand_path(File.join(File.dirname(__FILE__), "run_specs.rb"))
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.runner_template
|
47
|
+
File.read(File.join(File.dirname(__FILE__), "run.html.erb"))
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Jasmine
|
2
|
+
class CommandLineTool
|
3
|
+
def cwd
|
4
|
+
File.expand_path(File.join(File.dirname(__FILE__), '../..'))
|
5
|
+
end
|
6
|
+
|
7
|
+
def expand(*paths)
|
8
|
+
File.expand_path(File.join(*paths))
|
9
|
+
end
|
10
|
+
|
11
|
+
def template_path(filepath)
|
12
|
+
expand(cwd, File.join("generators", "jasmine" ,"templates", filepath))
|
13
|
+
end
|
14
|
+
|
15
|
+
def dest_path(filepath)
|
16
|
+
expand(Dir.pwd, filepath)
|
17
|
+
end
|
18
|
+
|
19
|
+
def copy_unless_exists(relative_path, dest_path = nil)
|
20
|
+
unless File.exist?(dest_path(relative_path))
|
21
|
+
FileUtils.copy(template_path(relative_path), dest_path(dest_path || relative_path))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def process(argv)
|
26
|
+
if argv[0] == 'init'
|
27
|
+
require 'fileutils'
|
28
|
+
|
29
|
+
FileUtils.makedirs('public/javascripts')
|
30
|
+
FileUtils.makedirs('spec/javascripts')
|
31
|
+
FileUtils.makedirs('spec/javascripts/support')
|
32
|
+
FileUtils.makedirs('spec/javascripts/helpers')
|
33
|
+
|
34
|
+
copy_unless_exists('jasmine-example/src/Player.js', 'public/javascripts/Player.js')
|
35
|
+
copy_unless_exists('jasmine-example/src/Song.js', 'public/javascripts/Song.js')
|
36
|
+
copy_unless_exists('jasmine-example/spec/PlayerSpec.js', 'spec/javascripts/PlayerSpec.js')
|
37
|
+
copy_unless_exists('jasmine-example/spec/SpecHelper.js', 'spec/javascripts/helpers/SpecHelper.js')
|
38
|
+
|
39
|
+
rails_tasks_dir = dest_path('lib/tasks')
|
40
|
+
if File.exist?(rails_tasks_dir)
|
41
|
+
copy_unless_exists('lib/tasks/jasmine.rake')
|
42
|
+
copy_unless_exists('spec/javascripts/support/jasmine-rails.yml', 'spec/javascripts/support/jasmine.yml')
|
43
|
+
else
|
44
|
+
copy_unless_exists('spec/javascripts/support/jasmine.yml')
|
45
|
+
require 'rake'
|
46
|
+
write_mode = 'w'
|
47
|
+
if File.exist?(dest_path('Rakefile'))
|
48
|
+
load dest_path('Rakefile')
|
49
|
+
write_mode = 'a'
|
50
|
+
end
|
51
|
+
|
52
|
+
unless Rake::Task.task_defined?('jasmine')
|
53
|
+
File.open(dest_path('Rakefile'), write_mode) do |f|
|
54
|
+
f.write("\n" + File.read(template_path('lib/tasks/jasmine.rake')))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
File.open(template_path('INSTALL'), 'r').each_line do |line|
|
59
|
+
puts line
|
60
|
+
end
|
61
|
+
elsif argv[0] == "license"
|
62
|
+
puts File.new(expand(cwd, "MIT.LICENSE")).read
|
63
|
+
else
|
64
|
+
puts "unknown command #{argv}"
|
65
|
+
puts "Usage: jasmine init"
|
66
|
+
puts " license"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module Jasmine
|
2
|
+
class Config
|
3
|
+
attr_accessor :src_mapper
|
4
|
+
|
5
|
+
require 'yaml'
|
6
|
+
require 'erb'
|
7
|
+
|
8
|
+
def match_files(dir, patterns)
|
9
|
+
dir = File.expand_path(dir)
|
10
|
+
negative, positive = patterns.partition {|pattern| /^!/ =~ pattern}
|
11
|
+
chosen, negated = [positive, negative].collect do |patterns|
|
12
|
+
patterns.collect do |pattern|
|
13
|
+
matches = Dir.glob(File.join(dir, pattern.gsub(/^!/,'')))
|
14
|
+
matches.empty? && !(pattern =~ /\*|^\!/) ? pattern : matches.collect {|f| f.sub("#{dir}/", "")}.sort
|
15
|
+
end.flatten.uniq
|
16
|
+
end
|
17
|
+
chosen - negated
|
18
|
+
end
|
19
|
+
|
20
|
+
def simple_config
|
21
|
+
config = File.exist?(simple_config_file) ? YAML::load(ERB.new(File.read(simple_config_file)).result(binding)) : false
|
22
|
+
config || {}
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def spec_path
|
27
|
+
"/__spec__"
|
28
|
+
end
|
29
|
+
|
30
|
+
def root_path
|
31
|
+
"/__root__"
|
32
|
+
end
|
33
|
+
|
34
|
+
def js_files(spec_filter = nil)
|
35
|
+
spec_files_to_include = spec_filter.nil? ? spec_files : match_files(spec_dir, [spec_filter])
|
36
|
+
src_files.collect {|f| "/" + f } + helpers.collect {|f| File.join(spec_path, f) } + spec_files_to_include.collect {|f| File.join(spec_path, f) }
|
37
|
+
end
|
38
|
+
|
39
|
+
def user_stylesheets
|
40
|
+
stylesheets.collect {|f| "/" + f }
|
41
|
+
end
|
42
|
+
|
43
|
+
def spec_files_full_paths
|
44
|
+
spec_files.collect {|spec_file| File.join(spec_dir, spec_file) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def project_root
|
48
|
+
Dir.pwd
|
49
|
+
end
|
50
|
+
|
51
|
+
def simple_config_file
|
52
|
+
File.join(project_root, 'spec/javascripts/support/jasmine.yml')
|
53
|
+
end
|
54
|
+
|
55
|
+
def src_dir
|
56
|
+
if simple_config['src_dir']
|
57
|
+
File.join(project_root, simple_config['src_dir'])
|
58
|
+
else
|
59
|
+
project_root
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def spec_dir
|
64
|
+
if simple_config['spec_dir']
|
65
|
+
File.join(project_root, simple_config['spec_dir'])
|
66
|
+
else
|
67
|
+
File.join(project_root, 'spec/javascripts')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def helpers
|
72
|
+
if simple_config['helpers']
|
73
|
+
match_files(spec_dir, simple_config['helpers'])
|
74
|
+
else
|
75
|
+
match_files(spec_dir, ["helpers/**/*.js"])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def src_files
|
80
|
+
return [] unless simple_config['src_files']
|
81
|
+
|
82
|
+
if self.src_mapper
|
83
|
+
self.src_mapper.files(simple_config['src_files'])
|
84
|
+
else
|
85
|
+
match_files(src_dir, simple_config['src_files'])
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def spec_files
|
90
|
+
if simple_config['spec_files']
|
91
|
+
match_files(spec_dir, simple_config['spec_files'])
|
92
|
+
else
|
93
|
+
match_files(spec_dir, ["**/*[sS]pec.js"])
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def stylesheets
|
98
|
+
if simple_config['stylesheets']
|
99
|
+
match_files(src_dir, simple_config['stylesheets'])
|
100
|
+
else
|
101
|
+
[]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def jasmine_host
|
106
|
+
ENV["JASMINE_HOST"] || 'http://localhost'
|
107
|
+
end
|
108
|
+
|
109
|
+
def port
|
110
|
+
@port ||= ENV["JASMINE_PORT"] || Jasmine.find_unused_port
|
111
|
+
end
|
112
|
+
|
113
|
+
def jasmine_stylesheets
|
114
|
+
::Jasmine::Core.css_files.map {|f| "/__JASMINE_ROOT__/#{f}"}
|
115
|
+
end
|
116
|
+
|
117
|
+
def jasmine_javascripts
|
118
|
+
::Jasmine::Core.js_files.map {|f| "/__JASMINE_ROOT__/#{f}" }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Jasmine
|
2
|
+
module Dependencies
|
3
|
+
|
4
|
+
class << self
|
5
|
+
def rspec2?
|
6
|
+
safe_gem_check("rspec", ">= 2.0")
|
7
|
+
end
|
8
|
+
|
9
|
+
def rails2?
|
10
|
+
safe_gem_check("rails", "~> 2.3") && running_rails2?
|
11
|
+
end
|
12
|
+
|
13
|
+
def legacy_rails?
|
14
|
+
safe_gem_check("rails", "< 2.3.11") && running_legacy_rails?
|
15
|
+
end
|
16
|
+
|
17
|
+
def rails3?
|
18
|
+
safe_gem_check("rails", ">= 3.0") && running_rails3?
|
19
|
+
end
|
20
|
+
|
21
|
+
def legacy_rack?
|
22
|
+
!Rack.constants.include?(:Server)
|
23
|
+
end
|
24
|
+
|
25
|
+
def rails_3_asset_pipeline?
|
26
|
+
rails3? && Rails.respond_to?(:application) && Rails.application.respond_to?(:assets) && Rails.application.assets
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def running_legacy_rails?
|
32
|
+
running_rails? && (Gem::Version.new(Rails.version) < Gem::Version.new("2.3.11"))
|
33
|
+
end
|
34
|
+
|
35
|
+
def running_rails2?
|
36
|
+
running_rails? && Rails.version.to_i == 2
|
37
|
+
end
|
38
|
+
|
39
|
+
def running_rails3?
|
40
|
+
running_rails? && Rails.version.to_i == 3
|
41
|
+
end
|
42
|
+
|
43
|
+
def running_rails?
|
44
|
+
defined?(Rails) && Rails.respond_to?(:version)
|
45
|
+
end
|
46
|
+
|
47
|
+
def safe_gem_check(gem_name, version_string)
|
48
|
+
if Gem::Specification.respond_to?(:find_by_name)
|
49
|
+
Gem::Specification.find_by_name(gem_name, version_string)
|
50
|
+
elsif Gem.respond_to?(:available?)
|
51
|
+
Gem.available?(gem_name, version_string)
|
52
|
+
end
|
53
|
+
rescue Gem::LoadError
|
54
|
+
false
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Software License Agreement (BSD License)
|
2
|
+
|
3
|
+
Copyright (c) 2007, Parakey Inc.
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use of this software in source and binary forms, with or without modification,
|
7
|
+
are permitted provided that the following conditions are met:
|
8
|
+
|
9
|
+
* Redistributions of source code must retain the above
|
10
|
+
copyright notice, this list of conditions and the
|
11
|
+
following disclaimer.
|
12
|
+
|
13
|
+
* Redistributions in binary form must reproduce the above
|
14
|
+
copyright notice, this list of conditions and the
|
15
|
+
following disclaimer in the documentation and/or other
|
16
|
+
materials provided with the distribution.
|
17
|
+
|
18
|
+
* Neither the name of Parakey Inc. nor the names of its
|
19
|
+
contributors may be used to endorse or promote products
|
20
|
+
derived from this software without specific prior
|
21
|
+
written permission of Parakey Inc.
|
22
|
+
|
23
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
24
|
+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
26
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
27
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
28
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
29
|
+
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
30
|
+
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'selenium/webdriver'
|
2
|
+
|
3
|
+
class Selenium::WebDriver::Firefox::Profile
|
4
|
+
def self.firebug_version
|
5
|
+
@firebug_version ||= '1.6.2'
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.firebug_version=(version)
|
9
|
+
@firebug_version = version
|
10
|
+
end
|
11
|
+
|
12
|
+
def enable_firebug(version = nil)
|
13
|
+
version ||= Selenium::WebDriver::Firefox::Profile.firebug_version
|
14
|
+
add_extension(File.expand_path("../firebug-#{version}.xpi", __FILE__))
|
15
|
+
|
16
|
+
# Prevent "Welcome!" tab
|
17
|
+
self["extensions.firebug.currentVersion"] = "999"
|
18
|
+
|
19
|
+
# Enable for all sites.
|
20
|
+
self["extensions.firebug.allPagesActivation"] = "on"
|
21
|
+
|
22
|
+
# Enable all features.
|
23
|
+
['console', 'net', 'script'].each do |feature|
|
24
|
+
self["extensions.firebug.#{feature}.enableSites"] = true
|
25
|
+
end
|
26
|
+
|
27
|
+
# Open by default.
|
28
|
+
self["extensions.firebug.previousPlacement"] = 1
|
29
|
+
end
|
30
|
+
end
|
data/lib/jasmine/page.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "rails/railtie"
|
2
|
+
module Jasmine
|
3
|
+
class Railtie < Rails::Railtie
|
4
|
+
|
5
|
+
config.before_configuration do
|
6
|
+
old_jasmine_rakefile = ::Rails.root.join('lib', 'tasks', 'jasmine.rake')
|
7
|
+
if old_jasmine_rakefile.exist? && !ENV["USE_JASMINE_RAKE"]
|
8
|
+
puts %Q{
|
9
|
+
You no longer need to have jasmine.rake in your project, as it is now automatically loaded
|
10
|
+
from the Jasmine gem. To silence this warning, set "USE_JASMINE_RAKE=true" in your environment
|
11
|
+
or remove jasmine.rake.
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
rake_tasks do
|
17
|
+
load "jasmine/tasks/jasmine.rake"
|
18
|
+
load "jasmine/tasks/jasmine_rails3.rake"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|