evergreen 0.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +101 -3
- data/bin/evergreen +2 -2
- data/lib/evergreen.rb +14 -2
- data/lib/evergreen/evergreen.js +23 -0
- data/lib/evergreen/rails.rb +8 -0
- data/lib/evergreen/runner.rb +21 -14
- data/lib/evergreen/spec.rb +12 -33
- data/lib/evergreen/version.rb +1 -1
- data/lib/evergreen/views/list.erb +1 -1
- data/lib/evergreen/views/spec.erb +9 -22
- data/lib/jasmine/README.markdown +21 -28
- data/lib/jasmine/Rakefile +98 -68
- data/lib/jasmine/example/SpecRunner.html +27 -0
- data/lib/jasmine/example/spec/PlayerSpec.js +58 -0
- data/lib/jasmine/example/spec/SpecHelper.js +9 -0
- data/lib/jasmine/example/src/Player.js +22 -0
- data/lib/jasmine/example/src/Song.js +7 -0
- data/lib/jasmine/lib/jasmine-html.js +182 -0
- data/lib/jasmine/lib/{jasmine-0.10.4.js → jasmine.js} +127 -155
- data/lib/jasmine/spec/runner.html +4 -3
- data/lib/jasmine/spec/suites/BaseSpec.js +27 -0
- data/lib/jasmine/spec/suites/CustomMatchersSpec.js +0 -24
- data/lib/jasmine/spec/suites/EnvSpec.js +1 -1
- data/lib/jasmine/spec/suites/JsApiReporterSpec.js +16 -9
- data/lib/jasmine/spec/suites/MatchersSpec.js +49 -42
- data/lib/jasmine/spec/suites/MockClockSpec.js +4 -0
- data/lib/jasmine/spec/suites/MultiReporterSpec.js +23 -8
- data/lib/jasmine/spec/suites/PrettyPrintSpec.js +2 -2
- data/lib/jasmine/spec/suites/ReporterSpec.js +10 -14
- data/lib/jasmine/spec/suites/RunnerSpec.js +6 -6
- data/lib/jasmine/spec/suites/SpecRunningSpec.js +1 -1
- data/lib/jasmine/spec/suites/SpecSpec.js +15 -1
- data/lib/jasmine/spec/suites/SpySpec.js +3 -3
- data/lib/jasmine/spec/suites/TrivialReporterSpec.js +91 -14
- data/lib/jasmine/spec/suites/WaitsForBlockSpec.js +5 -6
- data/lib/jasmine/src/JsApiReporter.js +4 -6
- data/lib/jasmine/src/Matchers.js +19 -19
- data/lib/jasmine/src/MultiReporter.js +8 -1
- data/lib/jasmine/src/NestedResults.js +5 -5
- data/lib/jasmine/src/PrettyPrinter.js +2 -2
- data/lib/jasmine/src/Reporter.js +4 -0
- data/lib/jasmine/src/Spec.js +12 -8
- data/lib/jasmine/src/base.js +40 -44
- data/lib/jasmine/{lib → src/html}/TrivialReporter.js +17 -6
- data/lib/jasmine/src/html/jasmine.css +166 -0
- data/lib/jasmine/src/mock-timeout.js +22 -16
- data/lib/jasmine/src/version.json +2 -2
- data/lib/tasks/evergreen.rake +7 -0
- data/spec/evergreen_spec.rb +18 -0
- data/spec/fixtures/public/jquery.js +152 -0
- data/spec/fixtures/spec/javascripts/bar_spec.js +0 -0
- data/spec/fixtures/spec/javascripts/failing_spec.js +12 -0
- data/spec/fixtures/spec/javascripts/foo_spec.js +0 -0
- data/spec/fixtures/spec/javascripts/templates_spec.html +1 -0
- data/spec/fixtures/spec/javascripts/templates_spec.js +23 -0
- data/spec/fixtures/spec/javascripts/testing_spec.js +11 -0
- data/spec/fixtures/spec/javascripts/transactions_spec.js +14 -0
- data/spec/meta_spec.rb +17 -0
- data/spec/runner_spec.rb +35 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/spec_spec.rb +30 -0
- metadata +64 -48
- data/lib/jasmine/doc/files.html +0 -460
- data/lib/jasmine/doc/index.html +0 -322
- data/lib/jasmine/doc/symbols/_global_.html +0 -918
- data/lib/jasmine/doc/symbols/jasmine.Block.html +0 -417
- data/lib/jasmine/doc/symbols/jasmine.Clock.html +0 -678
- data/lib/jasmine/doc/symbols/jasmine.Env.html +0 -1169
- data/lib/jasmine/doc/symbols/jasmine.JsApiReporter.html +0 -822
- data/lib/jasmine/doc/symbols/jasmine.Matchers.html +0 -1474
- data/lib/jasmine/doc/symbols/jasmine.MultiReporter.html +0 -394
- data/lib/jasmine/doc/symbols/jasmine.NestedResults.html +0 -710
- data/lib/jasmine/doc/symbols/jasmine.Reporter.html +0 -574
- data/lib/jasmine/doc/symbols/jasmine.Runner.html +0 -710
- data/lib/jasmine/doc/symbols/jasmine.Spec.html +0 -1253
- data/lib/jasmine/doc/symbols/jasmine.Spy.html +0 -855
- data/lib/jasmine/doc/symbols/jasmine.Suite.html +0 -705
- data/lib/jasmine/doc/symbols/jasmine.html +0 -1345
- data/lib/jasmine/doc/symbols/jasmine.util.html +0 -535
- data/lib/jasmine/doc/symbols/src/lib_TrivialReporter.js.html +0 -124
- data/lib/jasmine/doc/symbols/src/src_Block.js.html +0 -29
- data/lib/jasmine/doc/symbols/src/src_Env.js.html +0 -248
- data/lib/jasmine/doc/symbols/src/src_JsApiReporter.js.html +0 -111
- data/lib/jasmine/doc/symbols/src/src_Matchers.js.html +0 -344
- data/lib/jasmine/doc/symbols/src/src_MultiReporter.js.html +0 -36
- data/lib/jasmine/doc/symbols/src/src_NestedResults.js.html +0 -88
- data/lib/jasmine/doc/symbols/src/src_PrettyPrinter.js.html +0 -130
- data/lib/jasmine/doc/symbols/src/src_Queue.js.html +0 -102
- data/lib/jasmine/doc/symbols/src/src_Reporter.js.html +0 -35
- data/lib/jasmine/doc/symbols/src/src_Reporters.js.html +0 -51
- data/lib/jasmine/doc/symbols/src/src_Runner.js.html +0 -75
- data/lib/jasmine/doc/symbols/src/src_Spec.js.html +0 -214
- data/lib/jasmine/doc/symbols/src/src_Suite.js.html +0 -77
- data/lib/jasmine/doc/symbols/src/src_WaitsBlock.js.html +0 -21
- data/lib/jasmine/doc/symbols/src/src_WaitsForBlock.js.html +0 -45
- data/lib/jasmine/doc/symbols/src/src_base.js.html +0 -585
- data/lib/jasmine/doc/symbols/src/src_mock-timeout.js.html +0 -185
- data/lib/jasmine/doc/symbols/src/src_util.js.html +0 -75
- data/lib/jasmine/example/example_runner.html +0 -22
- data/lib/jasmine/example/spec/example_suite.js +0 -11
- data/lib/jasmine/spec/jasmine_helper.rb +0 -44
- data/lib/jasmine/spec/jasmine_spec.rb +0 -31
- data/lib/jasmine/spec/saucelabs.yml +0 -24
- data/lib/jasmine/src/Reporters.js +0 -43
data/README.rdoc
CHANGED
@@ -1,4 +1,102 @@
|
|
1
|
-
Evergreen
|
2
|
-
=========
|
1
|
+
= Evergreen
|
3
2
|
|
4
|
-
|
3
|
+
"Because green is the new Blue(Ridge)"
|
4
|
+
|
5
|
+
Evergreen is a tool to run javascript unit tests for client side JavaScript. It combines a runner which allows you to serve up and run your specs in a browser, as well as a headless runner based on envjs. Evergreen uses the Jasmine unit testing framework for JavaScript.
|
6
|
+
|
7
|
+
http://github.com/jnicklas/evergreen
|
8
|
+
|
9
|
+
== Philosophy
|
10
|
+
|
11
|
+
Evergreen is a unit testing tool. It's purpose is to test JavaScript in isolation from your application. If you need a tool that tests how your JavaScript integrates with your application you should use an integration testing framework, such as {Capybara}[http://github.com/jnicklas/capybara].
|
12
|
+
|
13
|
+
== Installation
|
14
|
+
|
15
|
+
Install as a Ruby gem:
|
16
|
+
|
17
|
+
gem install evergreen
|
18
|
+
|
19
|
+
== Usage
|
20
|
+
|
21
|
+
Evergreen assumes a file and directory structure, place all your javascript code inside ./public and all spec files inside ./spec/javascripts. All spec files should end in _spec.js. For example:
|
22
|
+
|
23
|
+
public/widget.js
|
24
|
+
spec/javascripts/widget_spec.js
|
25
|
+
|
26
|
+
You can require files from the public directory inside your spec file:
|
27
|
+
|
28
|
+
require('/widget.js')
|
29
|
+
|
30
|
+
describe('a widget', function() {
|
31
|
+
...
|
32
|
+
});
|
33
|
+
|
34
|
+
You can now look at your spec files inside a browser by starting up the Evergreen server:
|
35
|
+
|
36
|
+
evergreen server
|
37
|
+
|
38
|
+
Alternatively you can run the specs headlessly by running:
|
39
|
+
|
40
|
+
evergreen run
|
41
|
+
|
42
|
+
|
43
|
+
== Integrating with Rails 3
|
44
|
+
|
45
|
+
Add Evergreen to your Gemfile:
|
46
|
+
|
47
|
+
gem 'evergreen', :require => 'evergreen/rails'
|
48
|
+
|
49
|
+
Start your rails application and navigate to /evergreen/list. You should now see a list of all spec files, click on one to run it.
|
50
|
+
|
51
|
+
There's a rake task provided for you that you can use to run your specs:
|
52
|
+
|
53
|
+
rake spec:javascripts
|
54
|
+
|
55
|
+
== Transactions
|
56
|
+
|
57
|
+
One problem often faced when writing unit tests for client side code is that changes to the page are not reverted for the next example, so that successive examples become dependent on each other. Evergreen adds a special div to your page with an id of test. This div is automatically emptied before each example. You should avoid appending markup to the page body and instead append it to this test div:
|
58
|
+
|
59
|
+
describe('transactions', function() {
|
60
|
+
it("should add stuff in one test...", function() {
|
61
|
+
$('#test').append('<h1 id="added">New Stuff</h1>');
|
62
|
+
expect($('#test h1#added').length).toEqual(1);
|
63
|
+
});
|
64
|
+
|
65
|
+
it("... should have been removed before the next starts", function() {
|
66
|
+
expect($('#test h1#added').length).toEqual(0);
|
67
|
+
});
|
68
|
+
});
|
69
|
+
|
70
|
+
== Templates
|
71
|
+
|
72
|
+
Even more powerful than that, Evergreen allows you to create HTML templates to go along with your specs. Simply name the template the same as the spec, only with an html extension. For example:
|
73
|
+
|
74
|
+
spec/javascripts/widget_spec.js
|
75
|
+
spec/javascripts/widget_spec.html
|
76
|
+
|
77
|
+
The template will be placed inside the test div, so that means it should not include html, head, body or similar tags. The template will be restored for each example, so that at the start of each example, the markup inside the test div is identical.
|
78
|
+
|
79
|
+
== License:
|
80
|
+
|
81
|
+
(The MIT License)
|
82
|
+
|
83
|
+
Copyright (c) 2009 Jonas Nicklas
|
84
|
+
|
85
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
86
|
+
a copy of this software and associated documentation files (the
|
87
|
+
'Software'), to deal in the Software without restriction, including
|
88
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
89
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
90
|
+
permit persons to whom the Software is furnished to do so, subject to
|
91
|
+
the following conditions:
|
92
|
+
|
93
|
+
The above copyright notice and this permission notice shall be
|
94
|
+
included in all copies or substantial portions of the Software.
|
95
|
+
|
96
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
97
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
98
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
99
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
100
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
101
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
102
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/bin/evergreen
CHANGED
@@ -6,8 +6,8 @@ require 'evergreen'
|
|
6
6
|
|
7
7
|
begin
|
8
8
|
# The dup is to keep ARGV intact, so that tools like ruby-debug can respawn.
|
9
|
-
|
10
|
-
Kernel.exit(
|
9
|
+
success = Evergreen::Cli.execute(ARGV.dup)
|
10
|
+
Kernel.exit(success ? 0 : 1)
|
11
11
|
rescue SystemExit => e
|
12
12
|
Kernel.exit(e.status)
|
13
13
|
rescue Exception => e
|
data/lib/evergreen.rb
CHANGED
@@ -5,6 +5,7 @@ require 'capybara/envjs'
|
|
5
5
|
require 'capybara/wait_until'
|
6
6
|
require 'launchy'
|
7
7
|
require 'evergreen/version'
|
8
|
+
require 'json'
|
8
9
|
|
9
10
|
module Evergreen
|
10
11
|
autoload :Cli, 'evergreen/cli'
|
@@ -24,17 +25,28 @@ module Evergreen
|
|
24
25
|
use Rack::Static, :urls => ["/lib"], :root => File.expand_path('jasmine', File.dirname(__FILE__))
|
25
26
|
use Rack::Static, :urls => ["/evergreen"], :root => File.dirname(__FILE__)
|
26
27
|
|
28
|
+
helpers do
|
29
|
+
def url(path)
|
30
|
+
request.env['SCRIPT_NAME'].to_s + path.to_s
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
27
34
|
get '/' do
|
28
35
|
@specs = Spec.all(root)
|
29
36
|
erb :list
|
30
37
|
end
|
31
38
|
|
32
|
-
get '/
|
39
|
+
get '/list' do
|
40
|
+
@specs = Spec.all(root)
|
41
|
+
erb :list
|
42
|
+
end
|
43
|
+
|
44
|
+
get '/run/*' do |name|
|
33
45
|
@spec = Spec.new(root, name)
|
34
46
|
erb :spec
|
35
47
|
end
|
36
48
|
|
37
|
-
get '/spec
|
49
|
+
get '/spec/*' do |name|
|
38
50
|
Spec.new(root, name).read
|
39
51
|
end
|
40
52
|
end
|
data/lib/evergreen/evergreen.js
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
var Evergreen = {};
|
2
|
+
|
3
|
+
Evergreen.ReflectiveReporter = function() {
|
4
|
+
this.reportRunnerStarting = function(runner) {
|
5
|
+
jasmine.results = [];
|
6
|
+
};
|
7
|
+
this.reportSpecResults = function(spec) {
|
8
|
+
var results = spec.results();
|
9
|
+
var item = results.getItems()[0] || {};
|
10
|
+
jasmine.results.push({
|
11
|
+
name: spec.getFullName(),
|
12
|
+
passed: results.failedCount === 0,
|
13
|
+
message: item.message,
|
14
|
+
trace: item.trace
|
15
|
+
});
|
16
|
+
};
|
17
|
+
}
|
18
|
+
|
19
|
+
beforeEach(function() {
|
20
|
+
var test = document.getElementById('test');
|
21
|
+
test.innerHTML = Evergreen.template;
|
22
|
+
});
|
23
|
+
|
1
24
|
var require = function(file) {
|
2
25
|
document.write('<script type="text/javascript" src="' + file + '"></script>');
|
3
26
|
};
|
data/lib/evergreen/runner.rb
CHANGED
@@ -2,44 +2,51 @@ module Evergreen
|
|
2
2
|
class Runner
|
3
3
|
attr_reader :spec
|
4
4
|
|
5
|
-
def self.run(root)
|
5
|
+
def self.run(root, io=STDOUT)
|
6
6
|
runners = Spec.all(root).map { |spec| new(spec) }
|
7
7
|
runners.each do |runner|
|
8
8
|
if runner.passed?
|
9
|
-
print '.'
|
9
|
+
io.print '.'
|
10
10
|
else
|
11
|
-
print 'F'
|
11
|
+
io.print 'F'
|
12
12
|
end
|
13
13
|
end
|
14
|
-
puts ""
|
14
|
+
io.puts ""
|
15
15
|
|
16
16
|
runners.each do |runner|
|
17
|
-
puts runner.failure_message unless runner.passed?
|
17
|
+
io.puts runner.failure_message unless runner.passed?
|
18
18
|
end
|
19
|
+
runners.all? { |runner| runner.passed? }
|
19
20
|
end
|
20
21
|
|
21
22
|
def initialize(spec)
|
22
23
|
@spec = spec
|
23
24
|
end
|
24
25
|
|
25
|
-
def
|
26
|
-
|
26
|
+
def name
|
27
|
+
spec.name
|
27
28
|
end
|
28
29
|
|
29
|
-
def
|
30
|
-
|
30
|
+
def passed?
|
31
|
+
failed_examples.empty?
|
31
32
|
end
|
32
33
|
|
33
34
|
def failure_message
|
34
35
|
failed_examples.map do |row|
|
35
|
-
|
36
|
-
Failed: #{row.name}
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
msg = []
|
37
|
+
msg << " Failed: #{row.name}"
|
38
|
+
msg << " #{row.message}"
|
39
|
+
msg << " in #{row.trace.fileName}:#{row.trace.lineNumber}" if row.trace.respond_to?(:fileName)
|
40
|
+
msg.join("\n")
|
40
41
|
end.join("\n\n")
|
41
42
|
end
|
42
43
|
|
44
|
+
protected
|
45
|
+
|
46
|
+
def failed_examples
|
47
|
+
results.select { |row| !row.passed }
|
48
|
+
end
|
49
|
+
|
43
50
|
def results
|
44
51
|
@results ||= begin
|
45
52
|
session = Capybara::Session.new(:envjs, Evergreen.application(spec.root))
|
data/lib/evergreen/spec.rb
CHANGED
@@ -3,7 +3,7 @@ module Evergreen
|
|
3
3
|
|
4
4
|
def self.all(root)
|
5
5
|
Dir.glob(File.join(root, 'spec/javascripts', '*_spec.js')).map do |path|
|
6
|
-
new(root, File.basename(path)
|
6
|
+
new(root, File.basename(path))
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
@@ -14,47 +14,26 @@ module Evergreen
|
|
14
14
|
@name = name
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
File.join(root, 'spec/javascripts', name
|
17
|
+
def full_path
|
18
|
+
File.join(root, 'spec/javascripts', name)
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
|
21
|
+
def template_path
|
22
|
+
full_path.sub(/\..+$/, '.html')
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
"
|
25
|
+
def template
|
26
|
+
if File.exist?(template_path) then File.read(template_path) else "" end
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
|
31
|
-
results.all? { |row| row.passed }
|
32
|
-
end
|
33
|
-
|
34
|
-
def failure_message
|
35
|
-
run unless has_run?
|
36
|
-
results.each do |row|
|
37
|
-
puts "Failed: #{row.name}"
|
38
|
-
puts " #{row.message}"
|
39
|
-
puts " in #{row.trace.fileName}:#{row.trace.lineNumber}"
|
40
|
-
puts ""
|
41
|
-
puts ""
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
protected
|
46
|
-
|
47
|
-
def run
|
48
|
-
session.visit(url)
|
49
|
-
@results = session.evaluate_script('jasmine.results')
|
29
|
+
def read
|
30
|
+
File.read(full_path)
|
50
31
|
end
|
32
|
+
alias_method :contents, :read
|
51
33
|
|
52
|
-
def
|
53
|
-
|
34
|
+
def url
|
35
|
+
"/run/#{name}"
|
54
36
|
end
|
55
37
|
|
56
|
-
def session
|
57
|
-
@session ||= Capybara::Session.new(:envjs, Evergreen.applications(root))
|
58
|
-
end
|
59
38
|
end
|
60
39
|
end
|
data/lib/evergreen/version.rb
CHANGED
@@ -2,34 +2,21 @@
|
|
2
2
|
|
3
3
|
<html>
|
4
4
|
<head>
|
5
|
-
<link rel="stylesheet" type="text/css" href="/lib/jasmine.css">
|
6
|
-
<script src="/lib/jasmine
|
7
|
-
<script type="text/javascript" src="/lib/
|
8
|
-
<script type="text/javascript" src="/
|
9
|
-
<script type="text/javascript" src="/
|
10
|
-
<script src="/spec/<%= @spec.name %>.js" type="text/javascript"></script>
|
5
|
+
<link rel="stylesheet" type="text/css" href="<%= url('/lib/jasmine.css') %>">
|
6
|
+
<script type="text/javascript" src="<%= url("/lib/jasmine.js") %>"></script>
|
7
|
+
<script type="text/javascript" src="<%= url("/lib/jasmine-html.js") %>"></script>
|
8
|
+
<script type="text/javascript" src="<%= url("/evergreen/evergreen.js") %>"></script>
|
9
|
+
<script type="text/javascript" src="<%= url("/spec/#{@spec.name}") %>"></script>
|
11
10
|
</head>
|
12
11
|
<body>
|
12
|
+
<div id="test">
|
13
|
+
</div>
|
13
14
|
<script type="text/javascript">
|
14
15
|
(function() {
|
16
|
+
Evergreen.template = <%= @spec.template.to_json %>;
|
15
17
|
var jasmineEnv = jasmine.getEnv();
|
16
18
|
jasmineEnv.addReporter(new jasmine.TrivialReporter());
|
17
|
-
jasmineEnv.addReporter(
|
18
|
-
reportRunnerStarting: function(runner) {
|
19
|
-
jasmine.results = []
|
20
|
-
},
|
21
|
-
reportSpecResults: function(spec) {
|
22
|
-
var results = spec.results();
|
23
|
-
var item = results.getItems()[0] || {};
|
24
|
-
jasmine.results.push({
|
25
|
-
name: spec.getFullName(),
|
26
|
-
passed: results.failedCount === 0,
|
27
|
-
message: item.message,
|
28
|
-
trace: item.trace
|
29
|
-
});
|
30
|
-
}
|
31
|
-
});
|
32
|
-
|
19
|
+
jasmineEnv.addReporter(new Evergreen.ReflectiveReporter());
|
33
20
|
jasmineEnv.execute();
|
34
21
|
})();
|
35
22
|
</script>
|
data/lib/jasmine/README.markdown
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Jasmine
|
1
|
+
[Jasmine](http://pivotal.github.com/jasmine)
|
2
2
|
=======
|
3
3
|
**A JavaScript Testing Framework**
|
4
4
|
|
@@ -6,27 +6,14 @@ Quick Start
|
|
6
6
|
----------
|
7
7
|
|
8
8
|
1. Get the latest release from the [downloads page](http://github.com/pivotal/jasmine/downloads).
|
9
|
-
2. Open `
|
9
|
+
2. Open `SpecRunner.html` in your favorite browser.
|
10
10
|
|
11
11
|
For running within a Ruby environment, including automated execution with Selenium, please use
|
12
|
-
the [jasmine
|
13
|
-
|
14
|
-
Releases
|
15
|
-
----------
|
16
|
-
0.10.0 [[download]](http://cloud.github.com/downloads/pivotal/jasmine/jasmine-0.10.0.zip)
|
17
|
-
|
18
|
-
0.9.0 [[download]](http://github.com/pivotal/jasmine/zipball/0.9.0)
|
19
|
-
|
20
|
-
0.8.0 [[download]](http://github.com/pivotal/jasmine/zipball/0.8.0)
|
12
|
+
the [jasmine gem](http://github.com/pivotal/jasmine-gem).
|
21
13
|
|
22
14
|
### Which Release Should I Use?
|
23
15
|
|
24
|
-
Please use the latest version unless you have a good reason not to. Some of this documentation may not be applicable to older versions.
|
25
|
-
|
26
|
-
Pull Requests
|
27
|
-
----------
|
28
|
-
We welcome your contributions! Jasmine is currently maintained by Davis Frank ([infews](http://github.com/infews)), Rajan Agaskar ([ragaskar](http://github.com/ragaskar)), and Christian Williams ([Xian](http://github.com/Xian)). You can help us by removing all other recipients from your pull request.
|
29
|
-
|
16
|
+
Please use the latest version unless you have a good reason not to. Some of this documentation may not be applicable to older versions. Please see [[Release Notes]](http://wiki.github.com/pivotal/jasmine/release-notes) for change information.
|
30
17
|
|
31
18
|
Why Another JavaScript TDD/BDD Framework?
|
32
19
|
-----------
|
@@ -304,14 +291,14 @@ Here are a few examples:
|
|
304
291
|
spyOn(Klass, 'method');
|
305
292
|
Klass.method('foo argument');
|
306
293
|
|
307
|
-
expect(Klass.method).
|
294
|
+
expect(Klass.method).toHaveBeenCalledWith('foo argument');
|
308
295
|
});
|
309
296
|
|
310
297
|
it('should spy on Klass#methodWithCallback') {
|
311
298
|
var callback = Jasmine.createSpy();
|
312
299
|
Klass.methodWithCallback(callback);
|
313
300
|
|
314
|
-
expect(callback).
|
301
|
+
expect(callback).toHaveBeenCalledWith('foo');
|
315
302
|
});
|
316
303
|
|
317
304
|
|
@@ -331,23 +318,25 @@ Spies can be very useful for testing AJAX or other asynchronous behaviors that t
|
|
331
318
|
var callback = Jasmine.createSpy();
|
332
319
|
|
333
320
|
Klass.asyncMethod(callback);
|
334
|
-
expect(callback).
|
321
|
+
expect(callback).not.toHaveBeenCalled();
|
335
322
|
|
336
323
|
var someResponseData = 'foo';
|
337
324
|
Klass.asyncMethod.mostRecentCall.args[0](someResponseData);
|
338
|
-
expect(callback).
|
325
|
+
expect(callback).toHaveBeenCalledWith(someResponseData);
|
339
326
|
|
340
327
|
});
|
341
328
|
|
342
329
|
There are spy-specfic matchers that are very handy.
|
343
330
|
|
344
|
-
`expect(x).
|
331
|
+
`expect(x).toHaveBeenCalled()` passes if `x` is a spy and was called
|
332
|
+
|
333
|
+
`expect(x).toHaveBeenCalledWith(arguments)` passes if `x` is a spy and was called with the specified arguments
|
345
334
|
|
346
|
-
`expect(x).
|
335
|
+
`expect(x).not.toHaveBeenCalled()` passes if `x` is a spy and was not called
|
347
336
|
|
348
|
-
`expect(x).
|
337
|
+
`expect(x).not.toHaveBeenCalledWith(arguments)` passes if `x` is a spy and was not called with the specified arguments
|
349
338
|
|
350
|
-
`
|
339
|
+
The old matchers `wasCalled`, `wasNotCalled`, `wasCalledWith`, and `wasNotCalledWith` have been deprecated and will be removed in a future release. Please change your specs to use `toHaveBeenCalled`, `not.toHaveBeenCalled`, `toHaveBeenCalledWith`, and `not.toHaveBeenCalledWith` respectively.
|
351
340
|
|
352
341
|
Spies can be trained to respond in a variety of ways when invoked:
|
353
342
|
|
@@ -473,17 +462,21 @@ What's happening here?
|
|
473
462
|
## Support
|
474
463
|
We now have a Google Group for support & discussion.
|
475
464
|
|
476
|
-
*
|
465
|
+
* Discussion: [http://groups.google.com/group/jasmine-js](http://groups.google.com/group/jasmine-js)
|
477
466
|
* Group email: [jasmine-js@googlegroups.com](jasmine-js@googlegroups.com)
|
478
467
|
* Current build status of Jasmine is visible at [ci.pivotallabs.com](http://ci.pivotallabs.com)
|
468
|
+
* Pivotal Tracker project: [http://www.pivotaltracker.com/projects/10606](http://www.pivotaltracker.com/projects/10606)
|
469
|
+
* Twitter: [@JasmineBDD](http://twitter.com/JasmineBDD)
|
479
470
|
|
480
471
|
## Maintainers
|
481
|
-
|
482
472
|
* [Davis W. Frank](mailto:dwfrank@pivotallabs.com), Pivotal Labs
|
483
473
|
* [Rajan Agaskar](mailto:rajan@pivotallabs.com), Pivotal Labs
|
484
474
|
* [Christian Williams](mailto:xian@pivotallabs.com), Pivotal Labs
|
485
475
|
|
476
|
+
## Developers
|
477
|
+
We welcome your contributions! Jasmine is currently maintained by Davis Frank ([infews](http://github.com/infews)), Rajan Agaskar ([ragaskar](http://github.com/ragaskar)), and Christian Williams ([Xian](http://github.com/Xian)). You can help us by removing all other recipients from your pull request.
|
478
|
+
|
486
479
|
## Acknowledgments
|
487
480
|
* A big shout out to the various JavaScript test framework authors, especially TJ for [JSpec](http://github.com/visionmedia/jspec/tree/master) - we played with it a bit before deciding that we really needed to roll our own.
|
488
481
|
* Thanks to Pivot [Jessica Miller](http://www.jessicamillerworks.com/) for our fancy pass/fail/pending icons
|
489
|
-
* Huge contributions have been made by [
|
482
|
+
* Huge contributions have been made by [Adam Abrons](mailto:adam@pivotallabs.com), [Lee Byrd](mailto:lee@pivotallabs.com), [Erik Hanson](mailto:erik@pivotallabs.com), [Carl Jackson](mailto:carl@pivotallabs.com), and many other Pivots.
|