Compare commits
4 Commits
0.4.5-rele
...
0.4.6-rele
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f18595399 | ||
|
|
6c50f14f3b | ||
|
|
a0fbbd7f67 | ||
|
|
199517abaa |
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
:patch: 5
|
:patch: 6
|
||||||
:major: 0
|
:major: 0
|
||||||
:build:
|
:build:
|
||||||
:minor: 4
|
:minor: 4
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
# Generated by jeweler
|
# Generated by jeweler
|
||||||
# DO NOT EDIT THIS FILE DIRECTLY
|
# DO NOT EDIT THIS FILE DIRECTLY
|
||||||
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
# Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
|
||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
|
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = %q{jasmine}
|
s.name = %q{jasmine}
|
||||||
s.version = "0.4.5"
|
s.version = "0.4.6"
|
||||||
|
|
||||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||||
s.authors = ["Rajan Agaskar", "Christian Williams"]
|
s.authors = ["Rajan Agaskar", "Christian Williams"]
|
||||||
s.date = %q{2010-02-24}
|
s.date = %q{2010-03-10}
|
||||||
s.default_executable = %q{jasmine}
|
s.default_executable = %q{jasmine}
|
||||||
s.description = %q{Javascript BDD test framework}
|
s.description = %q{Javascript BDD test framework}
|
||||||
s.email = %q{ragaskar@gmail.com}
|
s.email = %q{ragaskar@gmail.com}
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ module Jasmine
|
|||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
require 'selenium_rc'
|
require 'selenium_rc'
|
||||||
@selenium_jar_path = SeleniumRC::Server.allocate.jar_path
|
@selenium_jar_path = SeleniumRC::Server.allocate.jar_path
|
||||||
@options = options
|
|
||||||
|
|
||||||
@browser = options[:browser] ? options.delete(:browser) : 'firefox'
|
@browser = ENV["JASMINE_BROWSER"] || 'firefox'
|
||||||
@selenium_pid = nil
|
@selenium_pid = nil
|
||||||
@jasmine_server_pid = nil
|
@jasmine_server_pid = nil
|
||||||
end
|
end
|
||||||
@@ -27,29 +26,40 @@ module Jasmine
|
|||||||
stop_servers
|
stop_servers
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_servers
|
def start_jasmine_server
|
||||||
@jasmine_server_port = Jasmine::find_unused_port
|
@jasmine_server_port = Jasmine::find_unused_port
|
||||||
@selenium_server_port = Jasmine::find_unused_port
|
|
||||||
|
|
||||||
server = Jasmine::Server.new(@jasmine_server_port, self)
|
server = Jasmine::Server.new(@jasmine_server_port, self)
|
||||||
|
|
||||||
@selenium_pid = fork do
|
|
||||||
Process.setpgrp
|
|
||||||
exec "java -jar #{@selenium_jar_path} -port #{@selenium_server_port} > /dev/null 2>&1"
|
|
||||||
end
|
|
||||||
puts "selenium started. pid is #{@selenium_pid}"
|
|
||||||
|
|
||||||
@jasmine_server_pid = fork do
|
@jasmine_server_pid = fork do
|
||||||
Process.setpgrp
|
Process.setpgrp
|
||||||
server.start
|
server.start
|
||||||
exit! 0
|
exit! 0
|
||||||
end
|
end
|
||||||
puts "jasmine server started. pid is #{@jasmine_server_pid}"
|
puts "jasmine server started. pid is #{@jasmine_server_pid}"
|
||||||
|
|
||||||
Jasmine::wait_for_listener(@selenium_server_port, "selenium server")
|
|
||||||
Jasmine::wait_for_listener(@jasmine_server_port, "jasmine server")
|
Jasmine::wait_for_listener(@jasmine_server_port, "jasmine server")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def external_selenium_server_port
|
||||||
|
ENV['SELENIUM_SERVER_PORT'] && ENV['SELENIUM_SERVER_PORT'].to_i > 0 ? ENV['SELENIUM_SERVER_PORT'].to_i : nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_selenium_server
|
||||||
|
@selenium_server_port = external_selenium_server_port
|
||||||
|
if @selenium_server_port.nil?
|
||||||
|
@selenium_server_port = Jasmine::find_unused_port
|
||||||
|
@selenium_pid = fork do
|
||||||
|
Process.setpgrp
|
||||||
|
exec "java -jar #{@selenium_jar_path} -port #{@selenium_server_port} > /dev/null 2>&1"
|
||||||
|
end
|
||||||
|
puts "selenium started. pid is #{@selenium_pid}"
|
||||||
|
end
|
||||||
|
Jasmine::wait_for_listener(@selenium_server_port, "selenium server")
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_servers
|
||||||
|
start_jasmine_server
|
||||||
|
start_selenium_server
|
||||||
|
end
|
||||||
|
|
||||||
def stop_servers
|
def stop_servers
|
||||||
puts "shutting down the servers..."
|
puts "shutting down the servers..."
|
||||||
Jasmine::kill_process_group(@selenium_pid) if @selenium_pid
|
Jasmine::kill_process_group(@selenium_pid) if @selenium_pid
|
||||||
|
|||||||
@@ -1,113 +1,153 @@
|
|||||||
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
||||||
|
|
||||||
describe Jasmine::Config do
|
describe Jasmine::Config do
|
||||||
before(:each) do
|
|
||||||
@template_dir = File.expand_path(File.join(File.dirname(__FILE__), "../generators/jasmine/templates"))
|
|
||||||
@config = Jasmine::Config.new
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "configuration" do
|
describe "configuration" do
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@config.stub!(:src_dir).and_return(File.join(@template_dir, "public"))
|
@template_dir = File.expand_path(File.join(File.dirname(__FILE__), "../generators/jasmine/templates"))
|
||||||
@config.stub!(:spec_dir).and_return(File.join(@template_dir, "spec"))
|
@config = Jasmine::Config.new
|
||||||
end
|
end
|
||||||
|
|
||||||
it "if sources.yaml not found" do
|
describe "defaults" do
|
||||||
File.stub!(:exist?).and_return(false)
|
|
||||||
@config.src_files.should == []
|
|
||||||
@config.stylesheets.should == []
|
|
||||||
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
|
||||||
@config.mappings.should == {
|
|
||||||
'/__root__' => @config.project_root,
|
|
||||||
'/__spec__' => @config.spec_dir
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
it "if jasmine.yml is empty" do
|
it "src_dir uses root when src dir is blank" do
|
||||||
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
|
@config.stub!(:project_root).and_return('some_project_root')
|
||||||
YAML.stub!(:load).and_return(false)
|
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
|
||||||
@config.src_files.should == []
|
YAML.stub!(:load).and_return({'src_dir' => nil})
|
||||||
@config.stylesheets.should == []
|
@config.src_dir.should == 'some_project_root'
|
||||||
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
end
|
||||||
@config.mappings.should == {
|
|
||||||
'/__root__' => @config.project_root,
|
it "should use correct default yaml config" do
|
||||||
'/__spec__' => @config.spec_dir
|
@config.stub!(:project_root).and_return('some_project_root')
|
||||||
}
|
@config.simple_config_file.should == (File.join('some_project_root', 'spec/javascripts/support/jasmine.yml'))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "using default jasmine.yml" do
|
|
||||||
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
|
it "should provide dir mappings" do
|
||||||
@config.src_files.should == []
|
@config.mappings.should == {
|
||||||
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
'/__root__' => @config.project_root,
|
||||||
@config.mappings.should == {
|
'/__spec__' => @config.spec_dir
|
||||||
'/__root__' => @config.project_root,
|
}
|
||||||
'/__spec__' => @config.spec_dir
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
it "simple_config stylesheets" do
|
|
||||||
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
|
|
||||||
YAML.stub!(:load).and_return({'stylesheets' => ['foo.css', 'bar.css']})
|
|
||||||
Dir.stub!(:glob).and_return do |glob_string|
|
|
||||||
glob_string
|
|
||||||
end
|
end
|
||||||
@config.stylesheets.should == ['foo.css', 'bar.css']
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "using rails jasmine.yml" do
|
|
||||||
original_glob = Dir.method(:glob)
|
describe "simple_config" do
|
||||||
Dir.stub!(:glob).and_return do |glob_string|
|
before(:each) do
|
||||||
if glob_string =~ /public/
|
@config.stub!(:src_dir).and_return(File.join(@template_dir, "public"))
|
||||||
|
@config.stub!(:spec_dir).and_return(File.join(@template_dir, "spec"))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "if sources.yaml not found" do
|
||||||
|
File.stub!(:exist?).and_return(false)
|
||||||
|
@config.src_files.should == []
|
||||||
|
@config.stylesheets.should == []
|
||||||
|
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
||||||
|
@config.mappings.should == {
|
||||||
|
'/__root__' => @config.project_root,
|
||||||
|
'/__spec__' => @config.spec_dir
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it "if jasmine.yml is empty" do
|
||||||
|
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
|
||||||
|
YAML.stub!(:load).and_return(false)
|
||||||
|
@config.src_files.should == []
|
||||||
|
@config.stylesheets.should == []
|
||||||
|
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
||||||
|
@config.mappings.should == {
|
||||||
|
'/__root__' => @config.project_root,
|
||||||
|
'/__spec__' => @config.spec_dir
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it "using default jasmine.yml" do
|
||||||
|
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
|
||||||
|
@config.src_files.should == []
|
||||||
|
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
||||||
|
@config.mappings.should == {
|
||||||
|
'/__root__' => @config.project_root,
|
||||||
|
'/__spec__' => @config.spec_dir
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it "simple_config stylesheets" do
|
||||||
|
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
|
||||||
|
YAML.stub!(:load).and_return({'stylesheets' => ['foo.css', 'bar.css']})
|
||||||
|
Dir.stub!(:glob).and_return do |glob_string|
|
||||||
glob_string
|
glob_string
|
||||||
else
|
|
||||||
original_glob.call(glob_string)
|
|
||||||
end
|
end
|
||||||
|
@config.stylesheets.should == ['foo.css', 'bar.css']
|
||||||
|
end
|
||||||
|
|
||||||
|
it "using rails jasmine.yml" do
|
||||||
|
original_glob = Dir.method(:glob)
|
||||||
|
Dir.stub!(:glob).and_return do |glob_string|
|
||||||
|
if glob_string =~ /public/
|
||||||
|
glob_string
|
||||||
|
else
|
||||||
|
original_glob.call(glob_string)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine-rails.yml'))
|
||||||
|
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
||||||
|
@config.src_files.should == ['javascripts/prototype.js',
|
||||||
|
'javascripts/effects.js',
|
||||||
|
'javascripts/controls.js',
|
||||||
|
'javascripts/dragdrop.js',
|
||||||
|
'javascripts/application.js']
|
||||||
|
@config.js_files.should == [
|
||||||
|
'/javascripts/prototype.js',
|
||||||
|
'/javascripts/effects.js',
|
||||||
|
'/javascripts/controls.js',
|
||||||
|
'/javascripts/dragdrop.js',
|
||||||
|
'/javascripts/application.js',
|
||||||
|
'/__spec__/javascripts/ExampleSpec.js',
|
||||||
|
'/__spec__/javascripts/SpecHelper.js',
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should provide a list of all spec files with full paths" do
|
||||||
|
@config.spec_files_full_paths.should == [
|
||||||
|
File.join(@template_dir, 'spec/javascripts/ExampleSpec.js'),
|
||||||
|
File.join(@template_dir, 'spec/javascripts/SpecHelper.js')
|
||||||
|
]
|
||||||
end
|
end
|
||||||
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine-rails.yml'))
|
|
||||||
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
|
||||||
@config.src_files.should == ['javascripts/prototype.js',
|
|
||||||
'javascripts/effects.js',
|
|
||||||
'javascripts/controls.js',
|
|
||||||
'javascripts/dragdrop.js',
|
|
||||||
'javascripts/application.js']
|
|
||||||
@config.js_files.should == [
|
|
||||||
'/javascripts/prototype.js',
|
|
||||||
'/javascripts/effects.js',
|
|
||||||
'/javascripts/controls.js',
|
|
||||||
'/javascripts/dragdrop.js',
|
|
||||||
'/javascripts/application.js',
|
|
||||||
'/__spec__/javascripts/ExampleSpec.js',
|
|
||||||
'/__spec__/javascripts/SpecHelper.js',
|
|
||||||
]
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should provide a list of all spec files with full paths" do
|
|
||||||
@config.spec_files_full_paths.should == [
|
|
||||||
File.join(@template_dir, 'spec/javascripts/ExampleSpec.js'),
|
|
||||||
File.join(@template_dir, 'spec/javascripts/SpecHelper.js')
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "src_dir uses root when src dir is blank" do
|
describe "browsers" do
|
||||||
@config.stub!(:project_root).and_return('some_project_root')
|
it "should use firefox by default" do
|
||||||
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/jasmine.yml'))
|
ENV.should_receive(:[], "JASMINE_BROWSER").and_return(nil)
|
||||||
YAML.stub!(:load).and_return({'src_dir' => nil})
|
config = Jasmine::Config.new
|
||||||
@config.src_dir.should == 'some_project_root'
|
config.stub!(:start_servers)
|
||||||
|
Jasmine::SeleniumDriver.should_receive(:new).
|
||||||
|
with(anything(), anything(), "*firefox", anything()).
|
||||||
|
and_return(mock(Jasmine::SeleniumDriver, :connect => true))
|
||||||
|
config.start
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should use ENV['JASMINE_BROWSER'] if set" do
|
||||||
|
ENV.should_receive(:[], "JASMINE_BROWSER").and_return("mosaic")
|
||||||
|
config = Jasmine::Config.new
|
||||||
|
config.stub!(:start_servers)
|
||||||
|
Jasmine::SeleniumDriver.should_receive(:new).
|
||||||
|
with(anything(), anything(), "*mosaic", anything()).
|
||||||
|
and_return(mock(Jasmine::SeleniumDriver, :connect => true))
|
||||||
|
config.start
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should use correct default yaml config" do
|
describe "#start_selenium_server" do
|
||||||
@config.stub!(:project_root).and_return('some_project_root')
|
it "should use an existing selenium server if SELENIUM_SERVER_PORT is set" do
|
||||||
@config.simple_config_file.should == (File.join('some_project_root', 'spec/javascripts/support/jasmine.yml'))
|
config = Jasmine::Config.new
|
||||||
end
|
ENV.stub!(:[], "SELENIUM_SERVER_PORT").and_return(1234)
|
||||||
|
Jasmine.should_receive(:wait_for_listener).with(1234, "selenium server")
|
||||||
|
config.start_selenium_server
|
||||||
it "should provide dir mappings" do
|
end
|
||||||
@config.mappings.should == {
|
|
||||||
'/__root__' => @config.project_root,
|
|
||||||
'/__spec__' => @config.spec_dir
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user