jasmine-stories 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +19 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +110 -0
- data/MIT-LICENSE +20 -0
- data/README.md +98 -0
- data/Rakefile +25 -0
- data/app/assets/images/.gitkeep +0 -0
- data/app/assets/javascripts/jasmine-stories.js.coffee +37 -0
- data/app/assets/stylesheets/application.css +7 -0
- data/app/controllers/jasmine_stories/application_controller.rb +4 -0
- data/app/controllers/jasmine_stories/spec_controller.rb +10 -0
- data/app/views/jasmine_stories/spec/index.html.haml +10 -0
- data/config/initializers/jasmine-stories.rb +1 -0
- data/config/routes.rb +7 -0
- data/jasmine-stories.gemspec +12 -0
- data/lib/jasmine-stories.rb +5 -0
- data/lib/jasmine-stories/engine.rb +5 -0
- data/vendor/assets/images/jasmine_favicon.png +0 -0
- data/vendor/assets/javascripts/jasmine-grammar.js +247 -0
- data/vendor/assets/javascripts/jasmine-html.js +190 -0
- data/vendor/assets/javascripts/jasmine-jquery.js +306 -0
- data/vendor/assets/javascripts/jasmine-reporting.js +191 -0
- data/vendor/assets/javascripts/jasmine.js +2476 -0
- data/vendor/assets/javascripts/namespace.js +499 -0
- data/vendor/assets/stylesheets/jasmine-be-calm.css +106 -0
- data/vendor/assets/stylesheets/jasmine.css +166 -0
- metadata +87 -0
data/.gitignore
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
.bundle
|
2
|
+
db/*.sqlite3
|
3
|
+
log/*.log
|
4
|
+
tmp/
|
5
|
+
.*.sw*
|
6
|
+
*.orig
|
7
|
+
.swp
|
8
|
+
public/system
|
9
|
+
*.*.BACKUP.*.lock
|
10
|
+
*.*.BASE.*.lock
|
11
|
+
*.*.REMOTE.*.lock
|
12
|
+
*.*.LOCAL.*.lock
|
13
|
+
.DS_Store
|
14
|
+
*.*.gz
|
15
|
+
Session.vim
|
16
|
+
err.txt
|
17
|
+
.sass-cache
|
18
|
+
public/stylesheets/*.css
|
19
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jasminerice (0.0.8)
|
5
|
+
haml
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (3.1.0)
|
11
|
+
actionpack (= 3.1.0)
|
12
|
+
mail (~> 2.3.0)
|
13
|
+
actionpack (3.1.0)
|
14
|
+
activemodel (= 3.1.0)
|
15
|
+
activesupport (= 3.1.0)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
i18n (~> 0.6)
|
19
|
+
rack (~> 1.3.2)
|
20
|
+
rack-cache (~> 1.0.3)
|
21
|
+
rack-mount (~> 0.8.2)
|
22
|
+
rack-test (~> 0.6.1)
|
23
|
+
sprockets (~> 2.0.0)
|
24
|
+
activemodel (3.1.0)
|
25
|
+
activesupport (= 3.1.0)
|
26
|
+
bcrypt-ruby (~> 3.0.0)
|
27
|
+
builder (~> 3.0.0)
|
28
|
+
i18n (~> 0.6)
|
29
|
+
activerecord (3.1.0)
|
30
|
+
activemodel (= 3.1.0)
|
31
|
+
activesupport (= 3.1.0)
|
32
|
+
arel (~> 2.2.1)
|
33
|
+
tzinfo (~> 0.3.29)
|
34
|
+
activeresource (3.1.0)
|
35
|
+
activemodel (= 3.1.0)
|
36
|
+
activesupport (= 3.1.0)
|
37
|
+
activesupport (3.1.0)
|
38
|
+
multi_json (~> 1.0)
|
39
|
+
arel (2.2.1)
|
40
|
+
bcrypt-ruby (3.0.1)
|
41
|
+
bcrypt-ruby (3.0.1-java)
|
42
|
+
builder (3.0.0)
|
43
|
+
columnize (0.3.4)
|
44
|
+
erubis (2.7.0)
|
45
|
+
haml (3.1.3)
|
46
|
+
hike (1.2.1)
|
47
|
+
i18n (0.6.0)
|
48
|
+
json (1.6.1)
|
49
|
+
json (1.6.1-java)
|
50
|
+
linecache (0.46)
|
51
|
+
rbx-require-relative (> 0.0.4)
|
52
|
+
mail (2.3.0)
|
53
|
+
i18n (>= 0.4.0)
|
54
|
+
mime-types (~> 1.16)
|
55
|
+
treetop (~> 1.4.8)
|
56
|
+
mime-types (1.17.2)
|
57
|
+
multi_json (1.0.3)
|
58
|
+
polyglot (0.3.2)
|
59
|
+
rack (1.3.5)
|
60
|
+
rack-cache (1.0.3)
|
61
|
+
rack (>= 0.4)
|
62
|
+
rack-mount (0.8.3)
|
63
|
+
rack (>= 1.0.0)
|
64
|
+
rack-ssl (1.3.2)
|
65
|
+
rack
|
66
|
+
rack-test (0.6.1)
|
67
|
+
rack (>= 1.0)
|
68
|
+
rails (3.1.0)
|
69
|
+
actionmailer (= 3.1.0)
|
70
|
+
actionpack (= 3.1.0)
|
71
|
+
activerecord (= 3.1.0)
|
72
|
+
activeresource (= 3.1.0)
|
73
|
+
activesupport (= 3.1.0)
|
74
|
+
bundler (~> 1.0)
|
75
|
+
railties (= 3.1.0)
|
76
|
+
railties (3.1.0)
|
77
|
+
actionpack (= 3.1.0)
|
78
|
+
activesupport (= 3.1.0)
|
79
|
+
rack-ssl (~> 1.3.2)
|
80
|
+
rake (>= 0.8.7)
|
81
|
+
rdoc (~> 3.4)
|
82
|
+
thor (~> 0.14.6)
|
83
|
+
rake (0.9.2.2)
|
84
|
+
rbx-require-relative (0.0.5)
|
85
|
+
rdoc (3.11)
|
86
|
+
json (~> 1.4)
|
87
|
+
ruby-debug (0.10.4)
|
88
|
+
columnize (>= 0.1)
|
89
|
+
ruby-debug-base (~> 0.10.4.0)
|
90
|
+
ruby-debug-base (0.10.4)
|
91
|
+
linecache (>= 0.3)
|
92
|
+
sprockets (2.0.3)
|
93
|
+
hike (~> 1.2)
|
94
|
+
rack (~> 1.0)
|
95
|
+
tilt (~> 1.1, != 1.3.0)
|
96
|
+
thor (0.14.6)
|
97
|
+
tilt (1.3.3)
|
98
|
+
treetop (1.4.10)
|
99
|
+
polyglot
|
100
|
+
polyglot (>= 0.3.1)
|
101
|
+
tzinfo (0.3.30)
|
102
|
+
|
103
|
+
PLATFORMS
|
104
|
+
java
|
105
|
+
ruby
|
106
|
+
|
107
|
+
DEPENDENCIES
|
108
|
+
jasminerice!
|
109
|
+
rails (= 3.1.0)
|
110
|
+
ruby-debug (>= 0.10.3)
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
Jasminerice
|
2
|
+
===========
|
3
|
+
|
4
|
+
Utilizing [Jasmine](http://pivotal.github.com/jasmine/) and taking full advantage
|
5
|
+
of the Rails 3.1 asset pipeline. jasmine-stories removes any excuse YOU have for
|
6
|
+
not testing your out of control application.
|
7
|
+
This project rocks and uses the MIT-LICENSE.
|
8
|
+
|
9
|
+
Headless Testing
|
10
|
+
----------------
|
11
|
+
|
12
|
+
See [guard-jasmine](https://github.com/netzpirat/guard-jasmine) for details.
|
13
|
+
|
14
|
+
Installation
|
15
|
+
------------
|
16
|
+
|
17
|
+
This is a gem specifically for Rails 3.1. Just include it in
|
18
|
+
your `Gemfile`:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
group :development, :test do
|
22
|
+
gem "jasmine-stories"
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
26
|
+
The engine is automatically mounted into your application in the development
|
27
|
+
and test environments. If you'd like to change that behavior, you can
|
28
|
+
override the array `JasmineStories.environments` in an initializer.
|
29
|
+
|
30
|
+
Usage
|
31
|
+
-----
|
32
|
+
|
33
|
+
### CoffeeScripts
|
34
|
+
|
35
|
+
Create a file `spec/javascripts/stories.js.coffee` with the following content:
|
36
|
+
|
37
|
+
#=require_tree ./stories
|
38
|
+
|
39
|
+
This pulls in all your specs from the `javascripts/stories` directory into Jasmine:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
spec/javascripts/stories/*_story.js.coffee
|
43
|
+
spec/javascripts/stories/*_story.js
|
44
|
+
spec/javascripts/stories/*_story.js.erb
|
45
|
+
```
|
46
|
+
|
47
|
+
The Rails 3.1 asset pipeline using [Sprockets](https://github.com/sstephenson/sprockets)
|
48
|
+
and [Tilt](https://github.com/rtomayko/tilt) ensure conversion.
|
49
|
+
|
50
|
+
As well you can use the `#require` dependency mechanisms in your specs to
|
51
|
+
pull dependencies. Here's an example `spec/javascripts/foo.js.coffee`:
|
52
|
+
|
53
|
+
```coffeescript
|
54
|
+
#= require foo
|
55
|
+
#= require bar
|
56
|
+
|
57
|
+
describe "Foo", ->
|
58
|
+
it "it is not bar", ->
|
59
|
+
v = new Foo()
|
60
|
+
expect(v.bar()).toEqual(false)
|
61
|
+
|
62
|
+
describe "Bar", ->
|
63
|
+
it "it is not foo", ->
|
64
|
+
v = new Bar()
|
65
|
+
expect(v.foo()).toEqual(false)
|
66
|
+
```
|
67
|
+
|
68
|
+
### Stylesheets
|
69
|
+
|
70
|
+
For including stylesheets in your specs, Jasminerice uses `spec/javascripts/spec.css`.
|
71
|
+
Use Sprockets directives to include the right css files:
|
72
|
+
|
73
|
+
```css
|
74
|
+
/*
|
75
|
+
*= require application
|
76
|
+
*/
|
77
|
+
```
|
78
|
+
|
79
|
+
### Start server
|
80
|
+
|
81
|
+
Now start your server
|
82
|
+
|
83
|
+
```bash
|
84
|
+
rails s
|
85
|
+
```
|
86
|
+
|
87
|
+
Goto
|
88
|
+
|
89
|
+
```bash
|
90
|
+
http://localhost:3000/jasmine-stories
|
91
|
+
```
|
92
|
+
|
93
|
+
and there are your acceptance tests.
|
94
|
+
|
95
|
+
Author
|
96
|
+
------
|
97
|
+
|
98
|
+
* Dominik Guzei (http://wizzart.at | http://nerdkitchen.org)
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler'
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'rdoc/task'
|
11
|
+
rescue LoadError
|
12
|
+
require 'rdoc/rdoc'
|
13
|
+
require 'rake/rdoctask'
|
14
|
+
RDoc::Task = Rake::RDocTask
|
15
|
+
end
|
16
|
+
|
17
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'JasmineStories'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README.rdoc')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
|
File without changes
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#=require jquery
|
2
|
+
#=require jquery_ujs
|
3
|
+
|
4
|
+
#=require namespace
|
5
|
+
#=require jasmine
|
6
|
+
#=require jasmine-html
|
7
|
+
#=require jasmine-jquery
|
8
|
+
#=require jasmine-grammar
|
9
|
+
#=require jasmine-reporting
|
10
|
+
|
11
|
+
# load all jasmine-species features
|
12
|
+
Namespace.use('jasmine.grammar.FeatureStory.*');
|
13
|
+
Namespace.use('jasmine.grammar.GWT.*');
|
14
|
+
Namespace.use('jasmine.grammar.Meta.*');
|
15
|
+
|
16
|
+
execJasmine = ->
|
17
|
+
jasmineEnv.execute()
|
18
|
+
jasmineEnv = jasmine.getEnv()
|
19
|
+
jasmineEnv.updateInterval = 1000
|
20
|
+
|
21
|
+
window.jsApiReporter = new jasmine.JsApiReporter()
|
22
|
+
storyReporter = new jasmine.reporting.StyledHtmlReporter()
|
23
|
+
|
24
|
+
jasmineEnv.addReporter storyReporter
|
25
|
+
jasmineEnv.addReporter jsApiReporter
|
26
|
+
|
27
|
+
jasmineEnv.specFilter = (spec) ->
|
28
|
+
storyReporter.specFilter spec
|
29
|
+
|
30
|
+
jasmine.stories = {}
|
31
|
+
jasmine.stories.autoExecute = true
|
32
|
+
|
33
|
+
currentWindowOnload = window.onload
|
34
|
+
window.onload = ->
|
35
|
+
currentWindowOnload() if currentWindowOnload
|
36
|
+
if jasmine.stories.autoExecute
|
37
|
+
execJasmine()
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*= require_self
|
6
|
+
*= require_tree .
|
7
|
+
*/
|
@@ -0,0 +1,10 @@
|
|
1
|
+
%html
|
2
|
+
%head
|
3
|
+
%title Jasmine Spec Runner
|
4
|
+
= stylesheet_link_tag "jasmine"
|
5
|
+
= stylesheet_link_tag "jasmine-be-calm"
|
6
|
+
= stylesheet_link_tag "spec"
|
7
|
+
= javascript_include_tag "jasmine-stories", :debug => Rails.env.development?
|
8
|
+
= javascript_include_tag "stories", :debug => Rails.env.development?
|
9
|
+
= csrf_meta_tags
|
10
|
+
%body
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails.application.config.assets.paths << File.join(Rails.root, "spec", "javascripts")
|
data/config/routes.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Provide a simple gemspec so you can easily use your
|
2
|
+
# project in your rails apps through git.
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "jasmine-stories"
|
5
|
+
s.summary = "Pain free coffeescript acceptance testing for Rails 3.1 using jasmine-species"
|
6
|
+
s.description = "Full support for the Rails 3.1 asset pipeline when acceptance testing your coffeescript or javascript using jasmine"
|
7
|
+
s.files = `git ls-files`.split "\n"
|
8
|
+
s.authors = ["Dominik Guzei"]
|
9
|
+
s.version = "0.0.1"
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.add_dependency( 'haml' )
|
12
|
+
end
|
Binary file
|
@@ -0,0 +1,247 @@
|
|
1
|
+
/**
|
2
|
+
* Jasmine Grammar - Additional Jasmine grammar to enable alternate BDD approaches.
|
3
|
+
*
|
4
|
+
* Copyright (C) 2010-2011, Rudy Lattae
|
5
|
+
* License: Simplified BSD
|
6
|
+
*
|
7
|
+
* Jasmine-Grammar contains some additions to the jasmine api that make it
|
8
|
+
* more suitable to alternate BDD approaches. The end-goal is streamline the
|
9
|
+
* grammatical aspect of specing out an application from different view-points.
|
10
|
+
*
|
11
|
+
* The new grammar should make it easier to create other types of specifications
|
12
|
+
* apart from "describe" and "it should". They are simply wrappers
|
13
|
+
* for "describe" and "it" so they follow the same rules for nesting.
|
14
|
+
*/
|
15
|
+
|
16
|
+
// Top level namespace for the package
|
17
|
+
jasmine.grammar = (typeof jasmine.grammar === 'undefined') ? {} : jasmine.grammar;
|
18
|
+
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Feature / Story => Scenario => ... style grammar
|
22
|
+
*/
|
23
|
+
jasmine.grammar.FeatureStory = {
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Defines a suite tagged as a "feature"
|
27
|
+
*/
|
28
|
+
feature: function(description, specDefinitions) {
|
29
|
+
var suite = jasmine.grammar.getEnv().describe('Feature: ' + description, specDefinitions);
|
30
|
+
suite.tags = ['feature'];
|
31
|
+
return suite;
|
32
|
+
},
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Defines a suite tagged as a "story"
|
36
|
+
*/
|
37
|
+
story: function(description, specDefinitions) {
|
38
|
+
var suite = jasmine.grammar.getEnv().describe('Story: ' + description, specDefinitions);
|
39
|
+
suite.tags = ['story'];
|
40
|
+
return suite;
|
41
|
+
},
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Defines a suite tagged as a "component"
|
45
|
+
*/
|
46
|
+
component: function(description, specDefinitions) {
|
47
|
+
var suite = jasmine.grammar.getEnv().describe('Component: ' + description, specDefinitions);
|
48
|
+
suite.tags = ['component'];
|
49
|
+
return suite;
|
50
|
+
},
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Defines a spec marked as a "scenario"
|
54
|
+
*/
|
55
|
+
scenario: function(desc, func) {
|
56
|
+
return jasmine.grammar.getEnv().it('Scenario: ' + desc, func);
|
57
|
+
}
|
58
|
+
};
|
59
|
+
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Given => When => Then ... style grammar
|
63
|
+
*/
|
64
|
+
jasmine.grammar.GWT = {
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Defines a "given" step as a runs block that marks the beginning of a GWT chain
|
68
|
+
*/
|
69
|
+
given: function(desc, func) {
|
70
|
+
return this._addStepToCurrentSpec('Given ' + desc, func);
|
71
|
+
},
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Defines a "when" step as a runs block that marks the interesting event in a GWT chain
|
75
|
+
*/
|
76
|
+
when: function(desc, func) {
|
77
|
+
return this._addStepToCurrentSpec('When ' + desc, func);
|
78
|
+
},
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Defines a "then" step as a runs block that marks the conclusion of a Given, when, then construct
|
82
|
+
*/
|
83
|
+
then: function(desc, func) {
|
84
|
+
return this._addStepToCurrentSpec('Then ' + desc, func);
|
85
|
+
},
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Defines an "and" step as a runs block that is a continuation from a "then" statement
|
89
|
+
*/
|
90
|
+
and: function(desc, func) {
|
91
|
+
return this._addStepToCurrentSpec('And ' + desc, func);
|
92
|
+
},
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Defines a "but" step as a runs block that is a continuation from a "then" statement
|
96
|
+
*/
|
97
|
+
but: function(desc, func) {
|
98
|
+
return this._addStepToCurrentSpec('But ' + desc, func);
|
99
|
+
},
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Adds the given function as a step (runs block) in the current spec. Also adds the description to the details list of the spec
|
103
|
+
*/
|
104
|
+
_addStepToCurrentSpec: function(desc, func) {
|
105
|
+
var spec = jasmine.grammar.getEnv().currentSpec;
|
106
|
+
spec.details = spec.details || [];
|
107
|
+
spec.details.push(desc);
|
108
|
+
spec.runs(func);
|
109
|
+
return spec;
|
110
|
+
}
|
111
|
+
};
|
112
|
+
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Add proper case aliases to GWT for Coffeescript use
|
116
|
+
*/
|
117
|
+
|
118
|
+
(function(GWT) {
|
119
|
+
GWT.Given = GWT.given;
|
120
|
+
GWT.When = GWT.when;
|
121
|
+
GWT.Then = GWT.then;
|
122
|
+
GWT.And = GWT.and;
|
123
|
+
GWT.But = GWT.but;
|
124
|
+
}) (jasmine.grammar.GWT);
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Concern => Context => Specification style grammar
|
131
|
+
*/
|
132
|
+
jasmine.grammar.ContextSpecification = {
|
133
|
+
|
134
|
+
/**
|
135
|
+
* Defines a suite tagged as a "concern"
|
136
|
+
*/
|
137
|
+
concern: function(description, specDefinitions) {
|
138
|
+
var suite = jasmine.grammar.getEnv().describe(description, specDefinitions);
|
139
|
+
suite.tags = ['concern'];
|
140
|
+
return suite;
|
141
|
+
},
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Defines a suite tagged as a "context"
|
145
|
+
*/
|
146
|
+
context: function(description, specDefinitions) {
|
147
|
+
var suite = jasmine.grammar.getEnv().describe(description, specDefinitions);
|
148
|
+
suite.tags = ['context'];
|
149
|
+
return suite;
|
150
|
+
},
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Defines a simple spec -- similar to it
|
154
|
+
*/
|
155
|
+
spec: function(desc, func) {
|
156
|
+
return jasmine.grammar.getEnv().it(desc, func);
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
/**
|
161
|
+
* Executable docs (Topic => Example) style grammar
|
162
|
+
*/
|
163
|
+
jasmine.grammar.XDoc = {
|
164
|
+
|
165
|
+
/**
|
166
|
+
* Defines a suite tagged as a "topic"
|
167
|
+
*/
|
168
|
+
topic: function(description, specDefinitions) {
|
169
|
+
var suite = jasmine.grammar.getEnv().describe(description, specDefinitions);
|
170
|
+
suite.tags = ['topic'];
|
171
|
+
return suite;
|
172
|
+
},
|
173
|
+
|
174
|
+
/**
|
175
|
+
* Defines a suite tagged as an "example".
|
176
|
+
*
|
177
|
+
* An axample suite actually stores the inner suites as a string in the "defs" attribute
|
178
|
+
*/
|
179
|
+
example: function(description, specDefinitions) {
|
180
|
+
var suite = jasmine.grammar.getEnv().describe(description, specDefinitions);
|
181
|
+
suite.tags = ['example'];
|
182
|
+
suite.expose = true;
|
183
|
+
suite.defs = specDefinitions.toString()
|
184
|
+
.replace(/^function.*\(.*\).*{/, '')
|
185
|
+
.replace(/}$/, '').trim(); // stored for later output
|
186
|
+
return suite;
|
187
|
+
},
|
188
|
+
|
189
|
+
/**
|
190
|
+
* Defines a simple spec without any associated function
|
191
|
+
*/
|
192
|
+
pass: function(desc, func) {
|
193
|
+
return jasmine.grammar.getEnv().it(desc);
|
194
|
+
}
|
195
|
+
};
|
196
|
+
|
197
|
+
|
198
|
+
/**
|
199
|
+
* Some more useful constructs that attach metadata to suites and specs
|
200
|
+
*/
|
201
|
+
jasmine.grammar.Meta = {
|
202
|
+
|
203
|
+
/**
|
204
|
+
* Adds summary content to the current suite.
|
205
|
+
*
|
206
|
+
* @param {String} content(s) variable number of detail content
|
207
|
+
* @see jasmine.grammar.SuiteDetails
|
208
|
+
*/
|
209
|
+
summary: function() {
|
210
|
+
var suite = jasmine.grammar.getEnv().currentSuite;
|
211
|
+
suite.summary = suite.summary || [];
|
212
|
+
|
213
|
+
if (arguments.length > 0) {
|
214
|
+
for(i=0; i<arguments.length; i++) {
|
215
|
+
suite.summary.push(arguments[i]);
|
216
|
+
}
|
217
|
+
}
|
218
|
+
},
|
219
|
+
|
220
|
+
/**
|
221
|
+
* Adds detail entries in the current spec.
|
222
|
+
*
|
223
|
+
* @param {String} content(s) variable number of detail content
|
224
|
+
* @see jasmine.grammar.SuiteDetails
|
225
|
+
*/
|
226
|
+
details: function() {
|
227
|
+
var spec = jasmine.grammar.getEnv().currentSpec;
|
228
|
+
spec.details = spec.details || [];
|
229
|
+
|
230
|
+
if (arguments.length > 0) {
|
231
|
+
for(i=0; i<arguments.length; i++) {
|
232
|
+
spec.details.push(arguments[i]);
|
233
|
+
}
|
234
|
+
}
|
235
|
+
}
|
236
|
+
};
|
237
|
+
|
238
|
+
|
239
|
+
// Utilities
|
240
|
+
// =========
|
241
|
+
|
242
|
+
/**
|
243
|
+
* Getter for the Jasmine environment. Makes it possible to inject a different environment when necessary.
|
244
|
+
*/
|
245
|
+
jasmine.grammar.getEnv = function() {
|
246
|
+
return jasmine.grammar._currentEnv = jasmine.grammar._currentEnv || jasmine.getEnv();
|
247
|
+
};
|