opal-spec 0.0.2 → 0.0.3
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/README.md +6 -0
- data/Rakefile +2 -2
- data/example/bar.rb +21 -0
- data/example/before.rb +19 -0
- data/example/foo.rb +39 -0
- data/example/groups.rb +11 -0
- data/example/nested.rb +11 -0
- data/example/runner.html +16 -0
- data/example/spec_helper.rb +5 -0
- data/lib/opal/spec/example.rb +1 -1
- data/lib/opal/spec/example_group.rb +15 -8
- data/lib/opal/spec/expectations.rb +1 -1
- data/lib/opal/spec/matchers.rb +3 -4
- data/lib/opal/spec/version.rb +1 -1
- metadata +10 -3
data/README.md
CHANGED
@@ -8,6 +8,12 @@ bare minimum to get specs running.
|
|
8
8
|
Change Log
|
9
9
|
----------
|
10
10
|
|
11
|
+
### 0.0.3
|
12
|
+
|
13
|
+
* Allow group names to be non-strings
|
14
|
+
* Nested groups now have outer group name as prefix
|
15
|
+
* Nested groups should inherit `before` and `after` blocks
|
16
|
+
|
11
17
|
### 0.0.2
|
12
18
|
|
13
19
|
* Added seperate BrowserFormatter class for cleaner output
|
data/Rakefile
CHANGED
@@ -2,10 +2,10 @@ require 'opal'
|
|
2
2
|
|
3
3
|
desc "Build latest opal-spec to current dir"
|
4
4
|
task :opal do
|
5
|
-
|
5
|
+
sh "opal build"
|
6
6
|
end
|
7
7
|
|
8
8
|
desc "Get all running dependnecies"
|
9
9
|
task :dependencies do
|
10
|
-
|
10
|
+
sh "opal dependencies"
|
11
11
|
end
|
data/example/bar.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
describe "All these tests will pass" do
|
2
|
+
it "some simple expectations" do
|
3
|
+
1.should == 1
|
4
|
+
2.should == 2
|
5
|
+
|
6
|
+
[1, 2, 3].should == [1, 2, 3]
|
7
|
+
[].should == []
|
8
|
+
|
9
|
+
"foo".should == "foo"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "some simple negative expectations" do
|
13
|
+
1.should_not == 2
|
14
|
+
3.should_not == 1
|
15
|
+
|
16
|
+
[1, 2, 3].should_not == [1, 2, 3, 4]
|
17
|
+
[].should_not == [1]
|
18
|
+
|
19
|
+
"foo".should_not == "bar"
|
20
|
+
end
|
21
|
+
end
|
data/example/before.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
describe "Outer before" do
|
2
|
+
before do
|
3
|
+
@foo = "foo_ran"
|
4
|
+
end
|
5
|
+
|
6
|
+
describe "with an inner before" do
|
7
|
+
before do
|
8
|
+
@bah = "bah_ran"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should get the outer before hooks run" do
|
12
|
+
@foo.should == "foo_ran"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should still run inner befores" do
|
16
|
+
@bah.should == "bah_ran"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/example/foo.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
describe "All these tests will fail" do
|
2
|
+
it "some simple expectations" do
|
3
|
+
1.should == 2
|
4
|
+
end
|
5
|
+
|
6
|
+
it "some array comparisons" do
|
7
|
+
[1, 2, 3].should == nil
|
8
|
+
end
|
9
|
+
|
10
|
+
it "be_kind_of expectations" do
|
11
|
+
1.should be_kind_of String
|
12
|
+
end
|
13
|
+
|
14
|
+
it "be_nil expectation" do
|
15
|
+
[].should be_nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it "be_true expectation" do
|
19
|
+
false.should be_true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "be_false expectation" do
|
23
|
+
true.should be_false
|
24
|
+
end
|
25
|
+
|
26
|
+
it "equal expectation" do
|
27
|
+
Object.new.should equal(Object.new)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "raise_error expectation" do
|
31
|
+
lambda {
|
32
|
+
"dont raise"
|
33
|
+
}.should raise_error(Exception)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "can use backtraces when available" do
|
37
|
+
something.should.fail.as.all.these.methods.dont.exist
|
38
|
+
end
|
39
|
+
end
|
data/example/groups.rb
ADDED
data/example/nested.rb
ADDED
data/example/runner.html
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
5
|
+
|
6
|
+
<title>Opal Spec Runner</title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<script src="../opal.debug.js"></script>
|
10
|
+
<script src="../opal-spec.debug.js"></script>
|
11
|
+
<script src="../example.debug.js"></script>
|
12
|
+
<script>
|
13
|
+
opal.main('example/spec_helper');
|
14
|
+
</script>
|
15
|
+
</body>
|
16
|
+
</html>
|
data/lib/opal/spec/example.rb
CHANGED
@@ -5,16 +5,23 @@ module OpalSpec
|
|
5
5
|
@example_groups
|
6
6
|
end
|
7
7
|
|
8
|
+
@stack = []
|
8
9
|
def self.create desc, block
|
9
|
-
|
10
|
+
group = self.new desc, @stack.last
|
11
|
+
@example_groups << group
|
12
|
+
|
13
|
+
@stack << group
|
14
|
+
group.instance_eval &block
|
15
|
+
@stack.pop
|
10
16
|
end
|
11
17
|
|
12
|
-
def initialize desc,
|
13
|
-
@desc
|
18
|
+
def initialize desc, parent
|
19
|
+
@desc = desc.to_s
|
20
|
+
@parent = parent
|
14
21
|
@examples = []
|
22
|
+
|
15
23
|
@before_hooks = []
|
16
|
-
@after_hooks
|
17
|
-
instance_eval &block
|
24
|
+
@after_hooks = []
|
18
25
|
end
|
19
26
|
|
20
27
|
def it desc, &block
|
@@ -35,11 +42,11 @@ module OpalSpec
|
|
35
42
|
end
|
36
43
|
|
37
44
|
def before_hooks
|
38
|
-
@before_hooks
|
45
|
+
@parent ? @parent.before_hooks + @before_hooks : @before_hooks
|
39
46
|
end
|
40
47
|
|
41
48
|
def after_hooks
|
42
|
-
@after_hooks
|
49
|
+
@parent ? @parent.after_hooks + @after_hooks : @after_hooks
|
43
50
|
end
|
44
51
|
|
45
52
|
def run runner
|
@@ -49,7 +56,7 @@ module OpalSpec
|
|
49
56
|
end
|
50
57
|
|
51
58
|
def description
|
52
|
-
@desc
|
59
|
+
@parent ? "#{@parent.description} #{@desc}" : @desc
|
53
60
|
end
|
54
61
|
end
|
55
62
|
end
|
data/lib/opal/spec/matchers.rb
CHANGED
@@ -74,17 +74,16 @@ module OpalSpec
|
|
74
74
|
end
|
75
75
|
|
76
76
|
class RaiseErrorMatcher < Matcher
|
77
|
-
def match
|
77
|
+
def match block
|
78
78
|
should_raise = false
|
79
79
|
begin
|
80
|
-
|
80
|
+
block.call
|
81
81
|
should_raise = true
|
82
82
|
rescue => e
|
83
|
-
|
84
83
|
end
|
85
84
|
|
86
85
|
if should_raise
|
87
|
-
failure "expected #{
|
86
|
+
failure "expected #{@actual} to be raised, but nothing was."
|
88
87
|
end
|
89
88
|
end
|
90
89
|
end
|
data/lib/opal/spec/version.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.3
|
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: 2012-01-
|
12
|
+
date: 2012-01-21 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Opal spec lib
|
15
15
|
email:
|
@@ -21,6 +21,13 @@ files:
|
|
21
21
|
- .gitignore
|
22
22
|
- README.md
|
23
23
|
- Rakefile
|
24
|
+
- example/bar.rb
|
25
|
+
- example/before.rb
|
26
|
+
- example/foo.rb
|
27
|
+
- example/groups.rb
|
28
|
+
- example/nested.rb
|
29
|
+
- example/runner.html
|
30
|
+
- example/spec_helper.rb
|
24
31
|
- lib/opal/spec.rb
|
25
32
|
- lib/opal/spec/autorun.rb
|
26
33
|
- lib/opal/spec/browser_formatter.rb
|
@@ -54,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
61
|
version: '0'
|
55
62
|
requirements: []
|
56
63
|
rubyforge_project:
|
57
|
-
rubygems_version: 1.8.
|
64
|
+
rubygems_version: 1.8.10
|
58
65
|
signing_key:
|
59
66
|
specification_version: 3
|
60
67
|
summary: Opal spec lib
|