oojspec 0.0.9 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +17 -1
- data/app/views/oojspec/iframe.html.erb +20 -0
- data/app/views/oojspec/runner.html.erb +5 -11
- data/lib/assets/javascripts/oojspec/iframe-runner.js.coffee +18 -0
- data/lib/assets/javascripts/oojspec/runner.js.coffee +30 -1
- data/lib/oojspec/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5095c2b9f5123ab0c683a7585bd33f32b9946fa8
|
4
|
+
data.tar.gz: b4dd0179a1f8bbf269a7c08e87160460a410e0cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 929c92a8a444716ff67357d63ee03642b0eaf7ce53fa9d4d1f5abb35c29bec1929396ba8b98eefc2776dc5b1d610809b12bcbb8bb15d2f70982c133824470036
|
7
|
+
data.tar.gz: 1b6257da1a39b80d4f8599384207ebad5ba5fe22dc63887430f073cd68290d2588a57d4d66acf5e663291295f3abd1f394817820fa4af414cd48b46e5671ce0d
|
data/README.md
CHANGED
@@ -88,7 +88,23 @@ context.
|
|
88
88
|
In contrast `oojspec` will only export `describe`. The other allowed features will be available
|
89
89
|
depending on the context. Inside a description `example`, `specify`, `it`, `xit`, `pending` and
|
90
90
|
`describe` will be available. Inside an example `expect`, `assert`, `waitsFor` and `runs` will be
|
91
|
-
available
|
91
|
+
available.
|
92
|
+
|
93
|
+
# Custom events
|
94
|
+
|
95
|
+
Oojspec supports custom events as well since v0.1.0 in case you want to notify and
|
96
|
+
listen to custom events:
|
97
|
+
|
98
|
+
```coffeescript
|
99
|
+
oojspec.on 'my-suite-start', (opts)-> console.log 'suite has started', opts
|
100
|
+
oojspec.on 'my-suite-end', -> console.log 'suite has ended'
|
101
|
+
oojspec.notify 'my-suite-start', option1: 1, option2: 'any'
|
102
|
+
oojspec.describe 'some description', -> @example 'it passes', -> @console.log 'suite is running'
|
103
|
+
oojspec.notify 'my-suite-end'
|
104
|
+
|
105
|
+
# this will log 'suite has started', {option1: 1, option2: 'any'},
|
106
|
+
'suite is running' and finally 'suite has ended'
|
107
|
+
```
|
92
108
|
|
93
109
|
# CoffeeScript?! Really?!
|
94
110
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
5
|
+
|
6
|
+
<title>OOJSpec Test Runner</title>
|
7
|
+
|
8
|
+
<%= javascript_include_tag "oojspec/iframe-runner" %>
|
9
|
+
<%= javascript_tag "oojspec.exposeAll()" unless Rails.configuration.sandbox_assets.options[:skip_oojspec_expose] %>
|
10
|
+
|
11
|
+
<% @stylesheets.each do |css| -%>
|
12
|
+
<%= stylesheet_link_tag css %>
|
13
|
+
<% end -%>
|
14
|
+
|
15
|
+
<%= javascript_include_tag @tests.first %>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -8,18 +8,12 @@
|
|
8
8
|
<%= stylesheet_link_tag "oojspec" %>
|
9
9
|
<%= javascript_include_tag "oojspec" %>
|
10
10
|
<%= javascript_tag "oojspec.exposeAll()" unless Rails.configuration.sandbox_assets.options[:skip_oojspec_expose] %>
|
11
|
-
|
12
|
-
<% @stylesheets.each do |css| -%>
|
13
|
-
<%= stylesheet_link_tag css %>
|
14
|
-
<% end -%>
|
15
|
-
|
16
|
-
<% @tests.each do |test| -%>
|
17
|
-
<%= javascript_include_tag test %>
|
18
|
-
<% end -%>
|
19
11
|
</head>
|
20
12
|
<body>
|
21
|
-
|
22
|
-
<%=
|
13
|
+
<% @tests.each do |test| -%>
|
14
|
+
<iframe src="<%= sandbox_assets_engine.sandbox_assets_iframe_path test %>"
|
15
|
+
onload="oojspec.onIFrameLoaded(this)" style="display: none"
|
16
|
+
width="100%" height="500px"></iframe>
|
17
|
+
<% end -%>
|
23
18
|
</body>
|
24
19
|
</html>
|
25
|
-
|
@@ -0,0 +1,18 @@
|
|
1
|
+
extend = (extended, extender)-> extended[p] = v for p, v of extender when p[0] isnt '_'
|
2
|
+
|
3
|
+
@oojspec or= new class IFrameOojspec
|
4
|
+
constructor: (@_oojspec = parent.oojspec)->
|
5
|
+
@_originalAssertions_ = @_oojspec.assertions
|
6
|
+
extend (@assertions = {}), @_originalAssertions_
|
7
|
+
@_deferredCalls_ = []
|
8
|
+
for m in ['describe', 'notify', 'on']
|
9
|
+
this[m] = do (m)=> => @_deferredCalls_.push [m, arguments]
|
10
|
+
|
11
|
+
run: ->
|
12
|
+
@_oojspec.on 'iframe-start', (w)=> @_oojspec.assertions = @assertions if w is window
|
13
|
+
@_oojspec.on 'iframe-end', (w)=> @_oojspec.assertions = @_originalAssertions_ if w is window
|
14
|
+
@_oojspec.notify 'iframe-start', window
|
15
|
+
@_oojspec[method] args... for [method, args] in @_deferredCalls_
|
16
|
+
@_oojspec.notify 'iframe-end', window
|
17
|
+
|
18
|
+
exposeAll: -> window.describe = @describe
|
@@ -14,6 +14,14 @@ _.extend oojspec, new class OojspecRunner
|
|
14
14
|
# avoid too much parameters between methods, acts like a context:
|
15
15
|
@params.events = @events
|
16
16
|
@params.assertions = @assertions
|
17
|
+
@_initializeIFrameSupport()
|
18
|
+
|
19
|
+
_initializeIFrameSupport: ->
|
20
|
+
@_iframesLoadedCount = 0
|
21
|
+
@_iframeByWindow = {}
|
22
|
+
@_iframeWindows = []
|
23
|
+
@on 'iframe-start', (w)=> @_iframeByWindow[w].style.display = ''
|
24
|
+
@on 'iframe-end', (w)=> @_iframeByWindow[w].style.display = 'none'
|
17
25
|
|
18
26
|
_registerEventHandlers: ->
|
19
27
|
@assertions = buster.assertions
|
@@ -40,10 +48,24 @@ _.extend oojspec, new class OojspecRunner
|
|
40
48
|
exposeAll: => window.describe = @describe
|
41
49
|
autorun: => @runSpecs() unless @disableAutorun
|
42
50
|
|
51
|
+
# for tests in iframe support:
|
52
|
+
onIFrameLoaded: (iframe)=>
|
53
|
+
@_iframeByWindow[iframe.contentWindow] = iframe
|
54
|
+
@_iframeWindows.push(iframe.contentWindow)
|
55
|
+
if ++@_iframesLoadedCount is document.getElementsByTagName('iframe').length
|
56
|
+
w.oojspec.run() for w in @_iframeWindows
|
57
|
+
@autorun()
|
58
|
+
|
59
|
+
notify: (eventName, options)->
|
60
|
+
@descriptions.push new Notification(@events, eventName, options)
|
61
|
+
|
62
|
+
on: (eventName, eventHandler)->
|
63
|
+
@events.on "notification:#{eventName}", eventHandler
|
64
|
+
|
43
65
|
runSpecs: =>
|
44
66
|
@reporter = buster.reporters.html.create detectCssPath: false
|
45
67
|
@reporter.listen @events
|
46
|
-
d.processDsl @params for d in @descriptions
|
68
|
+
d.processDsl? @params for d in @descriptions
|
47
69
|
@events.emit 'suite:start', name: "Specs"
|
48
70
|
@_runNextDescription()
|
49
71
|
|
@@ -55,6 +77,13 @@ _.extend oojspec, new class OojspecRunner
|
|
55
77
|
@stats.contexts++ # only root descriptions will be count
|
56
78
|
@descriptions.push new Description(description, block)
|
57
79
|
|
80
|
+
class Notification
|
81
|
+
constructor: (@events, @eventName, @options)->
|
82
|
+
|
83
|
+
run: (_, onFinish)->
|
84
|
+
@events.emit "notification:#{@eventName}", @options
|
85
|
+
onFinish()
|
86
|
+
|
58
87
|
RESERVED_FOR_DESCRIPTION_DSL = ['beforeAll', 'before', 'after', 'afterAll', 'describe', 'context',
|
59
88
|
'example', 'it', 'specify', 'pending', 'xit']
|
60
89
|
RESERVED_FOR_EXAMPLE_DSL = ['assert', 'expect', 'fail', 'refute', 'waitsFor', 'runs']
|
data/lib/oojspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oojspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Rosenfeld Rosas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coffee-rails
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.1.0
|
41
41
|
description: |2-
|
42
42
|
A test runner similar to RSpec for client-side code built
|
43
43
|
on top of Buster.js that is more suited for integration tests.
|
@@ -48,6 +48,8 @@ extensions: []
|
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
50
|
- app/views/oojspec/runner.html.erb
|
51
|
+
- app/views/oojspec/iframe.html.erb
|
52
|
+
- lib/assets/javascripts/oojspec/iframe-runner.js.coffee
|
51
53
|
- lib/assets/javascripts/oojspec/utils.js.coffee
|
52
54
|
- lib/assets/javascripts/oojspec/runner.js.coffee
|
53
55
|
- lib/assets/javascripts/oojspec/progress.js.coffee
|