opal-spec 0.1.6 → 0.1.7
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/Rakefile +1 -5
- data/lib/opal/spec/autorun.rb +3 -0
- data/lib/{opal-spec → opal/spec}/browser_formatter.rb +34 -43
- data/lib/{opal-spec → opal/spec}/example.rb +1 -1
- data/lib/{opal-spec → opal/spec}/example_group.rb +1 -1
- data/lib/{opal-spec → opal/spec}/expectations.rb +10 -10
- data/lib/{opal-spec → opal/spec}/kernel.rb +2 -2
- data/lib/{opal-spec → opal/spec}/matchers.rb +2 -2
- data/lib/{opal-spec → opal/spec}/runner.rb +1 -1
- data/lib/{opal-spec → opal/spec}/scratch_pad.rb +0 -0
- data/lib/opal/spec/version.rb +3 -0
- data/lib/opal/spec.rb +9 -0
- data/opal-spec.gemspec +4 -4
- metadata +15 -16
- data/lib/opal-spec/autorun.rb +0 -21
- data/lib/opal-spec/dom.rb +0 -52
- data/lib/opal-spec/version.rb +0 -3
- data/lib/opal-spec.rb +0 -10
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Spec
|
2
2
|
class BrowserFormatter
|
3
3
|
CSS = <<-EOS
|
4
4
|
|
@@ -56,21 +56,15 @@ module OpalSpec
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def start
|
59
|
-
unless
|
60
|
-
raise "Not running in browser"
|
61
|
-
end
|
59
|
+
raise "Not running in browser" unless Document.body_ready?
|
62
60
|
|
63
|
-
@summary_element =
|
64
|
-
@summary_element.class_name = 'summary'
|
61
|
+
@summary_element = DOM.parse '<p class="summary"></p>'
|
65
62
|
@summary_element.append_to_body
|
66
63
|
|
67
|
-
@groups_element =
|
68
|
-
@groups_element.class_name = 'example_groups'
|
64
|
+
@groups_element = DOM.parse '<ul class="example_groups"></ul>'
|
69
65
|
@groups_element.append_to_body
|
70
66
|
|
71
|
-
|
72
|
-
styles.html = CSS
|
73
|
-
styles.append_to_head
|
67
|
+
DOM.parse("<style>#{ CSS }</style>").append_to_head
|
74
68
|
end
|
75
69
|
|
76
70
|
def finish
|
@@ -82,20 +76,20 @@ module OpalSpec
|
|
82
76
|
@example_group = group
|
83
77
|
@example_group_failed = false
|
84
78
|
|
85
|
-
@group_element =
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
79
|
+
@group_element = DOM.parse <<-HTML
|
80
|
+
<li>
|
81
|
+
<span class="group_description">
|
82
|
+
#{ group.description }
|
83
|
+
</span>
|
84
|
+
</li>
|
85
|
+
HTML
|
92
86
|
|
93
|
-
@example_list
|
94
|
-
|
95
|
-
|
87
|
+
@example_list = DOM.parse <<-HTML
|
88
|
+
<ul class="examples" style="display:none;"></ul>
|
89
|
+
HTML
|
96
90
|
|
97
|
-
@group_element
|
98
|
-
@groups_element
|
91
|
+
@group_element << @example_list
|
92
|
+
@groups_element << @group_element
|
99
93
|
end
|
100
94
|
|
101
95
|
def example_group_finished group
|
@@ -118,41 +112,38 @@ module OpalSpec
|
|
118
112
|
exception = example.exception
|
119
113
|
|
120
114
|
case exception
|
121
|
-
when
|
115
|
+
when Spec::ExpectationNotMetError
|
122
116
|
output = exception.message
|
123
117
|
else
|
124
118
|
output = "#{exception.class}: #{exception.message}\n"
|
125
119
|
output += " #{exception.backtrace.join "\n "}\n"
|
126
120
|
end
|
127
121
|
|
128
|
-
wrapper =
|
129
|
-
wrapper.class_name = 'example failed'
|
122
|
+
wrapper = DOM.parse '<li class="example failed"></li>'
|
130
123
|
|
131
|
-
description =
|
132
|
-
|
133
|
-
|
124
|
+
description = DOM.parse <<-HTML
|
125
|
+
<span class="example_description">#{ example.description }</span>
|
126
|
+
HTML
|
134
127
|
|
135
|
-
exception =
|
136
|
-
|
137
|
-
|
128
|
+
exception = DOM.parse <<-HTML
|
129
|
+
<pre class="exception">#{ output }</pre>
|
130
|
+
HTML
|
138
131
|
|
139
|
-
wrapper
|
140
|
-
wrapper
|
132
|
+
wrapper << description
|
133
|
+
wrapper << exception
|
141
134
|
|
142
135
|
@example_list.append wrapper
|
143
|
-
@example_list.
|
136
|
+
@example_list.css 'display', 'list-item'
|
144
137
|
end
|
145
138
|
|
146
139
|
def example_passed example
|
147
|
-
|
148
|
-
|
140
|
+
out = DOM.parse <<-HTML
|
141
|
+
<li class="example passed">
|
142
|
+
<span class="example_description">#{ example.description }</span>
|
143
|
+
</li>
|
144
|
+
HTML
|
149
145
|
|
150
|
-
|
151
|
-
description.class_name = 'example_description'
|
152
|
-
description.html = example.description
|
153
|
-
|
154
|
-
wrapper.append description
|
155
|
-
@example_list.append wrapper
|
146
|
+
@example_list.append out
|
156
147
|
end
|
157
148
|
|
158
149
|
def example_count
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Spec
|
2
2
|
class ExpectationNotMetError < StandardError; end
|
3
3
|
|
4
4
|
module Expectations
|
@@ -6,7 +6,7 @@ module OpalSpec
|
|
6
6
|
if matcher
|
7
7
|
matcher.match self
|
8
8
|
else
|
9
|
-
|
9
|
+
Spec::PositiveOperatorMatcher.new self
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -14,36 +14,36 @@ module OpalSpec
|
|
14
14
|
if matcher
|
15
15
|
matcher.not_match self
|
16
16
|
else
|
17
|
-
|
17
|
+
Spec::NegativeOperatorMatcher.new self
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
def be_kind_of expected
|
22
|
-
|
22
|
+
Spec::BeKindOfMatcher.new expected
|
23
23
|
end
|
24
24
|
|
25
25
|
def be_nil
|
26
|
-
|
26
|
+
Spec::BeNilMatcher.new nil
|
27
27
|
end
|
28
28
|
|
29
29
|
def be_true
|
30
|
-
|
30
|
+
Spec::BeTrueMatcher.new true
|
31
31
|
end
|
32
32
|
|
33
33
|
def be_false
|
34
|
-
|
34
|
+
Spec::BeFalseMatcher.new false
|
35
35
|
end
|
36
36
|
|
37
37
|
def equal expected
|
38
|
-
|
38
|
+
Spec::EqualMatcher.new expected
|
39
39
|
end
|
40
40
|
|
41
41
|
def raise_error expected
|
42
|
-
|
42
|
+
Spec::RaiseErrorMatcher.new expected
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
class Object
|
48
|
-
include
|
48
|
+
include Spec::Expectations
|
49
49
|
end
|
File without changes
|
data/lib/opal/spec.rb
ADDED
data/opal-spec.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/opal
|
2
|
+
require File.expand_path('../lib/opal/spec/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'opal-spec'
|
6
|
-
s.version =
|
6
|
+
s.version = Spec::VERSION
|
7
7
|
s.author = 'Adam Beynon'
|
8
8
|
s.email = 'adam@adambeynon.com'
|
9
9
|
s.homepage = 'http://opalrb.org'
|
10
10
|
s.summary = 'Opal compatible spec'
|
11
|
-
s.description = 'Opal compatible spec'
|
11
|
+
s.description = 'Opal compatible spec library'
|
12
12
|
|
13
13
|
s.files = `git ls-files`.split("\n")
|
14
14
|
s.require_paths = ['lib']
|
15
|
-
end
|
15
|
+
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.1.
|
4
|
+
version: 0.1.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,9 +9,9 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: Opal compatible spec
|
14
|
+
description: Opal compatible spec library
|
15
15
|
email: adam@adambeynon.com
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
@@ -28,18 +28,17 @@ files:
|
|
28
28
|
- example/nested.rb
|
29
29
|
- example/runner.html
|
30
30
|
- example/spec_helper.rb
|
31
|
-
- lib/opal
|
32
|
-
- lib/opal
|
33
|
-
- lib/opal
|
34
|
-
- lib/opal
|
35
|
-
- lib/opal
|
36
|
-
- lib/opal
|
37
|
-
- lib/opal
|
38
|
-
- lib/opal
|
39
|
-
- lib/opal
|
40
|
-
- lib/opal
|
41
|
-
- lib/opal
|
42
|
-
- lib/opal-spec/version.rb
|
31
|
+
- lib/opal/spec.rb
|
32
|
+
- lib/opal/spec/autorun.rb
|
33
|
+
- lib/opal/spec/browser_formatter.rb
|
34
|
+
- lib/opal/spec/example.rb
|
35
|
+
- lib/opal/spec/example_group.rb
|
36
|
+
- lib/opal/spec/expectations.rb
|
37
|
+
- lib/opal/spec/kernel.rb
|
38
|
+
- lib/opal/spec/matchers.rb
|
39
|
+
- lib/opal/spec/runner.rb
|
40
|
+
- lib/opal/spec/scratch_pad.rb
|
41
|
+
- lib/opal/spec/version.rb
|
43
42
|
- opal-spec.gemspec
|
44
43
|
homepage: http://opalrb.org
|
45
44
|
licenses: []
|
@@ -61,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
60
|
version: '0'
|
62
61
|
requirements: []
|
63
62
|
rubyforge_project:
|
64
|
-
rubygems_version: 1.8.
|
63
|
+
rubygems_version: 1.8.24
|
65
64
|
signing_key:
|
66
65
|
specification_version: 3
|
67
66
|
summary: Opal compatible spec
|
data/lib/opal-spec/autorun.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'opal-spec'
|
2
|
-
|
3
|
-
OpalSpec.on_dom_ready do
|
4
|
-
Dir[OpalSpec.autorun_glob].each do |s|
|
5
|
-
require s
|
6
|
-
end
|
7
|
-
|
8
|
-
OpalSpec::Runner.new.run
|
9
|
-
end
|
10
|
-
|
11
|
-
module OpalSpec
|
12
|
-
@autorun_glob = "spec/**/*"
|
13
|
-
|
14
|
-
def self.autorun_glob
|
15
|
-
@autorun_glob
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.autorun_glob=(glob)
|
19
|
-
@autorun_glob = glob
|
20
|
-
end
|
21
|
-
end
|
data/lib/opal-spec/dom.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
module OpalSpec
|
2
|
-
|
3
|
-
def self.on_dom_ready(&block)
|
4
|
-
%x{
|
5
|
-
setTimeout(function() {
|
6
|
-
#{ block.call };
|
7
|
-
}, 0);
|
8
|
-
}
|
9
|
-
end
|
10
|
-
|
11
|
-
class Element
|
12
|
-
def self.body_ready?
|
13
|
-
`!!(document && document.body)`
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(tag = 'div')
|
17
|
-
`this.el = document.createElement(tag)`
|
18
|
-
end
|
19
|
-
|
20
|
-
def class_name=(class_name)
|
21
|
-
`this.el.className = class_name`
|
22
|
-
end
|
23
|
-
|
24
|
-
def html=(html)
|
25
|
-
`this.el.innerHTML = html`
|
26
|
-
end
|
27
|
-
|
28
|
-
def append(child)
|
29
|
-
`this.el.appendChild(child.el)`
|
30
|
-
end
|
31
|
-
|
32
|
-
def hide
|
33
|
-
`this.el.style.display = 'none'`
|
34
|
-
end
|
35
|
-
|
36
|
-
def show
|
37
|
-
`delete this.el.style.display`
|
38
|
-
end
|
39
|
-
|
40
|
-
def append_to_head
|
41
|
-
`document.head.appendChild(this.el)`
|
42
|
-
end
|
43
|
-
|
44
|
-
def append_to_body
|
45
|
-
`document.body.appendChild(this.el)`
|
46
|
-
end
|
47
|
-
|
48
|
-
def style(key, val)
|
49
|
-
`this.el.style[key] = val`
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
data/lib/opal-spec/version.rb
DELETED
data/lib/opal-spec.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'opal-spec/example'
|
2
|
-
require 'opal-spec/example_group'
|
3
|
-
require 'opal-spec/matchers'
|
4
|
-
require 'opal-spec/runner'
|
5
|
-
require 'opal-spec/scratch_pad'
|
6
|
-
require 'opal-spec/expectations'
|
7
|
-
require 'opal-spec/browser_formatter'
|
8
|
-
require 'opal-spec/dom'
|
9
|
-
require 'opal-spec/kernel'
|
10
|
-
require 'opal-spec/version'
|