opal-spec 0.2.12 → 0.2.13
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/CHANGELOG.md +11 -0
- data/Gemfile +1 -2
- data/lib/assets/javascripts/opal/spec/matchers.rb +4 -10
- data/lib/assets/javascripts/opal/spec/matchers/base.rb +11 -0
- data/lib/assets/javascripts/opal/spec/matchers/be_empty.rb +15 -0
- data/lib/assets/javascripts/opal/spec/matchers/respond_to.rb +19 -0
- data/lib/assets/javascripts/opal/spec/spec.rb +5 -0
- data/lib/opal/spec/server.rb +13 -53
- data/lib/opal/spec/version.rb +1 -1
- data/spec/matchers/be_empty_spec.rb +9 -0
- data/spec/matchers/respond_to_spec.rb +15 -0
- data/spec/specs.rb +18 -0
- metadata +7 -3
- data/vendor/spec_runner.html.erb +0 -9
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## 0.2.13 2013-02-23
|
2
|
+
|
3
|
+
* Re-write Opal::Spec::Server to inherit from Opal::Server. Opal::Server is
|
4
|
+
a standard rack-app which configures Opal and load paths in a more
|
5
|
+
consistent manner.
|
6
|
+
|
7
|
+
* Add respond_to and be_empty matchers for Spec.
|
8
|
+
|
9
|
+
* Added Spec::Pending as a standard way to mark specs as not compliant or
|
10
|
+
working. Pending specs are simply ignored when running.
|
11
|
+
|
1
12
|
## 0.2.11 2013-02-20
|
2
13
|
|
3
14
|
* Added TestCase class to allow unit tests. OpalTest::Spec now inherits from
|
data/Gemfile
CHANGED
@@ -1,14 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
@actual = actual
|
5
|
-
end
|
6
|
-
|
7
|
-
def failure(message)
|
8
|
-
raise Spec::ExpectationNotMetError, message
|
9
|
-
end
|
10
|
-
end
|
1
|
+
require 'opal/spec/matchers/base'
|
2
|
+
require 'opal/spec/matchers/be_empty'
|
3
|
+
require 'opal/spec/matchers/respond_to'
|
11
4
|
|
5
|
+
module OpalTest
|
12
6
|
class PositiveOperatorMatcher < Matcher
|
13
7
|
def == expected
|
14
8
|
if @actual == expected
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module OpalTest
|
2
|
+
class RespondToMatcher < Matcher
|
3
|
+
def initialize(expected)
|
4
|
+
@expected = expected
|
5
|
+
end
|
6
|
+
|
7
|
+
def match(actual)
|
8
|
+
unless actual.respond_to?(@expected)
|
9
|
+
failure "Expected #{actual.inspect} (#{actual.class}) to respond to #{@expected}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Object
|
16
|
+
def respond_to(expected)
|
17
|
+
OpalTest::RespondToMatcher.new expected
|
18
|
+
end
|
19
|
+
end
|
data/lib/opal/spec/server.rb
CHANGED
@@ -1,63 +1,23 @@
|
|
1
1
|
require 'opal/spec'
|
2
|
-
require '
|
2
|
+
require 'opal'
|
3
3
|
|
4
4
|
module Opal
|
5
5
|
module Spec
|
6
|
-
class Server
|
7
|
-
class Index
|
8
|
-
def initialize(app, server)
|
9
|
-
@app = app
|
10
|
-
@server = server
|
11
|
-
end
|
12
|
-
|
13
|
-
def call(env)
|
14
|
-
if env['PATH_INFO'] == '/'
|
15
|
-
[200, { 'Content-Type' => 'text/html' }, [self.html]]
|
16
|
-
else
|
17
|
-
@app.call env
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def html
|
22
|
-
source = File.read File.join(VENDOR_PATH, 'spec_runner.html.erb')
|
23
|
-
ERB.new(source).result binding
|
24
|
-
end
|
25
|
-
|
26
|
-
def javascript_include_tag(source)
|
27
|
-
if @server.debug
|
28
|
-
paths = sprockets[source].to_a.map { |d| "#{d.logical_path}?body=1" }
|
29
|
-
tags = paths.map { |p| "<script src=\"/assets/#{p}\"></script>" }
|
30
|
-
tags.join "\n"
|
31
|
-
else
|
32
|
-
"<script src=\"/assets/#{source}.js\"></script>"
|
33
|
-
end
|
34
|
-
end
|
35
6
|
|
36
|
-
|
37
|
-
|
7
|
+
# Custom Opal::Server subclass which adds the 'spec' dir as a
|
8
|
+
# directory for testing (adds to load path). Specs run through this
|
9
|
+
# server are not run in debug mode (all scripts loaded in a single
|
10
|
+
# file). This can be overriden in the supplied block.
|
11
|
+
class Server < Opal::Server
|
12
|
+
def initialize(*args, &block)
|
13
|
+
super(*args) do |s|
|
14
|
+
s.append_path 'spec'
|
15
|
+
s.main = 'opal/spec/sprockets_runner'
|
16
|
+
s.debug = false
|
17
|
+
|
18
|
+
yield s if block_given?
|
38
19
|
end
|
39
20
|
end
|
40
|
-
|
41
|
-
attr_reader :sprockets
|
42
|
-
attr_reader :debug
|
43
|
-
|
44
|
-
def initialize(debug = true)
|
45
|
-
@debug = debug
|
46
|
-
server = self
|
47
|
-
|
48
|
-
@sprockets = sprockets = Opal::Environment.new
|
49
|
-
@sprockets.append_path 'spec'
|
50
|
-
|
51
|
-
@app = Rack::Builder.app do
|
52
|
-
map('/assets') { run sprockets }
|
53
|
-
use Index, server
|
54
|
-
run Rack::Directory.new('spec')
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def call(env)
|
59
|
-
@app.call env
|
60
|
-
end
|
61
21
|
end
|
62
22
|
end
|
63
23
|
end
|
data/lib/opal/spec/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
class RespondToSpecs
|
2
|
+
def foo; end
|
3
|
+
end
|
4
|
+
|
5
|
+
describe "respond_to" do
|
6
|
+
it "should pass if the object responds to method" do
|
7
|
+
RespondToSpecs.new.should respond_to(:foo)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should fail if the object does not respond to method" do
|
11
|
+
lambda {
|
12
|
+
RespondToSpecs.new.should respond_to(:bar)
|
13
|
+
}.should raise_error(Exception)
|
14
|
+
end
|
15
|
+
end
|
data/spec/specs.rb
CHANGED
@@ -88,4 +88,22 @@ describe "before" do
|
|
88
88
|
it "should run multiple before blocks" do
|
89
89
|
@bar.should == 200
|
90
90
|
end
|
91
|
+
|
92
|
+
describe "nested" do
|
93
|
+
before { @nested = 300 }
|
94
|
+
|
95
|
+
it "should inherit before blocks" do
|
96
|
+
@foo.should eq(100)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should also run nested before blocks" do
|
100
|
+
@nested.should eq(300)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "pending" do
|
106
|
+
pending "these tests are not run" do
|
107
|
+
raise "otherwise this error would be raised"
|
108
|
+
end
|
91
109
|
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.2.
|
4
|
+
version: 0.2.13
|
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-02-
|
12
|
+
date: 2013-02-23 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Opal compatible spec library
|
15
15
|
email: adam.beynon@gmail.com
|
@@ -29,6 +29,9 @@ files:
|
|
29
29
|
- lib/assets/javascripts/opal/spec/expectations.rb
|
30
30
|
- lib/assets/javascripts/opal/spec/kernel.rb
|
31
31
|
- lib/assets/javascripts/opal/spec/matchers.rb
|
32
|
+
- lib/assets/javascripts/opal/spec/matchers/base.rb
|
33
|
+
- lib/assets/javascripts/opal/spec/matchers/be_empty.rb
|
34
|
+
- lib/assets/javascripts/opal/spec/matchers/respond_to.rb
|
32
35
|
- lib/assets/javascripts/opal/spec/phantom_formatter.rb
|
33
36
|
- lib/assets/javascripts/opal/spec/runner.rb
|
34
37
|
- lib/assets/javascripts/opal/spec/scratch_pad.rb
|
@@ -41,9 +44,10 @@ files:
|
|
41
44
|
- lib/opal/spec/server.rb
|
42
45
|
- lib/opal/spec/version.rb
|
43
46
|
- opal-spec.gemspec
|
47
|
+
- spec/matchers/be_empty_spec.rb
|
48
|
+
- spec/matchers/respond_to_spec.rb
|
44
49
|
- spec/specs.rb
|
45
50
|
- spec/tests.rb
|
46
|
-
- vendor/spec_runner.html.erb
|
47
51
|
- vendor/spec_runner.js
|
48
52
|
homepage: http://opalrb.org
|
49
53
|
licenses: []
|