visionmedia-jspec 1.1.7 → 2.0.0
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/History.rdoc +19 -0
- data/Manifest +6 -2
- data/README.rdoc +122 -86
- data/bin/jspec +1 -1
- data/jspec.gemspec +4 -4
- data/lib/images/loading.gif +0 -0
- data/lib/jspec.css +17 -2
- data/lib/jspec.jquery.js +4 -14
- data/lib/jspec.js +508 -154
- data/server/browsers.rb +3 -11
- data/server/server.rb +2 -13
- data/spec/server.html +5 -2
- data/spec/spec.grammar-less.js +34 -0
- data/spec/spec.grammar.js +27 -16
- data/spec/spec.html +6 -3
- data/spec/spec.jquery.js +32 -34
- data/spec/spec.js +86 -0
- data/spec/{spec.core.js → spec.matchers.js} +115 -107
- data/spec/spec.rhino.js +5 -1
- data/spec/spec.shared-behaviors.js +51 -0
- data/spec/spec.utils.js +138 -0
- metadata +9 -4
- data/spec/spec.core.dom.js +0 -12
data/spec/spec.rhino.js
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
|
2
2
|
load('lib/jspec.js')
|
3
|
+
load('spec/spec.grammar-less.js')
|
3
4
|
|
4
5
|
JSpec
|
5
6
|
.exec('spec/spec.grammar.js')
|
6
|
-
.exec('spec/spec.
|
7
|
+
.exec('spec/spec.js')
|
8
|
+
.exec('spec/spec.matchers.js')
|
9
|
+
.exec('spec/spec.utils.js')
|
10
|
+
.exec('spec/spec.shared-behaviors.js')
|
7
11
|
.run({ formatter : JSpec.formatters.Terminal, failuresOnly : true })
|
8
12
|
.report()
|
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
describe 'Shared Behaviors'
|
3
|
+
describe 'User'
|
4
|
+
before
|
5
|
+
User = function(name) { this.name = name }
|
6
|
+
user = new User('joe')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should have a name'
|
10
|
+
user.should.have_property 'name'
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'Administrator'
|
14
|
+
should_behave_like('User')
|
15
|
+
|
16
|
+
before
|
17
|
+
Admin = function(name) { this.name = name }
|
18
|
+
Admin.prototype.may = function(perm){ return true }
|
19
|
+
user = new Admin('tj')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should have access to all permissions'
|
23
|
+
user.may('edit pages').should.be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'Super Administrator'
|
27
|
+
should_behave_like('Administrator')
|
28
|
+
|
29
|
+
before
|
30
|
+
SuperAdmin = function(name) { this.name = name }
|
31
|
+
SuperAdmin.prototype.may = function(perm){ return true }
|
32
|
+
user = new SuperAdmin('tj')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'findSuite'
|
39
|
+
it 'should find a suite by full description'
|
40
|
+
JSpec.findSuite('Shared Behaviors User Administrator').should.be_a JSpec.Suite
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should find a suite by name'
|
44
|
+
JSpec.findSuite('User').should.be_a JSpec.Suite
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should return null when not found'
|
48
|
+
JSpec.findSuite('Rawr').should.be_null
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/spec/spec.utils.js
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
|
2
|
+
describe 'Utility'
|
3
|
+
describe 'wait'
|
4
|
+
it 'should wait for n milliseconds'
|
5
|
+
wait(2000)
|
6
|
+
setTimeout(function(){
|
7
|
+
true.should.be true
|
8
|
+
}, 1500)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should wait for n seconds'
|
12
|
+
wait(3, 'seconds')
|
13
|
+
setTimeout(function(){
|
14
|
+
true.should.be true
|
15
|
+
}, 2500)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'query'
|
20
|
+
it 'should return a pairs value'
|
21
|
+
query('suite', '?suite=Positive%20specs').should.equal 'Positive specs'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should return null when key is not present'
|
25
|
+
query('foo', '?suite=Positive%20specs').should.be_null
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'strip'
|
30
|
+
it 'should strip whitespace by default'
|
31
|
+
strip(" foo \n\n").should.equal 'foo'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should strip the characters passed'
|
35
|
+
strip('[foo]', '\\[\\]').should.equal 'foo'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'each'
|
40
|
+
it 'should iterate an array'
|
41
|
+
result = []
|
42
|
+
each([1,2,3], function(value){
|
43
|
+
result.push(value)
|
44
|
+
})
|
45
|
+
result.should.eql [1,2,3]
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should iterate words in a string'
|
49
|
+
result = []
|
50
|
+
each('some foo bar', function(value){
|
51
|
+
result.push(value)
|
52
|
+
})
|
53
|
+
result.should.eql ['some', 'foo', 'bar']
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'map'
|
58
|
+
it 'should return an array of mapped values'
|
59
|
+
result = map([1,2,3], function(value){
|
60
|
+
return value * 2
|
61
|
+
})
|
62
|
+
result.should.eql [2,4,6]
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should inherit the ability to iterate words in a string'
|
66
|
+
result = map('some foo bar', function(i, value){
|
67
|
+
return i + '-' + value
|
68
|
+
})
|
69
|
+
result.should.eql ['0-some', '1-foo', '2-bar']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'inject'
|
74
|
+
it 'should provide a memo object while iterating, not expecting returning of memo for composits'
|
75
|
+
result = inject([1,2,3], [], function(memo, value){
|
76
|
+
memo.push(value)
|
77
|
+
})
|
78
|
+
result.should.eql [1,2,3]
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should require returning of memo for scalar variables'
|
82
|
+
result = inject([1,2,3], false, function(memo, value){
|
83
|
+
return memo ? memo : value == 2
|
84
|
+
})
|
85
|
+
result.should.be_true
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe 'any'
|
90
|
+
it 'should return null when no matches are found'
|
91
|
+
result = any('some foo bar', function(value){
|
92
|
+
return value.length > 5
|
93
|
+
})
|
94
|
+
result.should.be_null
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should return the value of the first matching expression'
|
98
|
+
result = any('foo some bar', function(value){
|
99
|
+
return value.length > 3
|
100
|
+
})
|
101
|
+
result.should.eql 'some'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'select'
|
106
|
+
it 'should return an array of values when the callback evaluates to true'
|
107
|
+
result = select('some foo bar baz stuff', function(value){
|
108
|
+
return value.length > 3
|
109
|
+
})
|
110
|
+
result.should.eql ['some', 'stuff']
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe 'last'
|
115
|
+
it 'should return the last element in an array'
|
116
|
+
last(['foo', 'bar']).should.eql 'bar'
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe 'argumentsToArray'
|
121
|
+
it 'should return an array of arguments'
|
122
|
+
func = function(){ return argumentsToArray(arguments) }
|
123
|
+
func('foo', 'bar').should.eql ['foo', 'bar']
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should return the offset of an arguments array'
|
127
|
+
func = function(){ return argumentsToArray(arguments, 2) }
|
128
|
+
func('foo', 'bar', 'baz').should.eql ['baz']
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe 'does'
|
133
|
+
it 'should assert without reporting'
|
134
|
+
does('foo', 'eql', 'foo')
|
135
|
+
JSpec.currentSpec.assertions.should.have_length 0
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visionmedia-jspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TJ Holowaychuk
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-27 00:00:00 -07:00
|
13
13
|
default_executable: jspec
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,6 +32,7 @@ extra_rdoc_files:
|
|
32
32
|
- bin/jspec
|
33
33
|
- lib/images/bg.png
|
34
34
|
- lib/images/hr.png
|
35
|
+
- lib/images/loading.gif
|
35
36
|
- lib/images/sprites.bg.png
|
36
37
|
- lib/images/sprites.png
|
37
38
|
- lib/images/vr.png
|
@@ -45,6 +46,7 @@ files:
|
|
45
46
|
- jspec.gemspec
|
46
47
|
- lib/images/bg.png
|
47
48
|
- lib/images/hr.png
|
49
|
+
- lib/images/loading.gif
|
48
50
|
- lib/images/sprites.bg.png
|
49
51
|
- lib/images/sprites.png
|
50
52
|
- lib/images/vr.png
|
@@ -59,12 +61,15 @@ files:
|
|
59
61
|
- spec/async
|
60
62
|
- spec/jquery-1.3.1.js
|
61
63
|
- spec/server.html
|
62
|
-
- spec/spec.
|
63
|
-
- spec/spec.core.js
|
64
|
+
- spec/spec.grammar-less.js
|
64
65
|
- spec/spec.grammar.js
|
65
66
|
- spec/spec.html
|
66
67
|
- spec/spec.jquery.js
|
68
|
+
- spec/spec.js
|
69
|
+
- spec/spec.matchers.js
|
67
70
|
- spec/spec.rhino.js
|
71
|
+
- spec/spec.shared-behaviors.js
|
72
|
+
- spec/spec.utils.js
|
68
73
|
- templates/default/History.rdoc
|
69
74
|
- templates/default/lib/yourlib.core.js
|
70
75
|
- templates/default/README.rdoc
|
data/spec/spec.core.dom.js
DELETED