josephholsten-jasmine 1.1.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/.gitmodules +3 -0
- data/Gemfile +5 -0
- data/HOW_TO_TEST.markdown +9 -0
- data/MIT.LICENSE +20 -0
- data/README.markdown +71 -0
- data/RELEASE.markdown +22 -0
- data/Rakefile +76 -0
- data/bin/jasmine +6 -0
- data/generators/jasmine/jasmine_generator.rb +32 -0
- data/generators/jasmine/templates/INSTALL +9 -0
- data/generators/jasmine/templates/jasmine-example/SpecRunner.html +27 -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/generators/jasmine/templates/spec/javascripts/support/jasmine_config.rb +23 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/jasmine/Gemfile +6 -0
- data/jasmine/Gemfile.lock +33 -0
- data/jasmine/HowToRelease.markdown +29 -0
- data/jasmine/MIT.LICENSE +20 -0
- data/jasmine/README.markdown +50 -0
- data/jasmine/Rakefile +166 -0
- data/jasmine/cruise_config.rb +21 -0
- data/jasmine/example/SpecRunner.html +27 -0
- data/jasmine/example/spec/PlayerSpec.js +58 -0
- data/jasmine/example/spec/SpecHelper.js +9 -0
- data/jasmine/example/src/Player.js +22 -0
- data/jasmine/example/src/Song.js +7 -0
- data/jasmine/images/jasmine_favicon.png +0 -0
- data/jasmine/jsdoc-template/allclasses.tmpl +17 -0
- data/jasmine/jsdoc-template/allfiles.tmpl +56 -0
- data/jasmine/jsdoc-template/class.tmpl +646 -0
- data/jasmine/jsdoc-template/index.tmpl +39 -0
- data/jasmine/jsdoc-template/publish.js +184 -0
- data/jasmine/jsdoc-template/static/default.css +162 -0
- data/jasmine/jsdoc-template/static/header.html +2 -0
- data/jasmine/jsdoc-template/static/index.html +19 -0
- data/jasmine/jsdoc-template/symbol.tmpl +35 -0
- data/jasmine/jshint/jshint.js +5919 -0
- data/jasmine/jshint/run.js +98 -0
- data/jasmine/lib/jasmine-html.js +190 -0
- data/jasmine/lib/jasmine.css +166 -0
- data/jasmine/lib/jasmine.js +2445 -0
- data/jasmine/lib/json2.js +478 -0
- data/jasmine/spec/node_suite.js +233 -0
- data/jasmine/spec/runner.html +82 -0
- data/jasmine/spec/suites/BaseSpec.js +27 -0
- data/jasmine/spec/suites/CustomMatchersSpec.js +97 -0
- data/jasmine/spec/suites/EnvSpec.js +158 -0
- data/jasmine/spec/suites/ExceptionsSpec.js +107 -0
- data/jasmine/spec/suites/JsApiReporterSpec.js +103 -0
- data/jasmine/spec/suites/MatchersSpec.js +795 -0
- data/jasmine/spec/suites/MockClockSpec.js +38 -0
- data/jasmine/spec/suites/MultiReporterSpec.js +45 -0
- data/jasmine/spec/suites/NestedResultsSpec.js +54 -0
- data/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
- data/jasmine/spec/suites/QueueSpec.js +23 -0
- data/jasmine/spec/suites/ReporterSpec.js +56 -0
- data/jasmine/spec/suites/RunnerSpec.js +267 -0
- data/jasmine/spec/suites/SpecRunningSpec.js +1253 -0
- data/jasmine/spec/suites/SpecSpec.js +124 -0
- data/jasmine/spec/suites/SpySpec.js +201 -0
- data/jasmine/spec/suites/SuiteSpec.js +120 -0
- data/jasmine/spec/suites/TrivialConsoleReporterSpec.js +431 -0
- data/jasmine/spec/suites/TrivialReporterSpec.js +238 -0
- data/jasmine/spec/suites/UtilSpec.js +39 -0
- data/jasmine/spec/suites/WaitsForBlockSpec.js +118 -0
- data/jasmine/src/Block.js +22 -0
- data/jasmine/src/Env.js +264 -0
- data/jasmine/src/JsApiReporter.js +102 -0
- data/jasmine/src/Matchers.js +354 -0
- data/jasmine/src/MultiReporter.js +35 -0
- data/jasmine/src/NestedResults.js +80 -0
- data/jasmine/src/PrettyPrinter.js +123 -0
- data/jasmine/src/Queue.js +99 -0
- data/jasmine/src/Reporter.js +31 -0
- data/jasmine/src/Runner.js +77 -0
- data/jasmine/src/Spec.js +242 -0
- data/jasmine/src/Suite.js +82 -0
- data/jasmine/src/WaitsBlock.js +15 -0
- data/jasmine/src/WaitsForBlock.js +54 -0
- data/jasmine/src/base.js +608 -0
- data/jasmine/src/console/TrivialConsoleReporter.js +144 -0
- data/jasmine/src/html/TrivialReporter.js +190 -0
- data/jasmine/src/html/jasmine.css +166 -0
- data/jasmine/src/mock-timeout.js +183 -0
- data/jasmine/src/util.js +67 -0
- data/jasmine/src/version.json +5 -0
- data/jasmine.gemspec +52 -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/public/javascripts/jasmine_examples/Player.js +22 -0
- data/lib/generators/jasmine/examples/templates/public/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 +81 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_config.rb +23 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_runner.rb +20 -0
- data/lib/generators/jasmine/jasmine_generator.rb +32 -0
- data/lib/generators/jasmine/templates/INSTALL +9 -0
- data/lib/generators/jasmine/templates/lib/tasks/jasmine.rake +2 -0
- data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
- data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +73 -0
- data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine_config.rb +23 -0
- data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/lib/jasmine/base.rb +66 -0
- data/lib/jasmine/command_line_tool.rb +72 -0
- data/lib/jasmine/config.rb +190 -0
- data/lib/jasmine/railtie.rb +20 -0
- data/lib/jasmine/run.html.erb +44 -0
- data/lib/jasmine/selenium_driver.rb +49 -0
- data/lib/jasmine/server.rb +106 -0
- data/lib/jasmine/spec_builder.rb +162 -0
- data/lib/jasmine/tasks/jasmine.rake +44 -0
- data/lib/jasmine/version.rb +3 -0
- data/lib/jasmine.rb +14 -0
- data/spec/config_spec.rb +308 -0
- data/spec/fixture/jasmine.erb.yml +4 -0
- data/spec/jasmine_command_line_tool_spec.rb +29 -0
- data/spec/jasmine_pojs_spec.rb +51 -0
- data/spec/jasmine_rails2_spec.rb +93 -0
- data/spec/jasmine_rails3_spec.rb +71 -0
- data/spec/jasmine_self_test_config.rb +15 -0
- data/spec/jasmine_self_test_spec.rb +24 -0
- data/spec/server_spec.rb +80 -0
- data/spec/spec_helper.rb +65 -0
- metadata +386 -0
@@ -0,0 +1,93 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
2
|
+
|
3
|
+
if rails2?
|
4
|
+
|
5
|
+
describe "A Rails 2 app" do
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
temp_dir_before
|
9
|
+
Dir::chdir @tmp
|
10
|
+
create_rails 'rails-example'
|
11
|
+
Dir::chdir 'rails-example'
|
12
|
+
end
|
13
|
+
|
14
|
+
after :each do
|
15
|
+
temp_dir_after
|
16
|
+
end
|
17
|
+
|
18
|
+
context "before Jasmine has been installed" do
|
19
|
+
|
20
|
+
it "should not the jasmine:install generator" do
|
21
|
+
output = `./script/generate --help`
|
22
|
+
output.should_not include('jasmine:install')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should not show jasmine:install help" do
|
26
|
+
output = `rails g`
|
27
|
+
output.should_not include('This will create')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should not show jasmine rake task" do
|
31
|
+
output = `rake -T`
|
32
|
+
output.should_not include("jasmine ")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should not show jasmine:ci rake task" do
|
36
|
+
output = `rake -T`
|
37
|
+
output.should_not include("jasmine:ci")
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when the Jasmine generators are available" do
|
43
|
+
before :each do
|
44
|
+
`mkdir -p lib/generators && cp -R #{@root}/generators/jasmine lib/generators`
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should show the Jasmine generator" do
|
48
|
+
output = `./script/generate --help`
|
49
|
+
output.should include("Lib: jasmine")
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should show jasmine:install help" do
|
53
|
+
output = `./script/generate jasmine --help`
|
54
|
+
|
55
|
+
output.should include("Usage: ./script/generate jasmine")
|
56
|
+
end
|
57
|
+
|
58
|
+
context "and been run" do
|
59
|
+
before :each do
|
60
|
+
`./script/generate jasmine`
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should find the Jasmine configuration files" do
|
64
|
+
File.exists?("spec/javascripts/support/jasmine.yml").should == true
|
65
|
+
File.exists?("spec/javascripts/support/jasmine_runner.rb").should == true
|
66
|
+
File.exists?("spec/javascripts/support/jasmine_config.rb").should == true
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should find the Jasmine example files" do
|
70
|
+
File.exists?("public/javascripts/Player.js").should == true
|
71
|
+
File.exists?("public/javascripts/Song.js").should == true
|
72
|
+
|
73
|
+
File.exists?("spec/javascripts/PlayerSpec.js").should == true
|
74
|
+
File.exists?("spec/javascripts/helpers/SpecHelper.js").should == true
|
75
|
+
|
76
|
+
File.exists?("spec/javascripts/support/jasmine.yml").should == true
|
77
|
+
File.exists?("spec/javascripts/support/jasmine_runner.rb").should == true
|
78
|
+
File.exists?("spec/javascripts/support/jasmine_config.rb").should == true
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should show jasmine rake task" do
|
82
|
+
output = `rake -T`
|
83
|
+
output.should include("jasmine ")
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should show jasmine:ci rake task" do
|
87
|
+
output = `rake -T`
|
88
|
+
output.should include("jasmine:ci")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
2
|
+
|
3
|
+
if rails3?
|
4
|
+
|
5
|
+
describe "A Rails 3 app" do
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
temp_dir_before
|
9
|
+
Dir::chdir @tmp
|
10
|
+
|
11
|
+
create_rails 'rails-example'
|
12
|
+
Dir::chdir 'rails-example'
|
13
|
+
open('Gemfile', 'a') { |f| f.puts "gem \"jasmine\", \"#{Jasmine::VERSION}\"" }
|
14
|
+
end
|
15
|
+
|
16
|
+
after :each do
|
17
|
+
temp_dir_after
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when Jasmine has been required" do
|
21
|
+
it "should show the Jasmine generators" do
|
22
|
+
output = `rails g`
|
23
|
+
output.should include("jasmine:install")
|
24
|
+
output.should include("jasmine:examples")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should show jasmine:install help" do
|
28
|
+
output = `rails g jasmine:install --help`
|
29
|
+
output.should include("rails generate jasmine:install")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should have the jasmine rake task" do
|
33
|
+
output = `rake -T`
|
34
|
+
output.should include("jasmine ")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have the jasmine:ci rake task" do
|
38
|
+
output = `rake -T`
|
39
|
+
output.should include("jasmine:ci")
|
40
|
+
end
|
41
|
+
|
42
|
+
context "and then installed" do
|
43
|
+
before :each do
|
44
|
+
@output = `rails g jasmine:install`
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should have the Jasmine config files" do
|
48
|
+
@output.should include("create")
|
49
|
+
|
50
|
+
File.exists?("spec/javascripts/helpers/.gitkeep").should == true
|
51
|
+
File.exists?("spec/javascripts/support/jasmine.yml").should == true
|
52
|
+
File.exists?("spec/javascripts/support/jasmine_runner.rb").should == true
|
53
|
+
File.exists?("spec/javascripts/support/jasmine_config.rb").should == true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "and the jasmine examples have been installed" do
|
58
|
+
it "should find the Jasmine example files" do
|
59
|
+
output = `rails g jasmine:examples`
|
60
|
+
output.should include("create")
|
61
|
+
|
62
|
+
File.exists?("public/javascripts/jasmine_examples/Player.js").should == true
|
63
|
+
File.exists?("public/javascripts/jasmine_examples/Song.js").should == true
|
64
|
+
|
65
|
+
File.exists?("spec/javascripts/jasmine_examples/PlayerSpec.js").should == true
|
66
|
+
File.exists?("spec/javascripts/helpers/SpecHelper.js").should == true
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'jasmine'
|
2
|
+
|
3
|
+
class JasmineSelfTestConfig < Jasmine::Config
|
4
|
+
def project_root
|
5
|
+
File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
6
|
+
end
|
7
|
+
|
8
|
+
def src_dir
|
9
|
+
File.join(project_root, 'src')
|
10
|
+
end
|
11
|
+
|
12
|
+
def spec_dir
|
13
|
+
File.join(project_root, 'jasmine/spec')
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
2
|
+
|
3
|
+
require 'jasmine_self_test_config'
|
4
|
+
|
5
|
+
jasmine_config = JasmineSelfTestConfig.new
|
6
|
+
spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
|
7
|
+
|
8
|
+
should_stop = false
|
9
|
+
|
10
|
+
if rspec2?
|
11
|
+
RSpec.configuration.after(:suite) do
|
12
|
+
spec_builder.stop if should_stop
|
13
|
+
end
|
14
|
+
else
|
15
|
+
Spec::Runner.configure do |config|
|
16
|
+
config.after(:suite) do
|
17
|
+
spec_builder.stop if should_stop
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
spec_builder.start
|
23
|
+
should_stop = true
|
24
|
+
spec_builder.declare_suites
|
data/spec/server_spec.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
2
|
+
require 'rack/test'
|
3
|
+
|
4
|
+
describe "Jasmine.app" do
|
5
|
+
include Rack::Test::Methods
|
6
|
+
|
7
|
+
def app
|
8
|
+
config = Jasmine::Config.new
|
9
|
+
config.stub!(:project_root).and_return(Jasmine.root)
|
10
|
+
config.stub!(:spec_dir).and_return(File.join(Jasmine.root, "spec"))
|
11
|
+
config.stub!(:src_dir).and_return(File.join(Jasmine.root, "src"))
|
12
|
+
config.stub!(:src_files).and_return(["file1.js"])
|
13
|
+
config.stub!(:spec_files).and_return(["file2.js"])
|
14
|
+
Jasmine.app(config)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should serve static files from spec dir under __spec__" do
|
18
|
+
get "/__spec__/suites/EnvSpec.js"
|
19
|
+
last_response.status.should == 200
|
20
|
+
last_response.content_type.should == "application/javascript"
|
21
|
+
last_response.body.should == File.read(File.join(Jasmine.root, "spec/suites/EnvSpec.js"))
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should serve static files from root dir under __root__" do
|
25
|
+
get "/__root__/src/base.js"
|
26
|
+
last_response.status.should == 200
|
27
|
+
last_response.content_type.should == "application/javascript"
|
28
|
+
last_response.body.should == File.read(File.join(Jasmine.root, "src/base.js"))
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should serve static files from src dir under /" do
|
32
|
+
get "/base.js"
|
33
|
+
last_response.status.should == 200
|
34
|
+
last_response.content_type.should == "application/javascript"
|
35
|
+
last_response.body.should == File.read(File.join(Jasmine.root, "src/base.js"))
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should serve Jasmine static files under /__JASMINE_ROOT__/" do
|
39
|
+
get "/__JASMINE_ROOT__/lib/jasmine.css"
|
40
|
+
last_response.status.should == 200
|
41
|
+
last_response.content_type.should == "text/css"
|
42
|
+
last_response.body.should == File.read(File.join(Jasmine.root, "lib/jasmine.css"))
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should serve focused suites when prefixing spec files with /__suite__/" do
|
46
|
+
Dir.stub!(:glob).and_return { |glob_string| [glob_string] }
|
47
|
+
get "/__suite__/file2.js"
|
48
|
+
last_response.status.should == 200
|
49
|
+
last_response.content_type.should == "text/html"
|
50
|
+
last_response.body.should include("\"/__spec__/file2.js")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should redirect /run.html to /" do
|
54
|
+
get "/run.html"
|
55
|
+
last_response.status.should == 302
|
56
|
+
last_response.location.should == "/"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should 404 non-existent files" do
|
60
|
+
get "/some-non-existent-file"
|
61
|
+
last_response.should be_not_found
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "/ page" do
|
65
|
+
it "should load each js file in order" do
|
66
|
+
get "/"
|
67
|
+
last_response.status.should == 200
|
68
|
+
last_response.body.should include("\"/file1.js")
|
69
|
+
last_response.body.should include("\"/__spec__/file2.js")
|
70
|
+
last_response.body.should satisfy {|s| s.index("/file1.js") < s.index("/__spec__/file2.js") }
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should return an empty 200 for HEAD requests to /" do
|
74
|
+
head "/"
|
75
|
+
last_response.status.should == 200
|
76
|
+
last_response.headers.should == { 'Content-Type' => 'text/html' }
|
77
|
+
last_response.body.should == ''
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler"
|
3
|
+
require 'stringio'
|
4
|
+
require 'tmpdir'
|
5
|
+
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
|
8
|
+
def rspec2?
|
9
|
+
Gem.available? "rspec", ">= 2.0"
|
10
|
+
end
|
11
|
+
|
12
|
+
def rails2?
|
13
|
+
Gem.available? "rails", "~> 2.3"
|
14
|
+
end
|
15
|
+
|
16
|
+
def rails3?
|
17
|
+
Gem.available? "rails", ">= 3.0"
|
18
|
+
end
|
19
|
+
|
20
|
+
if rspec2?
|
21
|
+
require 'rspec'
|
22
|
+
else
|
23
|
+
require 'spec'
|
24
|
+
end
|
25
|
+
|
26
|
+
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "../lib")))
|
27
|
+
|
28
|
+
require "jasmine"
|
29
|
+
|
30
|
+
def create_rails(name)
|
31
|
+
if rails3?
|
32
|
+
`rails new #{name}`
|
33
|
+
else
|
34
|
+
`rails #{name}`
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_temp_dir
|
39
|
+
tmp = File.join(Dir.tmpdir, "jasmine-gem-test_#{Time.now.to_f}")
|
40
|
+
FileUtils.rm_r(tmp, :force => true)
|
41
|
+
FileUtils.mkdir(tmp)
|
42
|
+
tmp
|
43
|
+
end
|
44
|
+
|
45
|
+
def temp_dir_before
|
46
|
+
@root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
47
|
+
@old_dir = Dir::pwd
|
48
|
+
@tmp = create_temp_dir
|
49
|
+
end
|
50
|
+
|
51
|
+
def temp_dir_after
|
52
|
+
Dir::chdir @old_dir
|
53
|
+
FileUtils.rm_r @tmp
|
54
|
+
end
|
55
|
+
|
56
|
+
module Kernel
|
57
|
+
def capture_stdout
|
58
|
+
out = StringIO.new
|
59
|
+
$stdout = out
|
60
|
+
yield
|
61
|
+
return out.string
|
62
|
+
ensure
|
63
|
+
$stdout = STDOUT
|
64
|
+
end
|
65
|
+
end
|