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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbf962b33837327895dd28ab8b61a3c59d34798d
4
- data.tar.gz: 2b9a33708f6a1eb270588daf007e551f7da60125
3
+ metadata.gz: d5bd79540d6e74c4df7d716c4ca5b8f03cde5a6e
4
+ data.tar.gz: 723db13931f42a37a78ae3c2aecef9ef6eb17df2
5
5
  SHA512:
6
- metadata.gz: b8f78171304bf87f6eb090e75a9aa3d094951e8e1fabd030fb391188fc1b44f8eace7c479322f392672091f0de63262e433a958cdbf48aab9ef6ece5c58fc5b6
7
- data.tar.gz: ab4c3e4c9934741c1905f7a2dbfc9f2fe76d0945246eb92b48aebe0a51d6a67d0e2d3cbb3331ebdcd529ba1c08d0e054a64f6f3bb3457797ccd31cd09986bf21
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
@@ -1,8 +1,6 @@
1
1
  require 'bundler'
2
2
  Bundler.require
3
3
 
4
- require 'opal-sprockets'
5
-
6
4
  Opal::Processor.source_map_enabled = false
7
5
 
8
6
  run Opal::Server.new { |s|
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  module RSpec
3
- VERSION = '0.3.0.beta1'
3
+ VERSION = '0.3.0.beta2'
4
4
  end
5
5
  end
data/opal-rspec.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.require_paths = ['lib']
17
17
 
18
- s.add_dependency 'opal', '~> 0.6.0'
18
+ s.add_dependency 'opal', ['>= 0.6.0', '< 1.0.0']
19
19
 
20
20
  s.add_development_dependency 'rake'
21
21
  end
@@ -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 << @summary_element
13
- target << @groups_element
13
+ target << Element.new(:div, html: REPORT_TEMPLATE)
14
+ @rspec_results = Element.id('rspec-results')
14
15
 
15
- styles = Element.new(:style, type: 'text/css', css_text: CSS_STYLES)
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
- @group_element = Element.new(:li, class_name: 'group passed')
25
+ parents = example_group.parent_groups.size
24
26
 
25
- description = Element.new(:span, class_name: 'group_description', text: example_group.description)
26
- @group_element << description
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
- @example_list = Element.new(:ul, class_name: 'examples')
29
- @group_element << @example_list
33
+ @rspec_dl.style 'margin-left', "#{(parents - 2) * 15}px"
30
34
 
31
- @groups_element << @group_element
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
- @group_element.class_name = 'group failed'
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
- wrapper = Element.new(:li, class_name: 'example failed')
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
- @example_list << wrapper
61
- @example_list.style :display, 'list-item'
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
- wrapper = Element.new(:li, class_name: 'example passed')
68
- description = Element.new(:span, class_name: 'example_description', text: example.description)
69
-
70
- wrapper << description
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
- summary = "\n#{example_count} examples, #{failure_count} failures (time taken: #{duration})"
78
- @summary_element.text = summary
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
- CSS_STYLES = <<-EOF
145
- body {
146
- font-size: 14px;
147
- font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
148
- }
149
-
150
- pre {
151
- font-family: "Bitstream Vera Sans Mono", Monaco, "Lucida Console", monospace;
152
- font-size: 12px;
153
- color: #444444;
154
- white-space: pre;
155
- padding: 3px 0px 3px 12px;
156
- margin: 0px 0px 8px;
157
-
158
- background: #FAFAFA;
159
- -webkit-box-shadow: rgba(0,0,0,0.07) 0 1px 2px inset;
160
- -webkit-border-radius: 3px;
161
- -moz-border-radius: 3px;
162
- border-radius: 3px;
163
- border: 1px solid #DDDDDD;
164
- }
165
-
166
- ul.example_groups {
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">&#160;</p>
178
+ <p id="duration">&#160;</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('\\033[32m' + str + '\\033[0m')`
58
+ `console.log('\033[32m' + str + '\033[0m')`
59
59
  end
60
60
 
61
61
  def red(str)
62
- `console.log('\\033[31m' + str + '\\033[0m')`
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.beta1
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-01 00:00:00.000000000 Z
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.0.3
103
+ rubygems_version: 2.1.9
97
104
  signing_key:
98
105
  specification_version: 4
99
106
  summary: RSpec for Opal