jasmine 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +21 -0
- data/bin/jasmine +55 -0
- data/generators/jasmine/jasmine_generator.rb +25 -0
- data/generators/jasmine/templates/INSTALL +9 -0
- data/generators/jasmine/templates/lib/tasks/jasmine.rake +23 -0
- data/generators/jasmine/templates/spec/javascripts/ExampleSpec.js +11 -0
- data/generators/jasmine/templates/spec/javascripts/SpecHelper.js +1 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine_config.rb +23 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine_spec.rb +17 -0
- data/generators/jasmine/templates/spec/javascripts/support/sources-rails.yaml +8 -0
- data/generators/jasmine/templates/spec/javascripts/support/sources.yaml +5 -0
- data/jasmine/contrib/ruby/jasmine_runner.rb +334 -0
- data/jasmine/contrib/ruby/jasmine_spec_builder.rb +153 -0
- data/jasmine/contrib/ruby/run.html +47 -0
- data/jasmine/lib/TrivialReporter.js +117 -0
- data/jasmine/lib/consolex.js +28 -0
- data/jasmine/lib/jasmine-0.10.0.js +2261 -0
- data/jasmine/lib/jasmine.css +86 -0
- data/jasmine/lib/json2.js +478 -0
- data/lib/jasmine.rb +6 -0
- data/lib/jasmine/base.rb +63 -0
- data/lib/jasmine/config.rb +151 -0
- data/lib/jasmine/run.html.erb +43 -0
- data/lib/jasmine/selenium_driver.rb +44 -0
- data/lib/jasmine/server.rb +125 -0
- data/lib/jasmine/spec_builder.rb +152 -0
- data/spec/config_spec.rb +77 -0
- data/spec/jasmine_self_test_config.rb +15 -0
- data/spec/jasmine_self_test_spec.rb +18 -0
- data/spec/server_spec.rb +65 -0
- data/spec/spec_helper.rb +3 -0
- metadata +143 -0
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
2
|
+
|
3
|
+
describe Jasmine::Config do
|
4
|
+
before(:each) do
|
5
|
+
@template_dir = File.expand_path(File.join(File.dirname(__FILE__), "../generators/jasmine/templates"))
|
6
|
+
@config = Jasmine::Config.new
|
7
|
+
@config.stub!(:src_dir).and_return(File.join(@template_dir, "public"))
|
8
|
+
@config.stub!(:spec_dir).and_return(File.join(@template_dir, "spec"))
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "simple_config" do
|
12
|
+
it "if sources.yaml not found" do
|
13
|
+
File.stub!(:exist?).and_return(false)
|
14
|
+
@config.src_files.should == []
|
15
|
+
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
16
|
+
@config.mappings.should == {
|
17
|
+
'/__root__' => @config.project_root,
|
18
|
+
'/__spec__' => @config.spec_dir
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
it "if sources.yaml is empty" do
|
23
|
+
YAML.stub!(:load).and_return(false)
|
24
|
+
@config.src_files.should == []
|
25
|
+
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
26
|
+
@config.mappings.should == {
|
27
|
+
'/__root__' => @config.project_root,
|
28
|
+
'/__spec__' => @config.spec_dir
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
it "using default sources.yaml" do
|
33
|
+
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/sources.yaml'))
|
34
|
+
@config.src_files.should == []
|
35
|
+
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
36
|
+
@config.mappings.should == {
|
37
|
+
'/__root__' => @config.project_root,
|
38
|
+
'/__spec__' => @config.spec_dir
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
it "using rails sources.yaml" do
|
43
|
+
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/sources-rails.yaml'))
|
44
|
+
@config.src_files.should == ['javascripts/prototype.js',
|
45
|
+
'javascripts/effects.js',
|
46
|
+
'javascripts/controls.js',
|
47
|
+
'javascripts/dragdrop.js',
|
48
|
+
'javascripts/application.js']
|
49
|
+
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
50
|
+
@config.js_files.should == [
|
51
|
+
'/javascripts/prototype.js',
|
52
|
+
'/javascripts/effects.js',
|
53
|
+
'/javascripts/controls.js',
|
54
|
+
'/javascripts/dragdrop.js',
|
55
|
+
'/javascripts/application.js',
|
56
|
+
'/__spec__/javascripts/ExampleSpec.js',
|
57
|
+
'/__spec__/javascripts/SpecHelper.js',
|
58
|
+
]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
it "should provide dir mappings" do
|
64
|
+
@config.mappings.should == {
|
65
|
+
'/__root__' => @config.project_root,
|
66
|
+
'/__spec__' => @config.spec_dir
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should provide a list of all spec files with full paths" do
|
71
|
+
@config.spec_files_full_paths.should == [
|
72
|
+
File.join(@template_dir, 'spec/javascripts/ExampleSpec.js'),
|
73
|
+
File.join(@template_dir, 'spec/javascripts/SpecHelper.js')
|
74
|
+
]
|
75
|
+
end
|
76
|
+
|
77
|
+
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,18 @@
|
|
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
|
+
Spec::Runner.configure do |config|
|
11
|
+
config.after(:suite) do
|
12
|
+
spec_builder.stop if should_stop
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
spec_builder.start
|
17
|
+
should_stop = true
|
18
|
+
spec_builder.declare_suites
|
data/spec/server_spec.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
2
|
+
|
3
|
+
def read(body)
|
4
|
+
return body if body.is_a?(String)
|
5
|
+
out = ""
|
6
|
+
body.each {|data| out += data }
|
7
|
+
out
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Jasmine::Server do
|
11
|
+
before(:each) do
|
12
|
+
config = Jasmine::Config.new
|
13
|
+
config.stub!(:mappings).and_return({
|
14
|
+
"/src" => File.join(Jasmine.root, "src"),
|
15
|
+
"/spec" => File.join(Jasmine.root, "spec")
|
16
|
+
})
|
17
|
+
|
18
|
+
config.stub!(:js_files).and_return(["/src/file1.js", "/spec/file2.js"])
|
19
|
+
|
20
|
+
@server = Jasmine::Server.new(0, config)
|
21
|
+
@thin_app = @server.thin.app
|
22
|
+
end
|
23
|
+
|
24
|
+
after(:each) do
|
25
|
+
@server.thin.stop if @server && @server.thin.running?
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should serve static files" do
|
29
|
+
code, headers, body = @thin_app.call("PATH_INFO" => "/spec/suites/EnvSpec.js", "SCRIPT_NAME" => "xxx")
|
30
|
+
code.should == 200
|
31
|
+
headers["Content-Type"].should == "application/javascript"
|
32
|
+
read(body).should == File.read(File.join(Jasmine.root, "spec/suites/EnvSpec.js"))
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should serve Jasmine static files under /__JASMINE_ROOT__/" do
|
36
|
+
code, headers, body = @thin_app.call("PATH_INFO" => "/__JASMINE_ROOT__/lib/jasmine.css", "SCRIPT_NAME" => "xxx")
|
37
|
+
code.should == 200
|
38
|
+
headers["Content-Type"].should == "text/css"
|
39
|
+
read(body).should == File.read(File.join(Jasmine.root, "lib/jasmine.css"))
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should redirect /run.html to /" do
|
43
|
+
code, headers, body = @thin_app.call("PATH_INFO" => "/run.html", "SCRIPT_NAME" => "xxx")
|
44
|
+
code.should == 302
|
45
|
+
headers["Location"].should == "/"
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "/ page" do
|
49
|
+
it "should load each js file in order" do
|
50
|
+
code, headers, body = @thin_app.call("PATH_INFO" => "/", "SCRIPT_NAME" => "xxx")
|
51
|
+
code.should == 200
|
52
|
+
body = read(body)
|
53
|
+
body.should include("\"/src/file1.js")
|
54
|
+
body.should include("\"/spec/file2.js")
|
55
|
+
body.should satisfy {|s| s.index("/src/file1.js") < s.index("/spec/file2.js") }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should display an error using JS for 404's" do
|
60
|
+
code, headers, body = @thin_app.call("PATH_INFO" => "/spec/NonExistantFile.js", "SCRIPT_NAME" => "xxx")
|
61
|
+
code.should == 200 # todo: shouldn't this be 404? will that work with all browsers?
|
62
|
+
headers["Content-Type"].should == "application/javascript"
|
63
|
+
read(body).should == "document.write('<p>Couldn\\'t load /spec/NonExistantFile.js!</p>');"
|
64
|
+
end
|
65
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jasmine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rajan Agaskar
|
8
|
+
- Christian Williams
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2010-01-26 00:00:00 -08:00
|
14
|
+
default_executable: jasmine
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 1.1.5
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: json
|
28
|
+
type: :runtime
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.1.9
|
35
|
+
version:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rack
|
38
|
+
type: :runtime
|
39
|
+
version_requirement:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 1.0.0
|
45
|
+
version:
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: thin
|
48
|
+
type: :runtime
|
49
|
+
version_requirement:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.2.4
|
55
|
+
version:
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: selenium-rc
|
58
|
+
type: :runtime
|
59
|
+
version_requirement:
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 2.1.0
|
65
|
+
version:
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: selenium-client
|
68
|
+
type: :runtime
|
69
|
+
version_requirement:
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 1.2.17
|
75
|
+
version:
|
76
|
+
description: Javascript BDD test framework
|
77
|
+
email: ragaskar@gmail.com
|
78
|
+
executables:
|
79
|
+
- jasmine
|
80
|
+
extensions: []
|
81
|
+
|
82
|
+
extra_rdoc_files:
|
83
|
+
- README.markdown
|
84
|
+
files:
|
85
|
+
- generators/jasmine/jasmine_generator.rb
|
86
|
+
- generators/jasmine/templates/INSTALL
|
87
|
+
- generators/jasmine/templates/lib/tasks/jasmine.rake
|
88
|
+
- generators/jasmine/templates/spec/javascripts/ExampleSpec.js
|
89
|
+
- generators/jasmine/templates/spec/javascripts/SpecHelper.js
|
90
|
+
- generators/jasmine/templates/spec/javascripts/support/jasmine_config.rb
|
91
|
+
- generators/jasmine/templates/spec/javascripts/support/jasmine_spec.rb
|
92
|
+
- generators/jasmine/templates/spec/javascripts/support/sources-rails.yaml
|
93
|
+
- generators/jasmine/templates/spec/javascripts/support/sources.yaml
|
94
|
+
- jasmine/contrib/ruby/jasmine_runner.rb
|
95
|
+
- jasmine/contrib/ruby/jasmine_spec_builder.rb
|
96
|
+
- jasmine/contrib/ruby/run.html
|
97
|
+
- jasmine/lib/TrivialReporter.js
|
98
|
+
- jasmine/lib/consolex.js
|
99
|
+
- jasmine/lib/jasmine-0.10.0.js
|
100
|
+
- jasmine/lib/jasmine.css
|
101
|
+
- jasmine/lib/json2.js
|
102
|
+
- lib/jasmine.rb
|
103
|
+
- lib/jasmine/base.rb
|
104
|
+
- lib/jasmine/config.rb
|
105
|
+
- lib/jasmine/run.html.erb
|
106
|
+
- lib/jasmine/selenium_driver.rb
|
107
|
+
- lib/jasmine/server.rb
|
108
|
+
- lib/jasmine/spec_builder.rb
|
109
|
+
- README.markdown
|
110
|
+
has_rdoc: true
|
111
|
+
homepage: http://github.com/pivotal/jasmine-ruby
|
112
|
+
licenses: []
|
113
|
+
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options:
|
116
|
+
- --charset=UTF-8
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: "0"
|
124
|
+
version:
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: "0"
|
130
|
+
version:
|
131
|
+
requirements: []
|
132
|
+
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 1.3.5
|
135
|
+
signing_key:
|
136
|
+
specification_version: 3
|
137
|
+
summary: Jasmine Ruby Runner
|
138
|
+
test_files:
|
139
|
+
- spec/config_spec.rb
|
140
|
+
- spec/jasmine_self_test_config.rb
|
141
|
+
- spec/jasmine_self_test_spec.rb
|
142
|
+
- spec/server_spec.rb
|
143
|
+
- spec/spec_helper.rb
|