opal-spec 0.2.17 → 0.3.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/Gemfile +3 -0
- data/lib/opal/spec/version.rb +1 -1
- data/opal-spec.gemspec +2 -2
- data/opal/opal/spec/browser_formatter.rb +91 -52
- data/opal/opal/spec/matchers.rb +2 -2
- data/opal/opal/spec/phantom_formatter.rb +8 -5
- data/opal/opal/spec/runner.rb +3 -2
- metadata +6 -7
- data/CHANGELOG.md +0 -52
data/Gemfile
CHANGED
data/lib/opal/spec/version.rb
CHANGED
data/opal-spec.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.files = `git ls-files`.split("\n")
|
14
14
|
s.require_paths = ['lib']
|
15
15
|
|
16
|
-
s.add_dependency 'opal', '~> 0.4.
|
17
|
-
s.add_dependency 'opal-sprockets', '~> 0.
|
16
|
+
s.add_dependency 'opal', '~> 0.4.4'
|
17
|
+
s.add_dependency 'opal-sprockets', '~> 0.2.0'
|
18
18
|
|
19
19
|
s.add_development_dependency 'rake'
|
20
20
|
end
|
@@ -50,38 +50,77 @@ module OpalSpec
|
|
50
50
|
}
|
51
51
|
CSS
|
52
52
|
|
53
|
+
class Node
|
54
|
+
|
55
|
+
attr_reader :element
|
56
|
+
|
57
|
+
def self.create(tag)
|
58
|
+
new(`document.createElement(tag)`)
|
59
|
+
end
|
60
|
+
|
61
|
+
def initialize(element)
|
62
|
+
@element = element
|
63
|
+
end
|
64
|
+
|
65
|
+
def class_name=(name)
|
66
|
+
`#{ @element }.className = name`
|
67
|
+
end
|
68
|
+
|
69
|
+
def html=(html)
|
70
|
+
`#{ @element }.innerHTML = html`
|
71
|
+
end
|
72
|
+
|
73
|
+
def type=(type)
|
74
|
+
`#{ @element }.type = type`
|
75
|
+
end
|
76
|
+
|
77
|
+
def append(child)
|
78
|
+
`#{ @element }.appendChild(#{ child.element })`
|
79
|
+
end
|
80
|
+
|
81
|
+
def css_text=(text)
|
82
|
+
%x{
|
83
|
+
if (#{ @element }.styleSheet) {
|
84
|
+
#{ @element }.styleSheet.cssText = text;
|
85
|
+
}
|
86
|
+
else {
|
87
|
+
#{ @element }.appendChild(document.createTextNode(text));
|
88
|
+
}
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
def style(name, value)
|
93
|
+
`#{@element}.style[name] = value`
|
94
|
+
end
|
95
|
+
|
96
|
+
def append_to_head
|
97
|
+
`document.getElementsByTagName('head')[0].appendChild(#{@element})`
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
53
101
|
def initialize
|
54
102
|
@examples = []
|
55
103
|
@failed_examples = []
|
56
104
|
end
|
57
105
|
|
58
106
|
def start
|
59
|
-
raise "Not running in browser" unless
|
107
|
+
raise "Not running in browser" unless Runner.in_browser?
|
60
108
|
|
61
|
-
@summary_element =
|
62
|
-
@summary_element.
|
63
|
-
@summary_element.
|
109
|
+
@summary_element = Node.create 'p'
|
110
|
+
@summary_element.class_name = "summary"
|
111
|
+
@summary_element.html = "Runner..."
|
64
112
|
|
65
|
-
@groups_element =
|
66
|
-
@groups_element.
|
113
|
+
@groups_element = Node.create("ul")
|
114
|
+
@groups_element.class_name = "example_groups"
|
67
115
|
|
68
|
-
|
116
|
+
target = Node.new(`document.body`)
|
117
|
+
target.append @summary_element
|
118
|
+
target.append @groups_element
|
69
119
|
|
70
|
-
|
71
|
-
|
72
|
-
target.appendChild @summary_element
|
73
|
-
target.appendChild @groups_element
|
74
|
-
|
75
|
-
styles = $global.document.createElement 'style'
|
120
|
+
styles = Node.create "style"
|
76
121
|
styles.type = "text/css"
|
77
|
-
|
78
|
-
|
79
|
-
styles.styleSheet.cssText = CSS
|
80
|
-
else
|
81
|
-
styles.appendChild $global.document.createTextNode CSS
|
82
|
-
end
|
83
|
-
|
84
|
-
$global.document.getElementsByTagName('head')[0].appendChild styles
|
122
|
+
styles.css_text = CSS
|
123
|
+
styles.append_to_head
|
85
124
|
|
86
125
|
@start_time = Time.now.to_f
|
87
126
|
end
|
@@ -90,32 +129,32 @@ module OpalSpec
|
|
90
129
|
time = Time.now.to_f - @start_time
|
91
130
|
text = "\n#{example_count} examples, #{@failed_examples.size} failures (time taken: #{time})"
|
92
131
|
|
93
|
-
@summary_element.
|
132
|
+
@summary_element.html = text
|
94
133
|
end
|
95
134
|
|
96
135
|
def example_group_started group
|
97
136
|
@example_group = group
|
98
137
|
@example_group_failed = false
|
99
138
|
|
100
|
-
@group_element =
|
139
|
+
@group_element = Node.create("li")
|
101
140
|
|
102
|
-
description =
|
103
|
-
description.
|
104
|
-
description.
|
105
|
-
@group_element.
|
141
|
+
description = Node.create("span")
|
142
|
+
description.class_name = "group_description"
|
143
|
+
description.html = group.description.to_s
|
144
|
+
@group_element.append description
|
106
145
|
|
107
|
-
@example_list =
|
108
|
-
@example_list.
|
109
|
-
@group_element.
|
146
|
+
@example_list = Node.create "ul"
|
147
|
+
@example_list.class_name = "examples"
|
148
|
+
@group_element.append @example_list
|
110
149
|
|
111
|
-
@groups_element.
|
150
|
+
@groups_element.append @group_element
|
112
151
|
end
|
113
152
|
|
114
153
|
def example_group_finished group
|
115
154
|
if @example_group_failed
|
116
|
-
@group_element.
|
155
|
+
@group_element.class_name = "group failed"
|
117
156
|
else
|
118
|
-
@group_element.
|
157
|
+
@group_element.class_name = "group passed"
|
119
158
|
end
|
120
159
|
end
|
121
160
|
|
@@ -138,34 +177,34 @@ module OpalSpec
|
|
138
177
|
output += " #{exception.backtrace.join "\n "}\n"
|
139
178
|
end
|
140
179
|
|
141
|
-
wrapper =
|
142
|
-
wrapper.
|
180
|
+
wrapper = Node.create "li"
|
181
|
+
wrapper.class_name = "example failed"
|
143
182
|
|
144
|
-
description =
|
145
|
-
description.
|
146
|
-
description.
|
183
|
+
description = Node.create "span"
|
184
|
+
description.class_name = "example_description"
|
185
|
+
description.html = example.description.to_s
|
147
186
|
|
148
|
-
exception =
|
149
|
-
exception.
|
150
|
-
exception.
|
187
|
+
exception = Node.create "pre"
|
188
|
+
exception.class_name = "exception"
|
189
|
+
exception.html = output
|
151
190
|
|
152
|
-
wrapper.
|
153
|
-
wrapper.
|
191
|
+
wrapper.append description
|
192
|
+
wrapper.append exception
|
154
193
|
|
155
|
-
@example_list.
|
156
|
-
@example_list.style
|
194
|
+
@example_list.append wrapper
|
195
|
+
@example_list.style :display, "list-item"
|
157
196
|
end
|
158
197
|
|
159
198
|
def example_passed example
|
160
|
-
wrapper =
|
161
|
-
wrapper.
|
199
|
+
wrapper = Node.create "li"
|
200
|
+
wrapper.class_name = "example passed"
|
162
201
|
|
163
|
-
description =
|
164
|
-
description.
|
165
|
-
description.
|
202
|
+
description = Node.create "span"
|
203
|
+
description.class_name = "example_description"
|
204
|
+
description.html = example.description.to_s
|
166
205
|
|
167
|
-
wrapper.
|
168
|
-
@example_list.
|
206
|
+
wrapper.append description
|
207
|
+
@example_list.append wrapper
|
169
208
|
end
|
170
209
|
|
171
210
|
def example_count
|
data/opal/opal/spec/matchers.rb
CHANGED
@@ -41,7 +41,7 @@ module OpalSpec
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def failure_message_for_should
|
44
|
-
"expected #{
|
44
|
+
"expected #{actual.inspect}, but got: #{expected.inspect} (using ==)."
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -55,7 +55,7 @@ module OpalSpec
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def failure_message_for_should_not
|
58
|
-
"expected #{
|
58
|
+
"expected #{actual.inspect} not to be: #{expected.inspect} (using ==)."
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
@@ -50,11 +50,14 @@ module OpalSpec
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def finish_with_code(code)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
%x{
|
54
|
+
if (typeof(phantom) !== "undefined") {
|
55
|
+
phantom.exit(code);
|
56
|
+
}
|
57
|
+
else {
|
58
|
+
Opal.global.OPAL_SPEC_CODE = code;
|
59
|
+
}
|
60
|
+
}
|
58
61
|
end
|
59
62
|
|
60
63
|
def example_group_started group
|
data/opal/opal/spec/runner.rb
CHANGED
@@ -2,15 +2,16 @@ module OpalSpec
|
|
2
2
|
class Runner
|
3
3
|
def self.in_browser?
|
4
4
|
$global[:document]
|
5
|
+
`typeof(document) !== 'undefined'`
|
5
6
|
end
|
6
7
|
|
7
8
|
def self.in_phantom?
|
8
|
-
|
9
|
+
`typeof(phantom) !== 'undefined' || typeof(OPAL_SPEC_PHANTOM) !== 'undefined'`
|
9
10
|
end
|
10
11
|
|
11
12
|
def self.autorun
|
12
13
|
if in_browser?
|
13
|
-
|
14
|
+
`setTimeout(function() { #{ Runner.new.run } }, 0)`
|
14
15
|
else
|
15
16
|
Runner.new.run
|
16
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: opal
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.4.
|
21
|
+
version: 0.4.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.4.
|
29
|
+
version: 0.4.4
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: opal-sprockets
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.
|
37
|
+
version: 0.2.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
45
|
+
version: 0.2.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rake
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,6 @@ extensions: []
|
|
66
66
|
extra_rdoc_files: []
|
67
67
|
files:
|
68
68
|
- .gitignore
|
69
|
-
- CHANGELOG.md
|
70
69
|
- Gemfile
|
71
70
|
- README.md
|
72
71
|
- Rakefile
|
data/CHANGELOG.md
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
## 0.2.17 2013-06-16
|
2
|
-
|
3
|
-
* Use opal-sprockets as server for specs.
|
4
|
-
|
5
|
-
## 0.2.16 2013-06-09
|
6
|
-
|
7
|
-
* Define matchers using OpalSpec.matcher() method.
|
8
|
-
|
9
|
-
* Remove old TestCase code, and more to pure spec based testing.
|
10
|
-
|
11
|
-
## 0.2.15 2013-05-2
|
12
|
-
|
13
|
-
* Remove opal-sprockets dependency and use opal directly for sprockets
|
14
|
-
support.
|
15
|
-
|
16
|
-
## 0.2.13 2013-02-23
|
17
|
-
|
18
|
-
* Re-write Opal::Spec::Server to inherit from Opal::Server. Opal::Server is
|
19
|
-
a standard rack-app which configures Opal and load paths in a more
|
20
|
-
consistent manner.
|
21
|
-
|
22
|
-
* Add respond_to and be_empty matchers for Spec.
|
23
|
-
|
24
|
-
* Added Spec::Pending as a standard way to mark specs as not compliant or
|
25
|
-
working. Pending specs are simply ignored when running.
|
26
|
-
|
27
|
-
## 0.2.11 2013-02-20
|
28
|
-
|
29
|
-
* Added TestCase class to allow unit tests. OpalTest::Spec now inherits from
|
30
|
-
OpalTest::TestCase.
|
31
|
-
|
32
|
-
* Added Spec#let and Spec#subject.
|
33
|
-
|
34
|
-
## 0.2.7
|
35
|
-
|
36
|
-
* Can be built using asset pipeline/sprockets.
|
37
|
-
* BrowserFormatter is now default.
|
38
|
-
|
39
|
-
## 0.0.3
|
40
|
-
|
41
|
-
* Allow group names to be non-strings.
|
42
|
-
* Nested groups now have outer group name as prefix.
|
43
|
-
* Nested groups should inherit `before` and `after` blocks.
|
44
|
-
|
45
|
-
## 0.0.2
|
46
|
-
|
47
|
-
* Added seperate BrowserFormatter class for cleaner output.
|
48
|
-
* Update Rake tasks to use new Opal::Builder class.
|
49
|
-
|
50
|
-
## 0.0.1
|
51
|
-
|
52
|
-
* Initial Release.
|