opal-rspec 0.3.0.beta1 → 0.3.0.beta2
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/CHANGELOG.md +11 -0
- data/app/rspec-builder.rb +1 -0
- data/config.ru +0 -2
- data/lib/opal/rspec/version.rb +1 -1
- data/opal-rspec.gemspec +1 -1
- data/opal/opal/rspec/browser_formatter.rb +73 -79
- data/opal/opal/rspec/text_formatter.rb +2 -2
- metadata +12 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5bd79540d6e74c4df7d716c4ca5b8f03cde5a6e
|
4
|
+
data.tar.gz: 723db13931f42a37a78ae3c2aecef9ef6eb17df2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4072ac6a74fe502ca4c83b828934c5f88216d83ede42a03adf3e7cfad083ead45b8f624cb38671cc82912136746a6f8fbdf2475221aaa75d76276b0169ed3b12
|
7
|
+
data.tar.gz: 8256bba226056877123b8a50439d8eca2eeed995b4ba9b8eed3f34954a2bee31f544b9c86bd4ec79af1ca0ed76cdad96e41c5d5adc2f15d2c754ff98dbe2bdc9
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
## edge
|
2
|
+
|
3
|
+
* Update Opal dependency for ~> 0.6.0.
|
4
|
+
|
5
|
+
* Remove double-escaping in inline x-strings (from Opal bug fix).
|
6
|
+
|
7
|
+
* Remove opal-sprockets dependency - build tools now part of opal.
|
8
|
+
|
9
|
+
* Replaced browser formatter to use html printer from rspec
|
10
|
+
|
11
|
+
## 0.2.1 2013-11-24
|
data/app/rspec-builder.rb
CHANGED
@@ -38,6 +38,7 @@ require 'rspec/mocks'
|
|
38
38
|
|
39
39
|
# we want access to BaseFormatter
|
40
40
|
require 'rspec/core/formatters/base_formatter'
|
41
|
+
require 'rspec/core/formatters/html_printer'
|
41
42
|
|
42
43
|
# For now, we don't support mocking. This placeholder in rspec-core allows that.
|
43
44
|
require 'rspec/core/mocking/with_rspec'
|
data/config.ru
CHANGED
data/lib/opal/rspec/version.rb
CHANGED
data/opal-rspec.gemspec
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
1
3
|
module Opal
|
2
4
|
module RSpec
|
3
5
|
class BrowserFormatter < ::RSpec::Core::Formatters::BaseFormatter
|
6
|
+
include ERB::Util
|
7
|
+
|
8
|
+
CSS_STYLES = ::RSpec::Core::Formatters::HtmlPrinter::GLOBAL_STYLES
|
4
9
|
|
5
10
|
def start(example_count)
|
6
11
|
super
|
7
|
-
|
8
|
-
@summary_element = Element.new(:p, class_name: 'summary', text: 'Runner...')
|
9
|
-
@groups_element = Element.new(:ul, class_name: 'example_groups')
|
10
|
-
|
11
12
|
target = Element.new(`document.body`)
|
12
|
-
target <<
|
13
|
-
|
13
|
+
target << Element.new(:div, html: REPORT_TEMPLATE)
|
14
|
+
@rspec_results = Element.id('rspec-results')
|
14
15
|
|
15
|
-
|
16
|
+
css_text = CSS_STYLES + "\n body { padding: 0; margin: 0 }"
|
17
|
+
styles = Element.new(:style, type: 'text/css', css_text: css_text)
|
16
18
|
styles.append_to_head
|
17
19
|
end
|
18
20
|
|
@@ -20,62 +22,74 @@ module Opal
|
|
20
22
|
super
|
21
23
|
|
22
24
|
@example_group_failed = false
|
23
|
-
|
25
|
+
parents = example_group.parent_groups.size
|
24
26
|
|
25
|
-
|
26
|
-
@
|
27
|
+
@rspec_group = Element.new(:div, class_name: "example_group passed")
|
28
|
+
@rspec_dl = Element.new(:dl)
|
29
|
+
@rspec_dt = Element.new(:dt, class_name: "passed", text: example_group.description)
|
30
|
+
@rspec_group << @rspec_dl
|
31
|
+
@rspec_dl << @rspec_dt
|
27
32
|
|
28
|
-
@
|
29
|
-
@group_element << @example_list
|
33
|
+
@rspec_dl.style 'margin-left', "#{(parents - 2) * 15}px"
|
30
34
|
|
31
|
-
@
|
35
|
+
@rspec_results << @rspec_group
|
32
36
|
end
|
33
37
|
|
34
38
|
def example_group_finished(example_group)
|
35
39
|
super
|
36
40
|
|
37
41
|
if @example_group_failed
|
38
|
-
@
|
42
|
+
@rspec_group.class_name = "example_group failed"
|
43
|
+
@rspec_dt.class_name = "failed"
|
44
|
+
Element.id('rspec-header').class_name = 'failed'
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
42
48
|
def example_failed(example)
|
43
49
|
super
|
44
|
-
|
45
|
-
@example_group_failed = true
|
50
|
+
duration = sprintf("%0.5f", example.execution_result[:run_time])
|
46
51
|
|
47
52
|
error = example.execution_result[:exception]
|
48
53
|
error_name = error.class.name.to_s
|
49
54
|
output = "#{short_padding}#{error_name}:\n"
|
50
55
|
error.message.to_s.split("\n").each { |line| output += "#{long_padding} #{line}\n" }
|
51
56
|
|
52
|
-
|
53
|
-
|
54
|
-
description = Element.new(:span, class_name: 'example_description', text: example.description)
|
55
|
-
wrapper << description
|
56
|
-
|
57
|
-
exception = Element.new(:pre, class_name: 'exception', text: output)
|
58
|
-
wrapper << exception
|
57
|
+
@example_group_failed = true
|
59
58
|
|
60
|
-
@
|
61
|
-
|
59
|
+
@rspec_dl << Element.new(:dd, class_name: "example failed", html: <<-HTML)
|
60
|
+
<span class="failed_spec_name">#{h example.description}</span>
|
61
|
+
<span class="duration">#{duration}s</span>
|
62
|
+
<div class="failure">
|
63
|
+
<div class="message"><pre>#{h output}</pre></div>
|
64
|
+
</div>
|
65
|
+
HTML
|
62
66
|
end
|
63
67
|
|
64
68
|
def example_passed(example)
|
65
69
|
super
|
70
|
+
duration = sprintf("%0.5f", example.execution_result[:run_time])
|
66
71
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
@example_list << wrapper
|
72
|
+
@rspec_dl << Element.new(:dd, class_name: "example passed", html: <<-HTML)
|
73
|
+
<span class="passed_spec_name">#{h example.description}</span>
|
74
|
+
<span class="duration">#{duration}s</span>
|
75
|
+
HTML
|
72
76
|
end
|
73
77
|
|
74
78
|
def dump_summary(duration, example_count, failure_count, pending_count)
|
75
79
|
super
|
76
80
|
|
77
|
-
|
78
|
-
|
81
|
+
totals = "#{example_count} examples, #{failure_count} failures"
|
82
|
+
Element.id('totals').html = totals
|
83
|
+
|
84
|
+
duration = "Finished in <strong>#{sprintf("%.5f", duration)} seconds</strong>"
|
85
|
+
Element.id('duration').html = duration
|
86
|
+
|
87
|
+
add_scripts
|
88
|
+
end
|
89
|
+
|
90
|
+
def add_scripts
|
91
|
+
content = ::RSpec::Core::Formatters::HtmlPrinter::GLOBAL_SCRIPTS
|
92
|
+
`window.eval(#{content})`
|
79
93
|
end
|
80
94
|
|
81
95
|
def short_padding
|
@@ -89,6 +103,10 @@ module Opal
|
|
89
103
|
class Element
|
90
104
|
attr_reader :native
|
91
105
|
|
106
|
+
def self.id(id)
|
107
|
+
new(`document.getElementById(id)`)
|
108
|
+
end
|
109
|
+
|
92
110
|
def initialize(el, attrs={})
|
93
111
|
if String === el
|
94
112
|
@native = `document.createElement(el)`
|
@@ -141,53 +159,29 @@ module Opal
|
|
141
159
|
end
|
142
160
|
end
|
143
161
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
list-style-type: none;
|
168
|
-
}
|
169
|
-
|
170
|
-
li.group.passed .group_description {
|
171
|
-
color: #597800;
|
172
|
-
font-weight: bold;
|
173
|
-
}
|
174
|
-
|
175
|
-
li.group.failed .group_description {
|
176
|
-
color: #FF000E;
|
177
|
-
font-weight: bold;
|
178
|
-
}
|
179
|
-
|
180
|
-
li.example.passed {
|
181
|
-
color: #597800;
|
182
|
-
}
|
183
|
-
|
184
|
-
li.example.failed {
|
185
|
-
color: #FF000E;
|
186
|
-
}
|
187
|
-
|
188
|
-
.examples {
|
189
|
-
list-style-type: none;
|
190
|
-
}
|
162
|
+
REPORT_TEMPLATE = <<-EOF
|
163
|
+
<div class="rspec-report">
|
164
|
+
|
165
|
+
<div id="rspec-header">
|
166
|
+
<div id="label">
|
167
|
+
<h1>RSpec Code Examples</h1>
|
168
|
+
</div>
|
169
|
+
|
170
|
+
<div id="display-filters">
|
171
|
+
<input id="passed_checkbox" name="passed_checkbox" type="checkbox" checked="checked" onchange="apply_filters()" value="1" /> <label for="passed_checkbox">Passed</label>
|
172
|
+
<input id="failed_checkbox" name="failed_checkbox" type="checkbox" checked="checked" onchange="apply_filters()" value="2" /> <label for="failed_checkbox">Failed</label>
|
173
|
+
<input id="pending_checkbox" name="pending_checkbox" type="checkbox" checked="checked" onchange="apply_filters()" value="3" /> <label for="pending_checkbox">Pending</label>
|
174
|
+
</div>
|
175
|
+
|
176
|
+
<div id="summary">
|
177
|
+
<p id="totals"> </p>
|
178
|
+
<p id="duration"> </p>
|
179
|
+
</div>
|
180
|
+
</div>
|
181
|
+
|
182
|
+
<div id="rspec-results" class="results">
|
183
|
+
</div>
|
184
|
+
</div>
|
191
185
|
EOF
|
192
186
|
end
|
193
187
|
end
|
@@ -55,11 +55,11 @@ module Opal
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def green(str)
|
58
|
-
`console.log('
|
58
|
+
`console.log('\033[32m' + str + '\033[0m')`
|
59
59
|
end
|
60
60
|
|
61
61
|
def red(str)
|
62
|
-
`console.log('
|
62
|
+
`console.log('\033[31m' + str + '\033[0m')`
|
63
63
|
end
|
64
64
|
|
65
65
|
def short_padding
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.0.
|
4
|
+
version: 0.3.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Beynon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.6.0
|
20
|
+
- - <
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 0.6.0
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rake
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,6 +51,7 @@ extensions: []
|
|
45
51
|
extra_rdoc_files: []
|
46
52
|
files:
|
47
53
|
- .gitignore
|
54
|
+
- CHANGELOG.md
|
48
55
|
- Gemfile
|
49
56
|
- README.md
|
50
57
|
- Rakefile
|
@@ -93,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
100
|
version: 1.3.1
|
94
101
|
requirements: []
|
95
102
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
103
|
+
rubygems_version: 2.1.9
|
97
104
|
signing_key:
|
98
105
|
specification_version: 4
|
99
106
|
summary: RSpec for Opal
|