opal 0.3.2 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +85 -127
- data/bin/opal +3 -3
- data/lib/core.rb +114 -0
- data/{gems/core/lib → lib}/core/array.rb +68 -187
- data/{gems/core/lib → lib}/core/basic_object.rb +22 -5
- data/lib/core/class.rb +38 -0
- data/{gems/core/lib → lib}/core/dir.rb +1 -1
- data/lib/core/enumerable.rb +33 -0
- data/{gems/core/lib → lib}/core/error.rb +1 -4
- data/{gems/core/lib → lib}/core/false_class.rb +0 -0
- data/{gems/core/lib → lib}/core/file.rb +11 -3
- data/{gems/core/lib → lib}/core/hash.rb +12 -0
- data/{gems/core/lib → lib}/core/kernel.rb +114 -86
- data/lib/core/match_data.rb +33 -0
- data/lib/core/module.rb +97 -0
- data/{gems/core/lib → lib}/core/nil_class.rb +0 -0
- data/{gems/core/lib → lib}/core/numeric.rb +5 -0
- data/{gems/core/lib → lib}/core/object.rb +0 -0
- data/{gems/core/lib → lib}/core/proc.rb +13 -3
- data/{gems/core/lib → lib}/core/range.rb +10 -0
- data/{gems/core/lib → lib}/core/regexp.rb +33 -1
- data/{gems/core/lib → lib}/core/string.rb +25 -10
- data/{gems/core/lib → lib}/core/symbol.rb +3 -3
- data/{gems/core/lib → lib}/core/top_self.rb +0 -0
- data/{gems/core/lib → lib}/core/true_class.rb +0 -0
- data/lib/dev.rb +169 -0
- data/{gems/ospec/lib → lib}/ospec.rb +1 -0
- data/lib/ospec/autorun.rb +8 -0
- data/{gems/ospec/lib → lib}/ospec/dsl.rb +2 -2
- data/{gems/ospec/lib → lib}/ospec/example.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/example/before_and_after_hooks.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/example/errors.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/example/example_group.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/example/example_group_factory.rb +0 -3
- data/{gems/ospec/lib → lib}/ospec/example/example_group_hierarchy.rb +4 -3
- data/{gems/ospec/lib → lib}/ospec/example/example_group_methods.rb +1 -1
- data/{gems/ospec/lib → lib}/ospec/example/example_group_proxy.rb +3 -2
- data/{gems/ospec/lib → lib}/ospec/example/example_methods.rb +1 -1
- data/{gems/ospec/lib → lib}/ospec/example/example_proxy.rb +7 -7
- data/{gems/ospec/lib → lib}/ospec/expectations.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/expectations/errors.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/expectations/fail_with.rb +4 -3
- data/{gems/ospec/lib → lib}/ospec/expectations/handler.rb +6 -0
- data/lib/ospec/helpers/scratch.rb +18 -0
- data/{gems/ospec/lib → lib}/ospec/matchers.rb +2 -2
- data/{gems/ospec/lib → lib}/ospec/matchers/be.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/matchers/generated_descriptions.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/matchers/operator_matcher.rb +2 -0
- data/lib/ospec/matchers/raise_error.rb +38 -0
- data/lib/ospec/runner.rb +90 -0
- data/{gems/ospec/lib → lib}/ospec/runner/example_group_runner.rb +10 -13
- data/lib/ospec/runner/formatter/html_formatter.rb +139 -0
- data/{gems/ospec/lib → lib}/ospec/runner/formatter/terminal_formatter.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/runner/options.rb +1 -3
- data/{gems/ospec/lib → lib}/ospec/runner/reporter.rb +0 -9
- data/lib/racc/parser.rb +165 -0
- data/lib/strscan.rb +52 -0
- data/{lib → opal_lib}/opal.rb +2 -0
- data/opal_lib/opal/build_methods.rb +51 -0
- data/opal_lib/opal/builder.rb +164 -0
- data/opal_lib/opal/bundle.rb +70 -0
- data/opal_lib/opal/command.rb +68 -0
- data/{lib → opal_lib}/opal/context.rb +21 -9
- data/{lib → opal_lib}/opal/context/console.rb +0 -2
- data/opal_lib/opal/context/file_system.rb +34 -0
- data/{lib → opal_lib}/opal/context/loader.rb +26 -8
- data/opal_lib/opal/gem.rb +84 -0
- data/{lib → opal_lib}/opal/rake/builder_task.rb +2 -2
- data/opal_lib/opal/rake/spec_task.rb +32 -0
- data/{lib → opal_lib}/opal/ruby/nodes.rb +730 -109
- data/{lib → opal_lib}/opal/ruby/parser.rb +90 -23
- data/opal_lib/opal/ruby/ruby_parser.rb +4862 -0
- data/opal_lib/opal/ruby/ruby_parser.y +1454 -0
- data/opal_lib/opal/version.rb +4 -0
- data/runtime/class.js +359 -0
- data/runtime/debug.js +84 -0
- data/runtime/fs.js +199 -0
- data/runtime/init.js +558 -0
- data/runtime/loader.js +351 -0
- data/runtime/module.js +109 -0
- data/runtime/post.js +10 -0
- data/runtime/pre.js +7 -0
- data/runtime/runtime.js +351 -0
- metadata +88 -175
- data/.gitignore +0 -7
- data/Changelog +0 -31
- data/LICENSE +0 -75
- data/Rakefile +0 -86
- data/gems/core/README.md +0 -14
- data/gems/core/Rakefile +0 -8
- data/gems/core/core.gemspec +0 -13
- data/gems/core/lib/core.rb +0 -34
- data/gems/core/lib/core/class.rb +0 -31
- data/gems/core/lib/core/module.rb +0 -100
- data/gems/core/lib/core/vm.rb +0 -16
- data/gems/core/spec/core/array/append_spec.rb +0 -30
- data/gems/core/spec/core/array/assoc_spec.rb +0 -29
- data/gems/core/spec/core/array/at_spec.rb +0 -37
- data/gems/core/spec/core/array/clear_spec.rb +0 -22
- data/gems/core/spec/core/array/collect_bang_spec.rb +0 -27
- data/gems/core/spec/core/array/collect_spec.rb +0 -27
- data/gems/core/spec/core/array/compact_spec.rb +0 -41
- data/gems/core/spec/core/array/concat_spec.rb +0 -15
- data/gems/core/spec/core/array/constructor_spec.rb +0 -14
- data/gems/core/spec/core/array/each_spec.rb +0 -9
- data/gems/core/spec/core/array/element_reference_spec.rb +0 -4
- data/gems/core/spec/core/array/first_spec.rb +0 -35
- data/gems/core/spec/core/array/include_spec.rb +0 -9
- data/gems/core/spec/core/array/join_spec.rb +0 -6
- data/gems/core/spec/core/array/last_spec.rb +0 -51
- data/gems/core/spec/core/array/length_spec.rb +0 -6
- data/gems/core/spec/core/array/map_spec.rb +0 -33
- data/gems/core/spec/core/array/reverse_spec.rb +0 -6
- data/gems/core/spec/core/builtin_constants/builtin_constants_spec.rb +0 -7
- data/gems/core/spec/core/false/and_spec.rb +0 -10
- data/gems/core/spec/core/false/inspect_spec.rb +0 -6
- data/gems/core/spec/core/false/or_spec.rb +0 -10
- data/gems/core/spec/core/false/to_s_spec.rb +0 -6
- data/gems/core/spec/core/false/xor_spec.rb +0 -10
- data/gems/core/spec/core/file/join_spec.rb +0 -19
- data/gems/core/spec/core/hash/assoc_spec.rb +0 -32
- data/gems/core/spec/core/kernel/instance_eval_spec.rb +0 -0
- data/gems/core/spec/core/kernel/loop_spec.rb +0 -24
- data/gems/core/spec/core/kernel/raise_spec.rb +0 -0
- data/gems/core/spec/core/module/attr_accessor_spec.rb +0 -28
- data/gems/core/spec/core/number/lt_spec.rb +0 -12
- data/gems/core/spec/core/string/sub_spec.rb +0 -24
- data/gems/core/spec/core/true/and_spec.rb +0 -10
- data/gems/core/spec/core/true/inspect_spec.rb +0 -6
- data/gems/core/spec/core/true/or_spec.rb +0 -10
- data/gems/core/spec/core/true/to_s_spec.rb +0 -6
- data/gems/core/spec/core/true/xor_spec.rb +0 -10
- data/gems/core/spec/language/and_spec.rb +0 -61
- data/gems/core/spec/language/array_spec.rb +0 -68
- data/gems/core/spec/language/block_spec.rb +0 -38
- data/gems/core/spec/language/break_spec.rb +0 -36
- data/gems/core/spec/language/case_spec.rb +0 -103
- data/gems/core/spec/language/def_spec.rb +0 -21
- data/gems/core/spec/language/eigenclass_spec.rb +0 -60
- data/gems/core/spec/language/file_spec.rb +0 -13
- data/gems/core/spec/language/fixtures/block.rb +0 -21
- data/gems/core/spec/language/fixtures/super.rb +0 -293
- data/gems/core/spec/language/hash_spec.rb +0 -29
- data/gems/core/spec/language/if_spec.rb +0 -54
- data/gems/core/spec/language/loop_spec.rb +0 -11
- data/gems/core/spec/language/metaclass_spec.rb +0 -21
- data/gems/core/spec/language/method_spec.rb +0 -124
- data/gems/core/spec/language/next_spec.rb +0 -25
- data/gems/core/spec/language/or_spec.rb +0 -34
- data/gems/core/spec/language/redo_spec.rb +0 -24
- data/gems/core/spec/language/regexp_spec.rb +0 -26
- data/gems/core/spec/language/rescue_spec.rb +0 -20
- data/gems/core/spec/language/return_spec.rb +0 -47
- data/gems/core/spec/language/string_spec.rb +0 -25
- data/gems/core/spec/language/super_spec.rb +0 -32
- data/gems/core/spec/language/until_spec.rb +0 -157
- data/gems/core/spec/language/variables_spec.rb +0 -155
- data/gems/core/spec/language/while_spec.rb +0 -163
- data/gems/core/spec/spec_helper.rb +0 -5
- data/gems/core_fs/README.md +0 -19
- data/gems/dev/Rakefile +0 -5
- data/gems/dev/lib/dev.js +0 -99
- data/gems/dev/lib/dev/generator.js +0 -1264
- data/gems/dev/lib/dev/parser.js +0 -979
- data/gems/dev/lib/dev/ruby_parser.js +0 -1088
- data/gems/dev/lib/dev/ruby_parser.y +0 -1267
- data/gems/dev/lib/dev/string_scanner.js +0 -38
- data/gems/dev/tools/racc2js/README.md +0 -39
- data/gems/dev/tools/racc2js/math_parser.js +0 -222
- data/gems/dev/tools/racc2js/math_parser.rb +0 -133
- data/gems/dev/tools/racc2js/math_parser.y +0 -28
- data/gems/dev/tools/racc2js/parser.js +0 -218
- data/gems/dev/tools/racc2js/racc2js.rb +0 -153
- data/gems/json/README.md +0 -4
- data/gems/json/json.gemspec +0 -14
- data/gems/json/lib/json.rb +0 -64
- data/gems/json/lib/json/ext.rb +0 -51
- data/gems/json/lib/json/json2.js +0 -481
- data/gems/ospec/README.md +0 -0
- data/gems/ospec/lib/ospec/autorun.rb +0 -3
- data/gems/ospec/lib/ospec/runner.rb +0 -40
- data/gems/ospec/lib/ospec/runner/formatter/html_formatter.rb +0 -91
- data/gems/ospec/ospec.gemspec +0 -0
- data/gems/rquery/README.md +0 -9
- data/gems/rquery/lib/rquery.rb +0 -10
- data/gems/rquery/lib/rquery/ajax.rb +0 -4
- data/gems/rquery/lib/rquery/css.rb +0 -96
- data/gems/rquery/lib/rquery/document.rb +0 -25
- data/gems/rquery/lib/rquery/element.rb +0 -292
- data/gems/rquery/lib/rquery/event.rb +0 -108
- data/gems/rquery/lib/rquery/jquery.js +0 -8177
- data/gems/rquery/lib/rquery/request.rb +0 -138
- data/gems/rquery/lib/rquery/response.rb +0 -49
- data/gems/rquery/rquery.gemspec +0 -16
- data/lib/opal.js +0 -1597
- data/lib/opal/builder.rb +0 -117
- data/lib/opal/bundle.rb +0 -131
- data/lib/opal/command.rb +0 -11
- data/lib/opal/context/file_system.rb +0 -19
- data/lib/opal/gem.rb +0 -153
- data/lib/opal/ruby/ruby_parser.rb +0 -5170
- data/lib/opal/ruby/ruby_parser.y +0 -1298
- data/opal.gemspec +0 -15
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -6,13 +6,14 @@ module Spec
|
|
6
6
|
class ExampleGroupHierarchy
|
7
7
|
|
8
8
|
def initialize(example_group_class)
|
9
|
-
@example_group_class
|
9
|
+
@example_group_class = example_group_class
|
10
10
|
end
|
11
11
|
|
12
12
|
def run_before_each(example)
|
13
|
-
|
13
|
+
@example_group_class.before_each_parts.each do |part|
|
14
14
|
# puts "in each part before"
|
15
|
-
|
15
|
+
example.instance_eval &part
|
16
|
+
end
|
16
17
|
end
|
17
18
|
|
18
19
|
end
|
@@ -55,7 +55,7 @@ module Spec
|
|
55
55
|
|
56
56
|
def run_examples(success, instance_variables, examples, run_options)
|
57
57
|
examples.each do |example|
|
58
|
-
example_group_instance = new example,
|
58
|
+
example_group_instance = new example,
|
59
59
|
&example_implementations[example]
|
60
60
|
|
61
61
|
example_group_instance.execute run_options, instance_variables
|
@@ -2,9 +2,9 @@
|
|
2
2
|
module Spec
|
3
3
|
module Example
|
4
4
|
class ExampleGroupProxy
|
5
|
-
|
5
|
+
|
6
6
|
attr_reader :description, :examples
|
7
|
-
|
7
|
+
|
8
8
|
def initialize(example_group)
|
9
9
|
@description = example_group.description
|
10
10
|
@examples = example_group.example_proxies
|
@@ -12,3 +12,4 @@ module Spec
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module Spec
|
2
|
-
module Example
|
2
|
+
module Example
|
3
3
|
class ExampleProxy
|
4
|
-
|
4
|
+
|
5
5
|
attr_reader :description
|
6
|
-
|
7
|
-
def initialize(description, options, location)
|
6
|
+
|
7
|
+
def initialize(description, options = nil, location = nil)
|
8
8
|
@description = description
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def update(description)
|
12
12
|
@description = description
|
13
13
|
self
|
14
14
|
end
|
15
|
-
|
16
|
-
end
|
15
|
+
end # ExampleProxy
|
17
16
|
end
|
18
17
|
end
|
18
|
+
|
File without changes
|
File without changes
|
@@ -8,6 +8,12 @@ module Spec
|
|
8
8
|
Spec::Matchers.last_matcher = matcher
|
9
9
|
if matcher.nil?
|
10
10
|
return Spec::Matchers::PositiveOperatorMatcher.new actual
|
11
|
+
else
|
12
|
+
match = matcher.matches?(actual, &block)
|
13
|
+
return match if match
|
14
|
+
|
15
|
+
Spec::Expectations.fail_with matcher.failure_message_for_should
|
16
|
+
nil
|
11
17
|
end
|
12
18
|
end
|
13
19
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'ospec/matchers/operator_matcher'
|
2
2
|
require 'ospec/matchers/be'
|
3
3
|
require 'ospec/matchers/generated_descriptions'
|
4
|
+
require 'ospec/matchers/raise_error'
|
4
5
|
|
5
6
|
module Spec
|
6
7
|
|
7
8
|
module Matchers
|
8
9
|
|
9
10
|
class Matcher
|
10
|
-
|
11
|
-
# extend Spec::Matchers
|
11
|
+
include Spec::Matchers
|
12
12
|
|
13
13
|
# attr_reader :expected, :actual
|
14
14
|
|
File without changes
|
File without changes
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Spec
|
2
|
+
|
3
|
+
module Matchers
|
4
|
+
|
5
|
+
class RaiseError
|
6
|
+
|
7
|
+
def initialize(expected_error_or_message = Exception, expected_message = nil, &block)
|
8
|
+
@block = block
|
9
|
+
@actual_error = nil
|
10
|
+
@expected_exception = Exception
|
11
|
+
end
|
12
|
+
|
13
|
+
def matches?(given_proc)
|
14
|
+
@raised_expected_exception = false
|
15
|
+
@with_expected_message = false
|
16
|
+
|
17
|
+
begin
|
18
|
+
given_proc.call
|
19
|
+
rescue => e
|
20
|
+
@raised_expected_exception = true
|
21
|
+
end
|
22
|
+
|
23
|
+
@raised_expected_exception
|
24
|
+
end
|
25
|
+
|
26
|
+
def failure_message_for_should
|
27
|
+
"expected #{@expected_exception}, but nothing was raised"
|
28
|
+
end
|
29
|
+
end # RaiseError
|
30
|
+
|
31
|
+
def raise_error(error = Exception, message = nil, &block)
|
32
|
+
Spec::Matchers::RaiseError.new error, message, &block
|
33
|
+
end
|
34
|
+
|
35
|
+
alias_method :raise_exception, :raise_error
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
data/lib/ospec/runner.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'ospec/runner/options'
|
2
|
+
require 'ospec/runner/reporter'
|
3
|
+
require 'ospec/runner/example_group_runner'
|
4
|
+
|
5
|
+
require 'ospec/runner/formatter/html_formatter'
|
6
|
+
require 'ospec/runner/formatter/terminal_formatter'
|
7
|
+
|
8
|
+
module Spec
|
9
|
+
module Runner
|
10
|
+
|
11
|
+
def self.run
|
12
|
+
options.run_examples
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.options
|
16
|
+
@options ||= Options.new
|
17
|
+
@options
|
18
|
+
end
|
19
|
+
|
20
|
+
# Autorun for the browser. This differs from {.autorun} because it wraps
|
21
|
+
# itself in a setTimeout call to make sure the browser is ready as we
|
22
|
+
# start adding to the DOM as we run. This won't use rquery because its
|
23
|
+
# nice to keep everything independant, and someone might write a better
|
24
|
+
# DOM library. All the dom interactions are simply inline javascript.
|
25
|
+
def self.autorun_browser
|
26
|
+
`setTimeout(function() {`
|
27
|
+
specs = Dir["spec/**/*.{rb,js}"]
|
28
|
+
|
29
|
+
if specs.length == 0
|
30
|
+
puts "ospec: no input files given"
|
31
|
+
else
|
32
|
+
if File.exist? "spec/spec_helper.js"
|
33
|
+
require File.expand_path("spec/spec_helper.js")
|
34
|
+
end
|
35
|
+
|
36
|
+
specs.each do |spec|
|
37
|
+
require spec
|
38
|
+
end
|
39
|
+
# require specs[0]
|
40
|
+
# idx = 49
|
41
|
+
# puts idx
|
42
|
+
# `console.log(specs[idx]);`
|
43
|
+
# puts specs[idx]
|
44
|
+
# puts specs[idx]
|
45
|
+
# require specs[idx]
|
46
|
+
end
|
47
|
+
|
48
|
+
Spec::Runner.run
|
49
|
+
puts Spec::Runner.options.formatters
|
50
|
+
`}, 0);`
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
|
54
|
+
# Autorun gem/node context
|
55
|
+
def self.autorun
|
56
|
+
puts "in here"
|
57
|
+
puts ARGV.inspect
|
58
|
+
if ARGV.length == 0
|
59
|
+
specs = Dir["spec/**/*.{rb,js}"]
|
60
|
+
|
61
|
+
if specs.length == 0
|
62
|
+
puts "ospec: no input files given"
|
63
|
+
else
|
64
|
+
|
65
|
+
if File.exist? "spec/spec_helper.rb"
|
66
|
+
require File.expand_path "spec/spec_helper.rb"
|
67
|
+
end
|
68
|
+
|
69
|
+
specs.each do |spec|
|
70
|
+
require spec
|
71
|
+
end
|
72
|
+
end
|
73
|
+
# return
|
74
|
+
end
|
75
|
+
|
76
|
+
ARGV.each do |spec|
|
77
|
+
puts "should try and load #{spec}"
|
78
|
+
if File.exist? spec
|
79
|
+
puts "loading: " + File.expand_path(spec)
|
80
|
+
require File.expand_path(spec)
|
81
|
+
else
|
82
|
+
raise "Bad spec to load (does not exist): #{spec}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
Spec::Runner.run
|
87
|
+
end
|
88
|
+
|
89
|
+
end # Runner
|
90
|
+
end
|
@@ -1,44 +1,41 @@
|
|
1
|
-
module Spec
|
1
|
+
module Spec
|
2
2
|
module Runner
|
3
3
|
class ExampleGroupRunner
|
4
|
-
|
4
|
+
|
5
5
|
def initialize(options)
|
6
6
|
@options = options
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def run
|
10
10
|
prepare
|
11
|
-
# puts "RUNNING"
|
12
|
-
#`console.log(#{example_groups})`
|
13
11
|
example_groups.each do |group|
|
14
|
-
# puts "running group!"
|
15
|
-
#puts group
|
16
12
|
group.run @options
|
17
13
|
end
|
18
14
|
finish
|
19
15
|
end
|
20
|
-
|
16
|
+
|
21
17
|
def example_groups
|
22
18
|
@options.example_groups
|
23
19
|
end
|
24
|
-
|
20
|
+
|
25
21
|
def prepare
|
26
22
|
rep = reporter
|
27
23
|
rep.start number_of_examples
|
28
24
|
end
|
29
|
-
|
25
|
+
|
30
26
|
def finish
|
31
27
|
|
32
28
|
end
|
33
|
-
|
29
|
+
|
34
30
|
def reporter
|
35
31
|
@options.reporter
|
36
32
|
end
|
37
|
-
|
33
|
+
|
38
34
|
def number_of_examples
|
39
35
|
0
|
40
36
|
end
|
41
|
-
|
37
|
+
|
42
38
|
end # ExampleGroupRunner
|
43
39
|
end
|
44
40
|
end
|
41
|
+
|
@@ -0,0 +1,139 @@
|
|
1
|
+
module Spec
|
2
|
+
module Runner
|
3
|
+
module Formatter
|
4
|
+
class HtmlFormatter
|
5
|
+
|
6
|
+
attr_reader :example_group, :example_group_number
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
@options = options
|
10
|
+
@example_group_number = 0
|
11
|
+
@example_number = 0
|
12
|
+
@header_red = nil
|
13
|
+
|
14
|
+
setup_page_dom
|
15
|
+
end
|
16
|
+
|
17
|
+
##
|
18
|
+
# Get the DOM ready for output
|
19
|
+
#
|
20
|
+
def setup_page_dom
|
21
|
+
content = [
|
22
|
+
"<style>#{css_content}</style>",
|
23
|
+
'<div class="rspec-report">',
|
24
|
+
'<div id="rspec-header">',
|
25
|
+
'<div id="label">',
|
26
|
+
'<h1>Rspec Code Examples</h1>',
|
27
|
+
'</div>',
|
28
|
+
|
29
|
+
'<div id="summary">',
|
30
|
+
'<p id="totals">0</p>',
|
31
|
+
'<p id="duration">0</p>',
|
32
|
+
'</div>',
|
33
|
+
'</div>',
|
34
|
+
'<div id="results">',
|
35
|
+
'</div>',
|
36
|
+
'</div>'
|
37
|
+
].join ''
|
38
|
+
`var wrapper = document.createElement('div');
|
39
|
+
wrapper.id = "rspec-wrapper";
|
40
|
+
wrapper.innerHTML = content;
|
41
|
+
document.getElementsByTagName('body')[0].appendChild(wrapper);`
|
42
|
+
`self.$results = document.getElementById('results');`
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def css_content
|
47
|
+
'body{ margin:0px; padding:0px; background:white; font-size:80%}#rspec-header{ background:#65C400;color:#fff;height:4em}.rspec-report h1{ margin:0px 10px 0px 10px; padding:10px; font-family:"Lucida Grande",Helvetica,sans-serif; font-size:1.8em; position:absolute}#summary{ margin:0;padding:5px 10px; font-family:"Lucida Grande",Helvetica,sans-serif; text-align:right; top:0px; right:0px; float:right}#summary p{ margin:0 0 0 2px}#summary #totals{ font-size:1.2em}#results{}.example_group{ margin:0 10px 5px; background:#fff}dl{ margin:0;padding:0 0 5px; font:normal 11px "Lucida Grande",Helvetica,sans-serif}dt{ padding:3px; background:#65C400; color:#fff; font-weight:bold}dd{ margin:5px 0 5px 5px; padding:3px 3px 3px 18px}dd.spec.passed{ border-left:5px solid #65C400; border-bottom:1px solid #65C400; background:#DBFFB4;color:#3D7700}dd.spec.failed{ border-left:5px solid #C20000; border-bottom:1px solid #C20000; color:#C20000;background:#FFFBD3}dd.spec.not_implemented{ border-left:5px solid #FAF834; border-bottom:1px solid #FAF834; background:#FCFB98;color:#131313}dd.spec.pending_fixed{ border-left:5px solid #0000C2; border-bottom:1px solid #0000C2; color:#0000C2;background:#D3FBFF}.backtrace{ color:#000; font-size:12px}a{ color:#BE5C00}.ruby{ font-size:12px; font-family:monospace; color:white; background-color:black; padding:0.1em 0 0.2em 0}.ruby .keyword{color:#F60}.ruby .constant{color:#399}.ruby .attribute{color:white}.ruby .global{color:white}.ruby .module{color:white}.ruby .class{color:white}.ruby .string{color:#6F0}.ruby .ident{color:white}.ruby .method{color:#FC0}.ruby .number{color:white}.ruby .char{color:white}.ruby .comment{color:#93C}.ruby .symbol{color:white}.ruby .regex{color:#44B4CC}.ruby .punct{color:white}.ruby .escape{color:white}.ruby .interp{color:white}.ruby .expr{color:white}.ruby .offending{background-color:gray}.ruby .linenum{ width:75px; padding:0.1em 1em 0.2em 0; color:#000; background-color:#FFFBD3}'
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def start(number_of_examples)
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def end
|
56
|
+
@end_time = Time.now
|
57
|
+
end
|
58
|
+
|
59
|
+
def example_group_started(example_group)
|
60
|
+
@example_group = example_group
|
61
|
+
@example_group_red = false
|
62
|
+
@example_group_number += 1
|
63
|
+
|
64
|
+
# @example_group_div = results_output.div :class_name => "example_group"
|
65
|
+
# @example_group_dl = @example_group_div.dl
|
66
|
+
# @example_group_dt = @example_group_dl.dt :content => example_group.description, :id => "example_group_#{example_group_number}"
|
67
|
+
|
68
|
+
`var div = self.$example_div = document.createElement('div');
|
69
|
+
div.className = 'example_group';
|
70
|
+
|
71
|
+
var dl = self.$example_dl = document.createElement('dl');
|
72
|
+
div.appendChild(dl);
|
73
|
+
|
74
|
+
var dt = self.$example_dt = document.createElement('dt');
|
75
|
+
dt.innerHTML = #{example_group.description};
|
76
|
+
dt.id = "element_group_" + #{@element_group_number.to_s};
|
77
|
+
dl.appendChild(dt);
|
78
|
+
|
79
|
+
self.$results.appendChild(div);`
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
def example_started(example)
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
def example_failed(example, counter, failure)
|
88
|
+
@header_red = true
|
89
|
+
@example_group_red = true
|
90
|
+
|
91
|
+
`var dd = document.createElement('dd');
|
92
|
+
dd.className = "spec failed";
|
93
|
+
|
94
|
+
var span = document.createElement('span');
|
95
|
+
span.innerHTML = #{example.description};
|
96
|
+
span.className = "failed_spec_name";
|
97
|
+
dd.appendChild(span);
|
98
|
+
|
99
|
+
self.$example_dl.appendChild(dd);
|
100
|
+
|
101
|
+
var failure_div = document.createElement('div');
|
102
|
+
failure_div.className = "failure";
|
103
|
+
|
104
|
+
var msg = document.createElement('div');
|
105
|
+
msg.className = "message";
|
106
|
+
|
107
|
+
var pre = document.createElement('pre');
|
108
|
+
pre.innerHTML = #{failure.exception.message};
|
109
|
+
msg.appendChild(pre);
|
110
|
+
|
111
|
+
failure_div.appendChild(msg);
|
112
|
+
dd.appendChild(failure_div);`
|
113
|
+
|
114
|
+
nil
|
115
|
+
end
|
116
|
+
|
117
|
+
def example_passed(example)
|
118
|
+
`var dl = self.$example_dl;
|
119
|
+
|
120
|
+
var dd = document.createElement('dd');
|
121
|
+
dd.className = "spec passed";
|
122
|
+
|
123
|
+
var span = document.createElement('span');
|
124
|
+
dd.appendChild(span);
|
125
|
+
span.innerHTML = #{example.description.to_s};
|
126
|
+
span.className = "passed_spec_name";
|
127
|
+
|
128
|
+
dl.appendChild(dd);`
|
129
|
+
nil
|
130
|
+
end
|
131
|
+
|
132
|
+
def example_pending(example, message)
|
133
|
+
# @example_group_dl.dd(:class_name => "spec not_implemented").span(:content => "#{example.description} (PENDING: #{message})", :class_name => "not_implemented_spec_name")
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|