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 CHANGED
@@ -1,5 +1 @@
1
- require 'opal'
2
-
3
- Opal::Builder.setup do |b|
4
-
5
- end
1
+ require 'opal'
@@ -0,0 +1,3 @@
1
+ Document.ready? do
2
+ Spec::Runner.new.run
3
+ end
@@ -1,4 +1,4 @@
1
- module OpalSpec
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 Element.body_ready?
60
- raise "Not running in browser"
61
- end
59
+ raise "Not running in browser" unless Document.body_ready?
62
60
 
63
- @summary_element = Element.new 'p'
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 = Element.new 'ul'
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
- styles = Element.new 'style'
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 = Element.new 'li'
86
-
87
- description = Element.new 'span'
88
- description.class_name = 'group_description'
89
- description.html = group.description
90
-
91
- @group_element.append description
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 = Element.new 'ul'
94
- @example_list.class_name = 'examples'
95
- @example_list.hide
87
+ @example_list = DOM.parse <<-HTML
88
+ <ul class="examples" style="display:none;"></ul>
89
+ HTML
96
90
 
97
- @group_element.append @example_list
98
- @groups_element.append @group_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 OpalSpec::ExpectationNotMetError
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 = Element.new 'li'
129
- wrapper.class_name = 'example failed'
122
+ wrapper = DOM.parse '<li class="example failed"></li>'
130
123
 
131
- description = Element.new 'span'
132
- description.class_name = 'example_description'
133
- description.html = example.description
124
+ description = DOM.parse <<-HTML
125
+ <span class="example_description">#{ example.description }</span>
126
+ HTML
134
127
 
135
- exception = Element.new 'pre'
136
- exception.class_name = 'exception'
137
- exception.html = output
128
+ exception = DOM.parse <<-HTML
129
+ <pre class="exception">#{ output }</pre>
130
+ HTML
138
131
 
139
- wrapper.append description
140
- wrapper.append exception
132
+ wrapper << description
133
+ wrapper << exception
141
134
 
142
135
  @example_list.append wrapper
143
- @example_list.style 'display', 'list-item'
136
+ @example_list.css 'display', 'list-item'
144
137
  end
145
138
 
146
139
  def example_passed example
147
- wrapper = Element.new 'li'
148
- wrapper.class_name = 'example passed'
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
- description = Element.new 'span'
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 OpalSpec
1
+ module Spec
2
2
  class Example
3
3
  attr_reader :description, :example_group, :exception
4
4
 
@@ -1,4 +1,4 @@
1
- module OpalSpec
1
+ module Spec
2
2
  class ExampleGroup
3
3
  @example_groups = []
4
4
  def self.example_groups
@@ -1,4 +1,4 @@
1
- module OpalSpec
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
- OpalSpec::PositiveOperatorMatcher.new self
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
- OpalSpec::NegativeOperatorMatcher.new self
17
+ Spec::NegativeOperatorMatcher.new self
18
18
  end
19
19
  end
20
20
 
21
21
  def be_kind_of expected
22
- OpalSpec::BeKindOfMatcher.new expected
22
+ Spec::BeKindOfMatcher.new expected
23
23
  end
24
24
 
25
25
  def be_nil
26
- OpalSpec::BeNilMatcher.new nil
26
+ Spec::BeNilMatcher.new nil
27
27
  end
28
28
 
29
29
  def be_true
30
- OpalSpec::BeTrueMatcher.new true
30
+ Spec::BeTrueMatcher.new true
31
31
  end
32
32
 
33
33
  def be_false
34
- OpalSpec::BeFalseMatcher.new false
34
+ Spec::BeFalseMatcher.new false
35
35
  end
36
36
 
37
37
  def equal expected
38
- OpalSpec::EqualMatcher.new expected
38
+ Spec::EqualMatcher.new expected
39
39
  end
40
40
 
41
41
  def raise_error expected
42
- OpalSpec::RaiseErrorMatcher.new expected
42
+ Spec::RaiseErrorMatcher.new expected
43
43
  end
44
44
  end
45
45
  end
46
46
 
47
47
  class Object
48
- include OpalSpec::Expectations
48
+ include Spec::Expectations
49
49
  end
@@ -1,9 +1,9 @@
1
1
  module Kernel
2
2
  def describe desc, &block
3
- OpalSpec::ExampleGroup.create desc, block
3
+ Spec::ExampleGroup.create desc, block
4
4
  end
5
5
 
6
6
  def mock obj
7
7
  Object.new
8
8
  end
9
- end
9
+ end
@@ -1,11 +1,11 @@
1
- module OpalSpec
1
+ module Spec
2
2
  class Matcher
3
3
  def initialize actual
4
4
  @actual = actual
5
5
  end
6
6
 
7
7
  def failure message
8
- raise OpalSpec::ExpectationNotMetError, message
8
+ raise Spec::ExpectationNotMetError, message
9
9
  end
10
10
  end
11
11
 
@@ -1,4 +1,4 @@
1
- module OpalSpec
1
+ module Spec
2
2
  class Runner
3
3
  def initialize
4
4
  @formatter = BrowserFormatter.new
File without changes
@@ -0,0 +1,3 @@
1
+ module Spec
2
+ VERSION = "0.1.7"
3
+ end
data/lib/opal/spec.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'spec/example'
2
+ require 'spec/example_group'
3
+ require 'spec/matchers'
4
+ require 'spec/runner'
5
+ require 'spec/scratch_pad'
6
+ require 'spec/expectations'
7
+ require 'spec/browser_formatter'
8
+ require 'spec/kernel'
9
+ require 'spec/version'
data/opal-spec.gemspec CHANGED
@@ -1,15 +1,15 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/opal-spec/version', __FILE__)
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 = OpalSpec::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.6
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-05-29 00:00:00.000000000Z
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-spec.rb
32
- - lib/opal-spec/autorun.rb
33
- - lib/opal-spec/browser_formatter.rb
34
- - lib/opal-spec/dom.rb
35
- - lib/opal-spec/example.rb
36
- - lib/opal-spec/example_group.rb
37
- - lib/opal-spec/expectations.rb
38
- - lib/opal-spec/kernel.rb
39
- - lib/opal-spec/matchers.rb
40
- - lib/opal-spec/runner.rb
41
- - lib/opal-spec/scratch_pad.rb
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.11
63
+ rubygems_version: 1.8.24
65
64
  signing_key:
66
65
  specification_version: 3
67
66
  summary: Opal compatible spec
@@ -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
@@ -1,3 +0,0 @@
1
- module OpalSpec
2
- VERSION = "0.1.6"
3
- end
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'