teaspoon-jasmine 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/teaspoon-jasmine.rb +4 -0
- data/lib/teaspoon/jasmine/assets/jasmine/1.3.1.js +2602 -0
- data/lib/teaspoon/jasmine/assets/jasmine/2.0.3.js +2593 -0
- data/lib/teaspoon/jasmine/assets/jasmine/2.1.3.js +2908 -0
- data/lib/teaspoon/jasmine/assets/jasmine/2.2.0.js +3048 -0
- data/lib/teaspoon/jasmine/assets/jasmine/MIT.LICENSE +20 -0
- data/lib/teaspoon/jasmine/assets/support/jasmine-jquery-1.7.0.js +720 -0
- data/lib/teaspoon/jasmine/assets/support/jasmine-jquery-2.0.0.js +812 -0
- data/lib/teaspoon/jasmine/assets/support/jasmine-jquery-2.1.0.js +832 -0
- data/lib/teaspoon/jasmine/assets/teaspoon-jasmine1.js +1447 -0
- data/lib/teaspoon/jasmine/assets/teaspoon-jasmine2.js +1490 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine1.coffee +10 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine1/fixture.coffee +29 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine1/initialize.coffee +1 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine1/reporters/html.coffee +13 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine1/responder.coffee +23 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine1/runner.coffee +32 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine1/spec.coffee +37 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine1/suite.coffee +8 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine2.coffee +10 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine2/fixture.coffee +19 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine2/initialize.coffee +23 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine2/reporters/console.coffee +18 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine2/reporters/html.coffee +11 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine2/responder.coffee +39 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine2/runner.coffee +26 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine2/spec.coffee +36 -0
- data/lib/teaspoon/jasmine/assets/teaspoon/jasmine2/suite.coffee +8 -0
- data/lib/teaspoon/jasmine/framework.rb +35 -0
- data/lib/teaspoon/jasmine/templates/spec_helper.coffee +32 -0
- data/lib/teaspoon/jasmine/templates/spec_helper.js +32 -0
- data/lib/teaspoon/jasmine/version.rb +5 -0
- metadata +92 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
#= require teaspoon/teaspoon
|
2
|
+
#= require_self
|
3
|
+
#= require_tree ./jasmine1
|
4
|
+
|
5
|
+
unless jasmine?
|
6
|
+
throw new Teaspoon.Error('Jasmine 1 not found -- use `suite.use_framework :jasmine` and adjust or remove the `suite.javascripts` directive.')
|
7
|
+
|
8
|
+
@Teaspoon ?= {}
|
9
|
+
@Teaspoon.Jasmine1 ?= {}
|
10
|
+
@Teaspoon.Jasmine1.Reporters ?= {}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#= require teaspoon/fixture
|
2
|
+
|
3
|
+
class Teaspoon.Jasmine1.Fixture extends Teaspoon.Fixture
|
4
|
+
|
5
|
+
@load: ->
|
6
|
+
args = arguments
|
7
|
+
throw "Teaspoon can't load fixtures outside of describe." unless @env().currentSuite || @env().currentSpec
|
8
|
+
if @env().currentSuite
|
9
|
+
@env().beforeEach => fixture.__super__.constructor.load.apply(@, args)
|
10
|
+
@env().afterEach => @cleanup()
|
11
|
+
super
|
12
|
+
else
|
13
|
+
@env().currentSpec.after => @cleanup()
|
14
|
+
super
|
15
|
+
|
16
|
+
|
17
|
+
@set: ->
|
18
|
+
args = arguments
|
19
|
+
throw "Teaspoon can't load fixtures outside of describe." unless @env().currentSuite || @env().currentSpec
|
20
|
+
if @env().currentSuite
|
21
|
+
@env().beforeEach => fixture.__super__.constructor.set.apply(@, args)
|
22
|
+
@env().afterEach => @cleanup()
|
23
|
+
super
|
24
|
+
else
|
25
|
+
@env().currentSpec.after => @cleanup()
|
26
|
+
super
|
27
|
+
|
28
|
+
|
29
|
+
@env: -> window.jasmine.getEnv()
|
@@ -0,0 +1 @@
|
|
1
|
+
Teaspoon.setFramework(Teaspoon.Jasmine1)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#= require teaspoon/reporters/html
|
2
|
+
|
3
|
+
class Teaspoon.Jasmine1.Reporters.HTML extends Teaspoon.Reporters.HTML
|
4
|
+
|
5
|
+
readConfig: ->
|
6
|
+
super
|
7
|
+
jasmine.CATCH_EXCEPTIONS = @config["use-catch"]
|
8
|
+
|
9
|
+
|
10
|
+
envInfo: ->
|
11
|
+
ver = jasmine.getEnv().version()
|
12
|
+
verString = [ver.major, ver.minor, ver.build].join(".")
|
13
|
+
"jasmine #{verString} revision #{ver.revision}"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Teaspoon.Jasmine1.Responder
|
2
|
+
|
3
|
+
constructor: (@reporter) ->
|
4
|
+
|
5
|
+
|
6
|
+
reportRunnerStarting: (runner) ->
|
7
|
+
@reporter.reportRunnerStarting(total: runner.specs().length)
|
8
|
+
|
9
|
+
|
10
|
+
reportRunnerResults: ->
|
11
|
+
@reporter.reportRunnerResults()
|
12
|
+
|
13
|
+
|
14
|
+
reportSuiteResults: (suite) ->
|
15
|
+
@reporter.reportSuiteResults(new Teaspoon.Jasmine1.Suite(suite))
|
16
|
+
|
17
|
+
|
18
|
+
reportSpecStarting: (spec) ->
|
19
|
+
@reporter.reportSpecStarting(new Teaspoon.Jasmine1.Spec(spec))
|
20
|
+
|
21
|
+
|
22
|
+
reportSpecResults: (spec) ->
|
23
|
+
@reporter.reportSpecResults(new Teaspoon.Jasmine1.Spec(spec))
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#= require teaspoon/runner
|
2
|
+
|
3
|
+
class Teaspoon.Jasmine1.Runner extends Teaspoon.Runner
|
4
|
+
|
5
|
+
constructor: ->
|
6
|
+
@env = window.jasmine.getEnv()
|
7
|
+
super
|
8
|
+
@env.execute()
|
9
|
+
|
10
|
+
|
11
|
+
setup: ->
|
12
|
+
@env.updateInterval = 1000
|
13
|
+
|
14
|
+
# add the spec filter
|
15
|
+
if grep = @params["grep"]
|
16
|
+
@env.specFilter = (spec) -> spec.getFullName().indexOf(grep) == 0
|
17
|
+
|
18
|
+
# add the reporter
|
19
|
+
reporter = new (@getReporter())()
|
20
|
+
responder = new Teaspoon.Jasmine1.Responder(reporter)
|
21
|
+
@env.addReporter(responder)
|
22
|
+
|
23
|
+
# add fixture support
|
24
|
+
@addFixtureSupport()
|
25
|
+
|
26
|
+
|
27
|
+
addFixtureSupport: ->
|
28
|
+
return unless jasmine.getFixtures && @fixturePath
|
29
|
+
jasmine.getFixtures().containerId = "teaspoon-fixtures"
|
30
|
+
jasmine.getFixtures().fixturesPath = @fixturePath
|
31
|
+
jasmine.getStyleFixtures().fixturesPath = @fixturePath
|
32
|
+
jasmine.getJSONFixtures().fixturesPath = @fixturePath
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class Teaspoon.Jasmine1.Spec
|
2
|
+
|
3
|
+
constructor: (@spec) ->
|
4
|
+
@fullDescription = @spec.getFullName()
|
5
|
+
@description = @spec.description
|
6
|
+
@link = "?grep=#{encodeURIComponent(@fullDescription)}"
|
7
|
+
@parent = @spec.suite
|
8
|
+
@suiteName = @parent.getFullName()
|
9
|
+
@viewId = @spec.viewId
|
10
|
+
@pending = @spec.pending
|
11
|
+
|
12
|
+
|
13
|
+
errors: ->
|
14
|
+
return [] unless @spec.results
|
15
|
+
for item in @spec.results().getItems()
|
16
|
+
continue if item.passed()
|
17
|
+
{message: item.message, stack: item.trace.stack}
|
18
|
+
|
19
|
+
|
20
|
+
getParents: ->
|
21
|
+
return @parents if @parents
|
22
|
+
@parents ||= []
|
23
|
+
parent = @parent
|
24
|
+
while parent
|
25
|
+
parent = new Teaspoon.Jasmine1.Suite(parent)
|
26
|
+
@parents.unshift(parent)
|
27
|
+
parent = parent.parent
|
28
|
+
@parents
|
29
|
+
|
30
|
+
|
31
|
+
result: ->
|
32
|
+
results = @spec.results()
|
33
|
+
status = "failed"
|
34
|
+
status = "passed" if results.passed()
|
35
|
+
status = "pending" if @spec.pending
|
36
|
+
status: status
|
37
|
+
skipped: results.skipped
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#= require teaspoon/teaspoon
|
2
|
+
#= require_self
|
3
|
+
#= require_tree ./jasmine2
|
4
|
+
|
5
|
+
unless jasmineRequire?
|
6
|
+
throw new Teaspoon.Error('Jasmine 2 not found -- use `suite.use_framework :jasmine` and adjust or remove the `suite.javascripts` directive.')
|
7
|
+
|
8
|
+
@Teaspoon ?= {}
|
9
|
+
@Teaspoon.Jasmine2 ?= {}
|
10
|
+
@Teaspoon.Jasmine2.Reporters ?= {}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#= require teaspoon/fixture
|
2
|
+
|
3
|
+
class Teaspoon.Jasmine2.Fixture extends Teaspoon.Fixture
|
4
|
+
|
5
|
+
@load: ->
|
6
|
+
args = arguments
|
7
|
+
@env().beforeEach => fixture.__super__.constructor.load.apply(@, args)
|
8
|
+
@env().afterEach => @cleanup()
|
9
|
+
super
|
10
|
+
|
11
|
+
|
12
|
+
@set: ->
|
13
|
+
args = arguments
|
14
|
+
@env().beforeEach => fixture.__super__.constructor.set.apply(@, args)
|
15
|
+
@env().afterEach => @cleanup()
|
16
|
+
super
|
17
|
+
|
18
|
+
|
19
|
+
@env: -> window.jasmine.getEnv()
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Teaspoon.setFramework(Teaspoon.Jasmine2)
|
2
|
+
|
3
|
+
# Jasmine 2 runs the spec filter when the #it block are evaluated. This
|
4
|
+
# means we need to set the filter upon page load, instead of when the
|
5
|
+
# runner is initialized. Since Jasmine is loaded into the page first, then
|
6
|
+
# the tests, then Teaspoon is initialized, this is set up to run early in
|
7
|
+
# the boot process.
|
8
|
+
setupSpecFilter = (env) ->
|
9
|
+
if grep = Teaspoon.Runner::getParams()["grep"]
|
10
|
+
env.specFilter = (spec) ->
|
11
|
+
spec.getFullName().indexOf(grep) == 0
|
12
|
+
|
13
|
+
extend = (destination, source) ->
|
14
|
+
for property of source
|
15
|
+
destination[property] = source[property]
|
16
|
+
destination
|
17
|
+
|
18
|
+
|
19
|
+
# Set up Jasmine 2
|
20
|
+
window.jasmine = jasmineRequire.core(jasmineRequire)
|
21
|
+
env = window.jasmine.getEnv()
|
22
|
+
setupSpecFilter(env)
|
23
|
+
extend(window, jasmineRequire.interface(jasmine, env))
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#= require teaspoon/reporters/console
|
2
|
+
|
3
|
+
class Teaspoon.Jasmine2.Reporters.Console extends Teaspoon.Reporters.Console
|
4
|
+
|
5
|
+
reportRunnerStarting: ->
|
6
|
+
@currentAssertions = []
|
7
|
+
@log
|
8
|
+
type: "runner"
|
9
|
+
total: null
|
10
|
+
start: JSON.parse(JSON.stringify(@start))
|
11
|
+
|
12
|
+
|
13
|
+
reportRunnerResults: =>
|
14
|
+
@log
|
15
|
+
type: "result"
|
16
|
+
elapsed: ((new Teaspoon.Date().getTime() - @start.getTime()) / 1000).toFixed(5)
|
17
|
+
coverage: window.__coverage__
|
18
|
+
Teaspoon.finished = true
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Teaspoon.Jasmine2.Responder
|
2
|
+
|
3
|
+
constructor: (@reporter) ->
|
4
|
+
|
5
|
+
|
6
|
+
jasmineStarted: (runner) ->
|
7
|
+
@reporter.reportRunnerStarting(total: runner.totalSpecsDefined)
|
8
|
+
|
9
|
+
|
10
|
+
jasmineDone: ->
|
11
|
+
@reporter.reportRunnerResults()
|
12
|
+
|
13
|
+
|
14
|
+
suiteStarted: (suite) ->
|
15
|
+
if @currentSuite # suite already running, we're nested
|
16
|
+
suite.parent = @currentSuite
|
17
|
+
@currentSuite = suite
|
18
|
+
|
19
|
+
@reporter.reportSuiteStarting(new Teaspoon.Jasmine2.Suite(suite))
|
20
|
+
|
21
|
+
|
22
|
+
suiteDone: (suite) ->
|
23
|
+
@currentSuite = @currentSuite.parent
|
24
|
+
|
25
|
+
@reporter.reportSuiteResults(new Teaspoon.Jasmine2.Suite(suite))
|
26
|
+
|
27
|
+
|
28
|
+
specStarted: (spec) ->
|
29
|
+
# Jasmine 2 reports the spec starting even though it may
|
30
|
+
# be filtered out, but there's no way to tell.
|
31
|
+
# TODO: Is there a way to clean this up?
|
32
|
+
if jasmine.getEnv().specFilter(getFullName: -> spec.fullName)
|
33
|
+
spec.parent = @currentSuite
|
34
|
+
@reporter.reportSpecStarting(new Teaspoon.Jasmine2.Spec(spec))
|
35
|
+
|
36
|
+
|
37
|
+
specDone: (spec) ->
|
38
|
+
spec.parent = @currentSuite
|
39
|
+
@reporter.reportSpecResults(new Teaspoon.Jasmine2.Spec(spec))
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#= require teaspoon/runner
|
2
|
+
|
3
|
+
class Teaspoon.Jasmine2.Runner extends Teaspoon.Runner
|
4
|
+
|
5
|
+
constructor: ->
|
6
|
+
@env = window.jasmine.getEnv()
|
7
|
+
super
|
8
|
+
@env.execute()
|
9
|
+
|
10
|
+
|
11
|
+
setup: ->
|
12
|
+
# add the responder
|
13
|
+
reporter = new (@getReporter())()
|
14
|
+
responder = new Teaspoon.Jasmine2.Responder(reporter)
|
15
|
+
@env.addReporter(responder)
|
16
|
+
|
17
|
+
# add fixture support
|
18
|
+
@addFixtureSupport()
|
19
|
+
|
20
|
+
|
21
|
+
addFixtureSupport: ->
|
22
|
+
return unless jasmine.getFixtures && @fixturePath
|
23
|
+
jasmine.getFixtures().containerId = "teaspoon-fixtures"
|
24
|
+
jasmine.getFixtures().fixturesPath = @fixturePath
|
25
|
+
jasmine.getStyleFixtures().fixturesPath = @fixturePath
|
26
|
+
jasmine.getJSONFixtures().fixturesPath = @fixturePath
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class Teaspoon.Jasmine2.Spec
|
2
|
+
|
3
|
+
constructor: (@spec) ->
|
4
|
+
@fullDescription = @spec.fullName
|
5
|
+
@description = @spec.description
|
6
|
+
@link = "?grep=#{encodeURIComponent(@fullDescription)}"
|
7
|
+
@parent = @spec.parent
|
8
|
+
@suiteName = @parent.fullName
|
9
|
+
@viewId = @spec.id
|
10
|
+
@pending = @spec.status == "pending"
|
11
|
+
|
12
|
+
|
13
|
+
errors: ->
|
14
|
+
return [] unless @spec.failedExpectations.length
|
15
|
+
for item in @spec.failedExpectations
|
16
|
+
{message: item.message, stack: item.stack}
|
17
|
+
|
18
|
+
|
19
|
+
getParents: ->
|
20
|
+
return @parents if @parents
|
21
|
+
@parents ||= []
|
22
|
+
parent = @parent
|
23
|
+
while parent
|
24
|
+
parent = new Teaspoon.Jasmine2.Suite(parent)
|
25
|
+
@parents.unshift(parent)
|
26
|
+
parent = parent.parent
|
27
|
+
@parents
|
28
|
+
|
29
|
+
|
30
|
+
result: ->
|
31
|
+
status: @status()
|
32
|
+
skipped: @spec.status == "disabled"
|
33
|
+
|
34
|
+
|
35
|
+
status: ->
|
36
|
+
if @spec.status == "disabled" then "passed" else @spec.status
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "teaspoon/framework/base"
|
2
|
+
|
3
|
+
module Teaspoon
|
4
|
+
module Jasmine
|
5
|
+
class Framework < Teaspoon::Framework::Base
|
6
|
+
# specify the framework name
|
7
|
+
framework_name :jasmine
|
8
|
+
|
9
|
+
# register standard versions
|
10
|
+
register_version "1.3.1", "jasmine/1.3.1.js",
|
11
|
+
dependencies: ["teaspoon-jasmine1.js"],
|
12
|
+
dev_deps: ["teaspoon/jasmine1.js"]
|
13
|
+
|
14
|
+
versions = ["2.0.3", "2.1.3", "2.2.0"]
|
15
|
+
|
16
|
+
versions.each do |version|
|
17
|
+
register_version version, "jasmine/#{version}.js",
|
18
|
+
dependencies: ["teaspoon-jasmine2.js"],
|
19
|
+
dev_deps: ["teaspoon/jasmine2.js"]
|
20
|
+
end
|
21
|
+
|
22
|
+
# add asset paths
|
23
|
+
add_asset_path File.expand_path("../../../teaspoon/jasmine/assets", __FILE__)
|
24
|
+
|
25
|
+
# add custom install templates
|
26
|
+
add_template_path File.expand_path("../../../teaspoon/jasmine/templates", __FILE__)
|
27
|
+
|
28
|
+
# specify where to install, and add installation steps.
|
29
|
+
install_to "spec" do
|
30
|
+
ext = options[:coffee] ? ".coffee" : ".js"
|
31
|
+
copy_file "spec_helper#{ext}", "spec/javascripts/spec_helper#{ext}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Teaspoon includes some support files, but you can use anything from your own support path too.
|
2
|
+
# require support/jasmine-jquery-1.7.0
|
3
|
+
# require support/jasmine-jquery-2.0.0
|
4
|
+
# require support/jasmine-jquery-2.1.0
|
5
|
+
# require support/sinon
|
6
|
+
# require support/your-support-file
|
7
|
+
#
|
8
|
+
# PhantomJS (Teaspoons default driver) doesn't have support for Function.prototype.bind, which has caused confusion.
|
9
|
+
# Use this polyfill to avoid the confusion.
|
10
|
+
#= require support/bind-poly
|
11
|
+
#
|
12
|
+
# You can require your own javascript files here. By default this will include everything in application, however you
|
13
|
+
# may get better load performance if you require the specific files that are being used in the spec that tests them.
|
14
|
+
#= require application
|
15
|
+
#
|
16
|
+
# Deferring execution
|
17
|
+
# If you're using CommonJS, RequireJS or some other asynchronous library you can defer execution. Call
|
18
|
+
# Teaspoon.execute() after everything has been loaded. Simple example of a timeout:
|
19
|
+
#
|
20
|
+
# Teaspoon.defer = true
|
21
|
+
# setTimeout(Teaspoon.execute, 1000)
|
22
|
+
#
|
23
|
+
# Matching files
|
24
|
+
# By default Teaspoon will look for files that match _spec.{js,js.coffee,.coffee}. Add a filename_spec.js file in your
|
25
|
+
# spec path and it'll be included in the default suite automatically. If you want to customize suites, check out the
|
26
|
+
# configuration in teaspoon_env.rb
|
27
|
+
#
|
28
|
+
# Manifest
|
29
|
+
# If you'd rather require your spec files manually (to control order for instance) you can disable the suite matcher in
|
30
|
+
# the configuration and use this file as a manifest.
|
31
|
+
#
|
32
|
+
# For more information: http://github.com/modeset/teaspoon
|
@@ -0,0 +1,32 @@
|
|
1
|
+
// Teaspoon includes some support files, but you can use anything from your own support path too.
|
2
|
+
// require support/jasmine-jquery-1.7.0
|
3
|
+
// require support/jasmine-jquery-2.0.0
|
4
|
+
// require support/jasmine-jquery-2.1.0
|
5
|
+
// require support/sinon
|
6
|
+
// require support/your-support-file
|
7
|
+
//
|
8
|
+
// PhantomJS (Teaspoons default driver) doesn't have support for Function.prototype.bind, which has caused confusion.
|
9
|
+
// Use this polyfill to avoid the confusion.
|
10
|
+
//= require support/bind-poly
|
11
|
+
//
|
12
|
+
// You can require your own javascript files here. By default this will include everything in application, however you
|
13
|
+
// may get better load performance if you require the specific files that are being used in the spec that tests them.
|
14
|
+
//= require application
|
15
|
+
//
|
16
|
+
// Deferring execution
|
17
|
+
// If you're using CommonJS, RequireJS or some other asynchronous library you can defer execution. Call
|
18
|
+
// Teaspoon.execute() after everything has been loaded. Simple example of a timeout:
|
19
|
+
//
|
20
|
+
// Teaspoon.defer = true
|
21
|
+
// setTimeout(Teaspoon.execute, 1000)
|
22
|
+
//
|
23
|
+
// Matching files
|
24
|
+
// By default Teaspoon will look for files that match _spec.{js,js.coffee,.coffee}. Add a filename_spec.js file in your
|
25
|
+
// spec path and it'll be included in the default suite automatically. If you want to customize suites, check out the
|
26
|
+
// configuration in teaspoon_env.rb
|
27
|
+
//
|
28
|
+
// Manifest
|
29
|
+
// If you'd rather require your spec files manually (to control order for instance) you can disable the suite matcher in
|
30
|
+
// the configuration and use this file as a manifest.
|
31
|
+
//
|
32
|
+
// For more information: http://github.com/modeset/teaspoon
|