opal-rspec 0.0.1.beta1 → 0.0.1.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +21 -35
- data/Rakefile +3 -0
- data/app/rspec-builder.rb +32 -1
- data/lib/opal/rspec/version.rb +1 -1
- data/opal/opal/rspec/async.rb +129 -0
- data/opal/opal/rspec/fixes.rb +3 -1
- data/opal/opal/rspec/rspec.js +422 -5834
- data/opal/opal/rspec/runner.rb +27 -10
- data/opal/opal/rspec.rb +5 -0
- data/spec/async_spec.rb +39 -0
- data/spec/example_spec.rb +10 -0
- metadata +4 -9
- data/app/rspec/core/configuration.rb +0 -1070
- data/app/rspec/core/example_group.rb +0 -573
- data/app/rspec/core/project_initializer.rb +0 -0
- data/app/rspec/core/shared_example_group/collection.rb +0 -27
- data/app/rspec/core/shared_example_group.rb +0 -146
- data/app/rspec/core.rb +0 -202
- data/app/rspec/matchers/built_in/have.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa5a0b75048673c565e4c8d0b008dc55892a4ddd
|
4
|
+
data.tar.gz: 60bc477892cc5008bca2f1a766ed590d641ead54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0efbf01ddc93b6964063e6837f03d18bb2f59babbf41099e5f659f79350641b3de6f42b88ce6a6a3d7bc6f7405dec54f0c63d557a457cf5524a25561bcb03bd0
|
7
|
+
data.tar.gz: 9f616e0e0e61c5f6a0fe77c0dddfbb989d9cc5f617b1349c629d5d157d83ad09df27bf55dade95dd13681c94ffdb68644e158974100eda24ebed6a3f5f73fb57
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -35,44 +35,30 @@ Visit the page in any browser and view the console:
|
|
35
35
|
## Things to fix
|
36
36
|
|
37
37
|
`opal/opal-rspec/fixes.rb` contains a few bug fixes that need to be merged upstream
|
38
|
-
to opal itself.
|
38
|
+
to opal itself. `app/rspec-builder.rb` is used to precompile rspec ready to be used
|
39
|
+
in `opal-rspec`. All requires from `core.rb` have been inlined as opal cannot require
|
40
|
+
dynamically at runtime.
|
39
41
|
|
40
|
-
|
42
|
+
## License
|
41
43
|
|
42
|
-
|
43
|
-
opal has to include all dependencies into build.
|
44
|
+
(The MIT License)
|
44
45
|
|
45
|
-
|
46
|
+
Copyright (C) 2013 by Adam Beynon
|
46
47
|
|
47
|
-
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
49
|
+
of this software and associated documentation files (the "Software"), to deal
|
50
|
+
in the Software without restriction, including without limitation the rights
|
51
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
52
|
+
copies of the Software, and to permit persons to whom the Software is
|
53
|
+
furnished to do so, subject to the following conditions:
|
48
54
|
|
49
|
-
|
55
|
+
The above copyright notice and this permission notice shall be included in
|
56
|
+
all copies or substantial portions of the Software.
|
50
57
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
* **line 547**: opal cannot use mutable strings (see opal/rspec/fixes.rb)
|
60
|
-
|
61
|
-
* **line 564**: opal cannot use mutable strings (see opal/rspec/fixes.rb)
|
62
|
-
|
63
|
-
### rspec/core/project_initializer.rb
|
64
|
-
|
65
|
-
* **line 1**: opal cannot parse these heredocs (EOS used before last line of string)
|
66
|
-
|
67
|
-
### rspec/core/shared_example_group.rb
|
68
|
-
|
69
|
-
* **line 112**: opal cannot parse this heredoc
|
70
|
-
|
71
|
-
### rspec/core/shared_example_group/collection.rb
|
72
|
-
|
73
|
-
* **line 17**: opal cannot parse command call inside aref
|
74
|
-
|
75
|
-
### rspec/matchers/built_in/have.rb
|
76
|
-
|
77
|
-
* **line 1**: this is an error in rspec. This autoload does not exist so we must
|
78
|
-
stub the file.
|
58
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
59
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
60
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
61
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
62
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
63
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
64
|
+
THE SOFTWARE.
|
data/Rakefile
CHANGED
data/app/rspec-builder.rb
CHANGED
@@ -1,6 +1,37 @@
|
|
1
|
+
require 'set'
|
2
|
+
require 'time'
|
3
|
+
require 'rbconfig'
|
4
|
+
|
1
5
|
require 'rspec/support'
|
6
|
+
|
7
|
+
require 'rspec/core/version'
|
8
|
+
|
9
|
+
require 'rspec/support/caller_filter'
|
10
|
+
|
11
|
+
require 'rspec/core/flat_map'
|
12
|
+
require 'rspec/core/filter_manager'
|
13
|
+
require 'rspec/core/dsl'
|
14
|
+
require 'rspec/core/warnings'
|
15
|
+
require 'rspec/core/reporter'
|
16
|
+
|
17
|
+
require 'rspec/core/hooks'
|
18
|
+
require 'rspec/core/memoized_helpers'
|
19
|
+
require 'rspec/core/metadata'
|
20
|
+
require 'rspec/core/pending'
|
21
|
+
require 'rspec/core/formatters'
|
22
|
+
require 'rspec/core/ordering'
|
23
|
+
|
24
|
+
require 'rspec/core/world'
|
25
|
+
require 'rspec/core/configuration'
|
26
|
+
require 'rspec/core/option_parser'
|
27
|
+
require 'rspec/core/configuration_options'
|
28
|
+
require 'rspec/core/command_line'
|
29
|
+
require 'rspec/core/runner'
|
30
|
+
require 'rspec/core/example'
|
31
|
+
require 'rspec/core/shared_example_group/collection'
|
32
|
+
require 'rspec/core/shared_example_group'
|
33
|
+
require 'rspec/core/example_group'
|
2
34
|
require 'rspec/core'
|
3
|
-
require 'rspec/mocks'
|
4
35
|
require 'rspec-expectations'
|
5
36
|
|
6
37
|
# we want access to BaseFormatter
|
data/lib/opal/rspec/version.rb
CHANGED
@@ -0,0 +1,129 @@
|
|
1
|
+
module Opal
|
2
|
+
module RSpec
|
3
|
+
module AsyncDefinitions
|
4
|
+
def async(desc, *args, &block)
|
5
|
+
options = ::RSpec::Core::Metadata.build_hash_from(args)
|
6
|
+
Opal::RSpec::AsyncExample.register(self, desc, options, block)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module AsyncHelpers
|
11
|
+
def run_async(&block)
|
12
|
+
::RSpec.current_example.continue_async(block)
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_timeout(duration, &block)
|
16
|
+
`setTimeout(block, duration)`
|
17
|
+
self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class AsyncRunner
|
22
|
+
def initialize(runner, reporter, finish_block)
|
23
|
+
@runner = runner
|
24
|
+
@reporter = reporter
|
25
|
+
@finish_block = finish_block
|
26
|
+
end
|
27
|
+
|
28
|
+
def run
|
29
|
+
@examples = AsyncExample.examples.clone
|
30
|
+
run_next_example
|
31
|
+
end
|
32
|
+
|
33
|
+
def run_next_example
|
34
|
+
if @examples.empty?
|
35
|
+
finish
|
36
|
+
else
|
37
|
+
run_example @examples.pop
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def run_example(example)
|
42
|
+
example_group = example.example_group
|
43
|
+
|
44
|
+
@reporter.example_group_started example_group
|
45
|
+
instance = example_group.new
|
46
|
+
|
47
|
+
example.run(instance, @reporter) do
|
48
|
+
example_finished example
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def example_finished(example)
|
53
|
+
@reporter.example_group_finished example.example_group
|
54
|
+
run_next_example
|
55
|
+
end
|
56
|
+
|
57
|
+
# Called once all examples have finished. Just calls back to main
|
58
|
+
# runner to inform it
|
59
|
+
def finish
|
60
|
+
@finish_block.call
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class AsyncExample < ::RSpec::Core::Example
|
65
|
+
def self.register(*args)
|
66
|
+
examples << new(*args)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.examples
|
70
|
+
@examples ||= []
|
71
|
+
end
|
72
|
+
|
73
|
+
def run(example_group_instance, reporter, &after_run_block)
|
74
|
+
@example_group_instance = example_group_instance
|
75
|
+
@reporter = reporter
|
76
|
+
@after_run_block = after_run_block
|
77
|
+
|
78
|
+
should_wait = true
|
79
|
+
|
80
|
+
::RSpec.current_example = self
|
81
|
+
|
82
|
+
start(reporter)
|
83
|
+
|
84
|
+
begin
|
85
|
+
run_before_each
|
86
|
+
@example_group_instance.instance_exec(self, &@example_block)
|
87
|
+
rescue Exception => e
|
88
|
+
set_exception(e)
|
89
|
+
should_wait = false
|
90
|
+
end
|
91
|
+
|
92
|
+
async_example_finished unless should_wait
|
93
|
+
end
|
94
|
+
|
95
|
+
def continue_async(block)
|
96
|
+
begin
|
97
|
+
block.call
|
98
|
+
rescue Exception => e
|
99
|
+
set_exception(e)
|
100
|
+
end
|
101
|
+
|
102
|
+
async_example_finished
|
103
|
+
end
|
104
|
+
|
105
|
+
def async_example_finished
|
106
|
+
begin
|
107
|
+
run_after_each
|
108
|
+
rescue Exception => e
|
109
|
+
set_exception(e)
|
110
|
+
ensure
|
111
|
+
@example_group_instance.instance_variables.each do |ivar|
|
112
|
+
@example_group_instance.instance_variable_set(ivar, nil)
|
113
|
+
end
|
114
|
+
@example_group_instance = nil
|
115
|
+
|
116
|
+
begin
|
117
|
+
assign_generated_description
|
118
|
+
rescue Exception => e
|
119
|
+
set_exception(e, "while assigning the example description")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
finish(@reporter)
|
124
|
+
::RSpec.current_example = nil
|
125
|
+
@after_run_block.call
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
data/opal/opal/rspec/fixes.rb
CHANGED
@@ -31,6 +31,7 @@ class RSpec::Matchers::BuiltIn::BePredicate
|
|
31
31
|
end
|
32
32
|
|
33
33
|
module RSpec::ExampleGroups
|
34
|
+
# opal cannot use mutable strings AND opal doesnt support `\A` or `\z` anchors
|
34
35
|
def self.base_name_for(group)
|
35
36
|
return "Anonymous" if group.description.empty?
|
36
37
|
|
@@ -43,11 +44,12 @@ module RSpec::ExampleGroups
|
|
43
44
|
|
44
45
|
# Ruby requires first const letter to be A-Z. Use `Nested`
|
45
46
|
# as necessary to enforce that.
|
46
|
-
name = name.gsub(
|
47
|
+
name = name.gsub(/^([^A-Z]|$)/, 'Nested$1')
|
47
48
|
|
48
49
|
name
|
49
50
|
end
|
50
51
|
|
52
|
+
# opal cannot use mutable strings
|
51
53
|
def self.disambiguate(name, const_scope)
|
52
54
|
return name unless const_scope.const_defined?(name)
|
53
55
|
|