opal-spec 0.0.1 → 0.2.8
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/.gitignore +4 -5
- data/Gemfile +6 -0
- data/README.md +90 -3
- data/Rakefile +27 -0
- data/lib/assets/javascripts/opal/spec/browser_formatter.rb +194 -0
- data/lib/assets/javascripts/opal/spec/example.rb +78 -0
- data/lib/assets/javascripts/opal/spec/example_group.rb +94 -0
- data/lib/assets/javascripts/opal/spec/expectations.rb +55 -0
- data/lib/{opal → assets/javascripts/opal}/spec/kernel.rb +1 -1
- data/lib/assets/javascripts/opal/spec/matchers.rb +106 -0
- data/lib/assets/javascripts/opal/spec/phantom_formatter.rb +93 -0
- data/lib/assets/javascripts/opal/spec/runner.rb +80 -0
- data/lib/assets/javascripts/opal/spec.rb +13 -0
- data/lib/assets/javascripts/opal-spec.rb +1 -0
- data/lib/opal/spec/rake_task.rb +52 -0
- data/lib/opal/spec/runner.rb +9 -35
- data/lib/opal/spec/version.rb +4 -2
- data/lib/opal/spec.rb +8 -7
- data/lib/opal-spec.rb +1 -0
- data/opal-spec.gemspec +10 -10
- data/spec/index.html +9 -0
- data/spec/specs.rb +76 -0
- data/vendor/runner.js +40 -0
- metadata +25 -16
- data/lib/opal/spec/autorun.rb +0 -30
- data/lib/opal/spec/example.rb +0 -45
- data/lib/opal/spec/example_group.rb +0 -55
- data/lib/opal/spec/expectations.rb +0 -49
- data/lib/opal/spec/formatter.rb +0 -58
- data/lib/opal/spec/matchers.rb +0 -91
- /data/lib/{opal → assets/javascripts/opal}/spec/scratch_pad.rb +0 -0
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
module OpalSpec
|
|
2
|
-
class ExpectationNotMetError < StandardError; end
|
|
3
|
-
|
|
4
|
-
module Expectations
|
|
5
|
-
def should matcher = nil
|
|
6
|
-
if matcher
|
|
7
|
-
matcher.match self
|
|
8
|
-
else
|
|
9
|
-
OpalSpec::PositiveOperatorMatcher.new self
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def should_not matcher = nil
|
|
14
|
-
if matcher
|
|
15
|
-
matcher.not_match self
|
|
16
|
-
else
|
|
17
|
-
OpalSpec::NegativeOperatorMatcher.new self
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def be_kind_of expected
|
|
22
|
-
OpalSpec::BeKindOfMatcher.new expected
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def be_nil
|
|
26
|
-
OpalSpec::BeNilMatcher.new nil
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def be_true
|
|
30
|
-
OpalSpec::BeTrueMatcher.new true
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def be_false
|
|
34
|
-
OpalSpec::BeFalseMatcher.new false
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def equal expected
|
|
38
|
-
OpalSpec::EqualMatcher.new expected
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def raise_error expected
|
|
42
|
-
OpalSpec::RaiseErrorMatcher.new expected, &@actual
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
class Object
|
|
48
|
-
include OpalSpec::Expectations
|
|
49
|
-
end
|
data/lib/opal/spec/formatter.rb
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
module OpalSpec
|
|
2
|
-
class Formatter
|
|
3
|
-
def initialize
|
|
4
|
-
@examples = []
|
|
5
|
-
@failed_examples = []
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def start
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def finish
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def example_group_started group
|
|
15
|
-
@example_group = group
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def example_group_finished group
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def example_started example
|
|
22
|
-
@examples << example
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def example_passed example
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def example_failed example
|
|
29
|
-
@failed_examples << example
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def example_count
|
|
33
|
-
@examples.size
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
class ConsoleFormatter < Formatter
|
|
38
|
-
def finish
|
|
39
|
-
@failed_examples.each_with_index do |example, i|
|
|
40
|
-
exception = example.exception
|
|
41
|
-
description = example.description
|
|
42
|
-
group = example.example_group
|
|
43
|
-
|
|
44
|
-
case exception
|
|
45
|
-
when OpalSpec::ExpectationNotMetError
|
|
46
|
-
puts "\n#{i + 1}) Failure:\n#{group.description} #{description}:"
|
|
47
|
-
puts "#{exception.message}\n"
|
|
48
|
-
else
|
|
49
|
-
puts "\n#{i + 1}) Error:\n#{group.description} #{description}:"
|
|
50
|
-
puts "#{exception.class}: #{exception.message}\n"
|
|
51
|
-
puts " #{exception.backtrace.join "\n "}\n"
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
puts "\n#{example_count} specifications, #{@failed_examples.size} failures"
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
data/lib/opal/spec/matchers.rb
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
module OpalSpec
|
|
2
|
-
class Matcher
|
|
3
|
-
def initialize actual
|
|
4
|
-
@actual = actual
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def failure message
|
|
8
|
-
raise OpalSpec::ExpectationNotMetError, message
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
class PositiveOperatorMatcher < Matcher
|
|
13
|
-
def == expected
|
|
14
|
-
if @actual == expected
|
|
15
|
-
true
|
|
16
|
-
else
|
|
17
|
-
failure "expected: #{expected.inspect}, got: #{@actual.inspect} (using ==)."
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
class NegativeOperatorMatcher < Matcher
|
|
23
|
-
def == expected
|
|
24
|
-
if @actual == expected
|
|
25
|
-
failure "expected: #{expected.inspect} not to be #{@actual.inspect} (using ==)."
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
class BeKindOfMatcher < Matcher
|
|
31
|
-
def match expected
|
|
32
|
-
unless expected.kind_of? @actual
|
|
33
|
-
failure "expected #{expected.inspect} to be a kind of #{@actual}, not #{expected.class}."
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
class BeNilMatcher < Matcher
|
|
39
|
-
def match expected
|
|
40
|
-
unless expected.nil?
|
|
41
|
-
failure "expected #{expected.inspect} to be nil."
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
class BeTrueMatcher < Matcher
|
|
47
|
-
def match expected
|
|
48
|
-
unless expected == true
|
|
49
|
-
failure "expected #{expected.inspect} to be true."
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
class BeFalseMatcher < Matcher
|
|
55
|
-
def match expected
|
|
56
|
-
unless expected == false
|
|
57
|
-
failure "expected #{expected.inspect} to be false."
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
class EqualMatcher < Matcher
|
|
63
|
-
def match expected
|
|
64
|
-
unless expected.equal? @actual
|
|
65
|
-
failure "expected #{@actual.inspect} to be the same as #{expected.inspect}."
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def not_match expected
|
|
70
|
-
if expected.equal? @actual
|
|
71
|
-
failure "expected #{@actual.inspect} not to be equal to #{expected.inspect}."
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
class RaiseErrorMatcher < Matcher
|
|
77
|
-
def match expected
|
|
78
|
-
should_raise = false
|
|
79
|
-
begin
|
|
80
|
-
yield
|
|
81
|
-
should_raise = true
|
|
82
|
-
rescue => e
|
|
83
|
-
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
if should_raise
|
|
87
|
-
failure "expected #{expected} to be raised, but nothing was."
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
File without changes
|