opal-rspec 0.4.0.beta3 → 0.4.0.beta4
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.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.gitmodules +15 -0
- data/.travis.yml +12 -0
- data/.yardopts +5 -0
- data/CHANGELOG.md +3 -1
- data/Gemfile +6 -7
- data/README.md +2 -0
- data/Rakefile +12 -50
- data/lib/opal/rspec/version.rb +1 -1
- data/lib/opal/rspec.rb +14 -0
- data/opal/opal/rspec/async.rb +146 -11
- data/opal/opal/rspec/fixes.rb +18 -8
- data/opal/opal/rspec/requires.rb +45 -0
- data/opal/opal/rspec.rb +1 -24
- data/opal-rspec.gemspec +1 -1
- data/spec/async_spec.rb +4 -5
- data/spec/matchers_spec.rb +20 -0
- data/spec/named_subject_spec.rb +11 -0
- data/spec/should_syntax_spec.rb +17 -0
- data/vendor_lib/rspec/autorun.rb +2 -0
- data/vendor_lib/rspec/core/backport_random.rb +302 -0
- data/vendor_lib/rspec/core/backtrace_formatter.rb +65 -0
- data/vendor_lib/rspec/core/command_line.rb +36 -0
- data/vendor_lib/rspec/core/configuration.rb +1129 -0
- data/vendor_lib/rspec/core/configuration_options.rb +143 -0
- data/vendor_lib/rspec/core/drb_command_line.rb +26 -0
- data/vendor_lib/rspec/core/drb_options.rb +87 -0
- data/vendor_lib/rspec/core/dsl.rb +26 -0
- data/vendor_lib/rspec/core/example.rb +312 -0
- data/vendor_lib/rspec/core/example_group.rb +540 -0
- data/vendor_lib/rspec/core/filter_manager.rb +224 -0
- data/vendor_lib/rspec/core/flat_map.rb +17 -0
- data/vendor_lib/rspec/core/formatters/base_formatter.rb +291 -0
- data/vendor_lib/rspec/core/formatters/base_text_formatter.rb +307 -0
- data/vendor_lib/rspec/core/formatters/deprecation_formatter.rb +193 -0
- data/vendor_lib/rspec/core/formatters/documentation_formatter.rb +67 -0
- data/vendor_lib/rspec/core/formatters/helpers.rb +82 -0
- data/vendor_lib/rspec/core/formatters/html_formatter.rb +155 -0
- data/vendor_lib/rspec/core/formatters/html_printer.rb +408 -0
- data/vendor_lib/rspec/core/formatters/json_formatter.rb +99 -0
- data/vendor_lib/rspec/core/formatters/progress_formatter.rb +32 -0
- data/vendor_lib/rspec/core/formatters/snippet_extractor.rb +101 -0
- data/vendor_lib/rspec/core/formatters.rb +54 -0
- data/vendor_lib/rspec/core/hooks.rb +535 -0
- data/vendor_lib/rspec/core/memoized_helpers.rb +431 -0
- data/vendor_lib/rspec/core/metadata.rb +313 -0
- data/vendor_lib/rspec/core/mocking/with_absolutely_nothing.rb +11 -0
- data/vendor_lib/rspec/core/mocking/with_flexmock.rb +27 -0
- data/vendor_lib/rspec/core/mocking/with_mocha.rb +52 -0
- data/vendor_lib/rspec/core/mocking/with_rr.rb +27 -0
- data/vendor_lib/rspec/core/mocking/with_rspec.rb +27 -0
- data/vendor_lib/rspec/core/option_parser.rb +234 -0
- data/vendor_lib/rspec/core/ordering.rb +154 -0
- data/vendor_lib/rspec/core/pending.rb +110 -0
- data/vendor_lib/rspec/core/project_initializer.rb +88 -0
- data/vendor_lib/rspec/core/rake_task.rb +128 -0
- data/vendor_lib/rspec/core/reporter.rb +132 -0
- data/vendor_lib/rspec/core/ruby_project.rb +44 -0
- data/vendor_lib/rspec/core/runner.rb +97 -0
- data/vendor_lib/rspec/core/shared_context.rb +53 -0
- data/vendor_lib/rspec/core/shared_example_group/collection.rb +27 -0
- data/vendor_lib/rspec/core/shared_example_group.rb +146 -0
- data/vendor_lib/rspec/core/version.rb +7 -0
- data/vendor_lib/rspec/core/warnings.rb +22 -0
- data/vendor_lib/rspec/core/world.rb +131 -0
- data/vendor_lib/rspec/core.rb +203 -0
- data/vendor_lib/rspec/expectations/differ.rb +154 -0
- data/vendor_lib/rspec/expectations/errors.rb +9 -0
- data/vendor_lib/rspec/expectations/expectation_target.rb +87 -0
- data/vendor_lib/rspec/expectations/extensions/object.rb +29 -0
- data/vendor_lib/rspec/expectations/extensions.rb +1 -0
- data/vendor_lib/rspec/expectations/fail_with.rb +79 -0
- data/vendor_lib/rspec/expectations/handler.rb +68 -0
- data/vendor_lib/rspec/expectations/syntax.rb +182 -0
- data/vendor_lib/rspec/expectations/version.rb +8 -0
- data/vendor_lib/rspec/expectations.rb +75 -0
- data/vendor_lib/rspec/matchers/built_in/base_matcher.rb +68 -0
- data/vendor_lib/rspec/matchers/built_in/be.rb +213 -0
- data/vendor_lib/rspec/matchers/built_in/be_instance_of.rb +15 -0
- data/vendor_lib/rspec/matchers/built_in/be_kind_of.rb +11 -0
- data/vendor_lib/rspec/matchers/built_in/be_within.rb +55 -0
- data/vendor_lib/rspec/matchers/built_in/change.rb +141 -0
- data/vendor_lib/rspec/matchers/built_in/cover.rb +21 -0
- data/vendor_lib/rspec/matchers/built_in/eq.rb +22 -0
- data/vendor_lib/rspec/matchers/built_in/eql.rb +23 -0
- data/vendor_lib/rspec/matchers/built_in/equal.rb +48 -0
- data/vendor_lib/rspec/matchers/built_in/exist.rb +26 -0
- data/vendor_lib/rspec/matchers/built_in/has.rb +48 -0
- data/vendor_lib/rspec/matchers/built_in/include.rb +61 -0
- data/vendor_lib/rspec/matchers/built_in/match.rb +17 -0
- data/vendor_lib/rspec/matchers/built_in/match_array.rb +51 -0
- data/vendor_lib/rspec/matchers/built_in/raise_error.rb +154 -0
- data/vendor_lib/rspec/matchers/built_in/respond_to.rb +74 -0
- data/vendor_lib/rspec/matchers/built_in/satisfy.rb +30 -0
- data/vendor_lib/rspec/matchers/built_in/start_and_end_with.rb +48 -0
- data/vendor_lib/rspec/matchers/built_in/throw_symbol.rb +94 -0
- data/vendor_lib/rspec/matchers/built_in/yield.rb +297 -0
- data/vendor_lib/rspec/matchers/built_in.rb +39 -0
- data/vendor_lib/rspec/matchers/compatibility.rb +14 -0
- data/vendor_lib/rspec/matchers/configuration.rb +113 -0
- data/vendor_lib/rspec/matchers/dsl.rb +23 -0
- data/vendor_lib/rspec/matchers/generated_descriptions.rb +35 -0
- data/vendor_lib/rspec/matchers/matcher.rb +301 -0
- data/vendor_lib/rspec/matchers/method_missing.rb +12 -0
- data/vendor_lib/rspec/matchers/operator_matcher.rb +99 -0
- data/vendor_lib/rspec/matchers/pretty.rb +70 -0
- data/vendor_lib/rspec/matchers/test_unit_integration.rb +11 -0
- data/vendor_lib/rspec/matchers.rb +633 -0
- data/vendor_lib/rspec/mocks/any_instance/chain.rb +92 -0
- data/vendor_lib/rspec/mocks/any_instance/expectation_chain.rb +47 -0
- data/vendor_lib/rspec/mocks/any_instance/message_chains.rb +75 -0
- data/vendor_lib/rspec/mocks/any_instance/recorder.rb +200 -0
- data/vendor_lib/rspec/mocks/any_instance/stub_chain.rb +45 -0
- data/vendor_lib/rspec/mocks/any_instance/stub_chain_chain.rb +23 -0
- data/vendor_lib/rspec/mocks/argument_list_matcher.rb +104 -0
- data/vendor_lib/rspec/mocks/argument_matchers.rb +264 -0
- data/vendor_lib/rspec/mocks/arity_calculator.rb +66 -0
- data/vendor_lib/rspec/mocks/configuration.rb +111 -0
- data/vendor_lib/rspec/mocks/error_generator.rb +203 -0
- data/vendor_lib/rspec/mocks/errors.rb +12 -0
- data/vendor_lib/rspec/mocks/example_methods.rb +201 -0
- data/vendor_lib/rspec/mocks/extensions/marshal.rb +17 -0
- data/vendor_lib/rspec/mocks/framework.rb +36 -0
- data/vendor_lib/rspec/mocks/instance_method_stasher.rb +112 -0
- data/vendor_lib/rspec/mocks/matchers/have_received.rb +99 -0
- data/vendor_lib/rspec/mocks/matchers/receive.rb +112 -0
- data/vendor_lib/rspec/mocks/matchers/receive_messages.rb +72 -0
- data/vendor_lib/rspec/mocks/message_expectation.rb +643 -0
- data/vendor_lib/rspec/mocks/method_double.rb +209 -0
- data/vendor_lib/rspec/mocks/method_reference.rb +95 -0
- data/vendor_lib/rspec/mocks/mock.rb +7 -0
- data/vendor_lib/rspec/mocks/mutate_const.rb +406 -0
- data/vendor_lib/rspec/mocks/object_reference.rb +90 -0
- data/vendor_lib/rspec/mocks/order_group.rb +82 -0
- data/vendor_lib/rspec/mocks/proxy.rb +269 -0
- data/vendor_lib/rspec/mocks/proxy_for_nil.rb +37 -0
- data/vendor_lib/rspec/mocks/space.rb +95 -0
- data/vendor_lib/rspec/mocks/standalone.rb +3 -0
- data/vendor_lib/rspec/mocks/stub_chain.rb +51 -0
- data/vendor_lib/rspec/mocks/syntax.rb +374 -0
- data/vendor_lib/rspec/mocks/targets.rb +90 -0
- data/vendor_lib/rspec/mocks/test_double.rb +109 -0
- data/vendor_lib/rspec/mocks/verifying_double.rb +77 -0
- data/vendor_lib/rspec/mocks/verifying_message_expecation.rb +60 -0
- data/vendor_lib/rspec/mocks/verifying_proxy.rb +151 -0
- data/vendor_lib/rspec/mocks/version.rb +7 -0
- data/vendor_lib/rspec/mocks.rb +100 -0
- data/vendor_lib/rspec/support/caller_filter.rb +56 -0
- data/vendor_lib/rspec/support/spec/deprecation_helpers.rb +29 -0
- data/vendor_lib/rspec/support/spec/in_sub_process.rb +40 -0
- data/vendor_lib/rspec/support/spec/stderr_splitter.rb +50 -0
- data/vendor_lib/rspec/support/spec.rb +14 -0
- data/vendor_lib/rspec/support/version.rb +7 -0
- data/vendor_lib/rspec/support/warnings.rb +41 -0
- data/vendor_lib/rspec/support.rb +6 -0
- data/vendor_lib/rspec/version.rb +5 -0
- data/vendor_lib/rspec-expectations.rb +1 -0
- data/vendor_lib/rspec.rb +3 -0
- metadata +163 -4
- data/opal/opal/rspec/rspec.js +0 -20384
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b6ec1f1110451f412a61b923b32d640e293e2929
|
|
4
|
+
data.tar.gz: 6aebaf694d03562bc10ff99c956dc53c7cb36155
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1f07f2a9acaa17631c66fa1455670f07d7f05641786e4df60d1641d853818cc2b2ecc17e3379f4e068789ecde5a1df077f076685a9aef09bf8e82570c64ebfac
|
|
7
|
+
data.tar.gz: 06559b78e1349be1765b9a14047f1b290e113b8a435c87fb02fd5c026e23676ad82892e15b3527a0ee27b3739bcfb4dc98aa7487fe892c4e2addd17dc38a1ab3
|
data/.gitignore
CHANGED
data/.gitmodules
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[submodule "rspec"]
|
|
2
|
+
path = rspec
|
|
3
|
+
url = https://github.com/rspec/rspec.git
|
|
4
|
+
[submodule "rspec-support"]
|
|
5
|
+
path = rspec-support
|
|
6
|
+
url = https://github.com/rspec/rspec-support.git
|
|
7
|
+
[submodule "rspec-core"]
|
|
8
|
+
path = rspec-core
|
|
9
|
+
url = https://github.com/rspec/rspec-core.git
|
|
10
|
+
[submodule "rspec-mocks"]
|
|
11
|
+
path = rspec-mocks
|
|
12
|
+
url = https://github.com/rspec/rspec-mocks.git
|
|
13
|
+
[submodule "rspec-expectations"]
|
|
14
|
+
path = rspec-expectations
|
|
15
|
+
url = https://github.com/rspec/rspec-expectations.git
|
data/.travis.yml
ADDED
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
## edge
|
|
2
2
|
|
|
3
|
+
* Remove predicate matcher fixes as Opal supports $1..$9 special gvars.
|
|
4
|
+
|
|
3
5
|
* Update Opal dependency for ~> 0.6.0.
|
|
4
6
|
|
|
5
7
|
* Remove double-escaping in inline x-strings (from Opal bug fix).
|
|
@@ -10,4 +12,4 @@
|
|
|
10
12
|
|
|
11
13
|
* Add timeout support to asynchronous specs
|
|
12
14
|
|
|
13
|
-
## 0.2.1 2013
|
|
15
|
+
## 0.2.1 November 24, 2013
|
data/Gemfile
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
gemspec
|
|
3
3
|
|
|
4
|
-
gem 'opal', github
|
|
5
|
-
# gem 'opal', path: '../opal'
|
|
4
|
+
gem 'opal', :github => 'opal/opal'
|
|
6
5
|
|
|
7
|
-
gem 'rspec', '
|
|
8
|
-
gem 'rspec-support', '
|
|
9
|
-
gem 'rspec-core', '
|
|
10
|
-
gem 'rspec-mocks', '
|
|
11
|
-
gem 'rspec-expectations', '
|
|
6
|
+
gem 'rspec', :path => 'rspec'
|
|
7
|
+
gem 'rspec-support', :path => 'rspec-support'
|
|
8
|
+
gem 'rspec-core', :path => 'rspec-core'
|
|
9
|
+
gem 'rspec-mocks', :path => 'rspec-mocks'
|
|
10
|
+
gem 'rspec-expectations', :path => 'rspec-expectations'
|
data/README.md
CHANGED
data/Rakefile
CHANGED
|
@@ -1,64 +1,26 @@
|
|
|
1
1
|
require 'bundler'
|
|
2
2
|
Bundler.require
|
|
3
|
+
|
|
3
4
|
Bundler::GemHelper.install_tasks
|
|
4
5
|
|
|
5
6
|
require 'opal/rspec/rake_task'
|
|
6
7
|
Opal::RSpec::RakeTask.new(:default)
|
|
7
8
|
|
|
8
|
-
desc "Build opal/opal/rspec/rspec.js"
|
|
9
|
-
task :dist do
|
|
10
|
-
File.open('opal/opal/rspec/rspec.js', 'w+') do |out|
|
|
11
|
-
out << build_rspec
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
task :build => :dist
|
|
15
|
-
|
|
16
|
-
desc "Show dev/min sizes"
|
|
17
|
-
task :sizes do
|
|
18
|
-
code = build_rspec
|
|
19
|
-
min = uglify code
|
|
20
|
-
|
|
21
|
-
puts "\ndevelopment: #{code.size}, minified: #{min.size}"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def build_rspec
|
|
25
|
-
Opal::Processor.dynamic_require_severity = :warning
|
|
26
|
-
|
|
27
|
-
code = []
|
|
28
|
-
gems = %w(rspec rspec-core rspec-support rspec-expectations rspec-mocks)
|
|
29
9
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
10
|
+
require 'fileutils'
|
|
11
|
+
desc "Copy RSpec sources"
|
|
12
|
+
task :copy_rspec do
|
|
13
|
+
gems = %w(rspec rspec-core rspec-expectations rspec-mocks rspec-support)
|
|
34
14
|
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
gems.each do |gem|
|
|
16
|
+
spec = Gem::Specification.find_by_name gem
|
|
17
|
+
lib = File.join spec.gem_dir, 'lib'
|
|
37
18
|
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
Dir["#{lib}/**/*.rb"].each do |file|
|
|
20
|
+
out = file.sub(/^#{lib}\//, 'opal/')
|
|
40
21
|
|
|
41
|
-
|
|
22
|
+
FileUtils.mkdir_p File.dirname(out)
|
|
23
|
+
FileUtils.cp file, out
|
|
42
24
|
end
|
|
43
25
|
end
|
|
44
|
-
|
|
45
|
-
stubs = %w(shellwords fileutils optparse)
|
|
46
|
-
|
|
47
|
-
stubs.each do |stub|
|
|
48
|
-
compiler = Opal::Compiler.new '', requirable: true, file: stub
|
|
49
|
-
code << compiler.compile
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
code.join "\n"
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def uglify(str)
|
|
56
|
-
IO.popen('uglifyjs', 'r+') do |i|
|
|
57
|
-
i.puts str
|
|
58
|
-
i.close_write
|
|
59
|
-
return i.read
|
|
60
|
-
end
|
|
61
|
-
rescue Errno::ENOENT
|
|
62
|
-
$stderr.puts '"uglifyjs" command not found (install with: "npm install -g uglify-js")'
|
|
63
|
-
nil
|
|
64
26
|
end
|
data/lib/opal/rspec/version.rb
CHANGED
data/lib/opal/rspec.rb
CHANGED
|
@@ -3,4 +3,18 @@ require 'opal/rspec/version'
|
|
|
3
3
|
|
|
4
4
|
# Just register our opal code path with opal build tools
|
|
5
5
|
Opal.append_path File.expand_path('../../../opal', __FILE__)
|
|
6
|
+
Opal.append_path File.expand_path('../../../vendor_lib', __FILE__)
|
|
6
7
|
|
|
8
|
+
Opal::Processor.dynamic_require_severity = :warning
|
|
9
|
+
|
|
10
|
+
Opal::Processor.stub_file "rspec/matchers/built_in/have"
|
|
11
|
+
Opal::Processor.stub_file "diff/lcs"
|
|
12
|
+
Opal::Processor.stub_file "diff/lcs/hunk"
|
|
13
|
+
Opal::Processor.stub_file "fileutils"
|
|
14
|
+
Opal::Processor.stub_file "test/unit/assertions"
|
|
15
|
+
Opal::Processor.stub_file "coderay"
|
|
16
|
+
Opal::Processor.stub_file "optparse"
|
|
17
|
+
Opal::Processor.stub_file "shellwords"
|
|
18
|
+
Opal::Processor.stub_file "socket"
|
|
19
|
+
Opal::Processor.stub_file "uri"
|
|
20
|
+
Opal::Processor.stub_file "drb/drb"
|
data/opal/opal/rspec/async.rb
CHANGED
|
@@ -1,27 +1,148 @@
|
|
|
1
1
|
module Opal
|
|
2
2
|
module RSpec
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
# {AsyncHelpers} is automatically included in all example groups to add
|
|
4
|
+
# support for running specs async. Usually, rspec runners expect all
|
|
5
|
+
# examples to run synchronously, but this is not ideal in the case for
|
|
6
|
+
# Opal where a lot of underlying libraries expect the ability to run code
|
|
7
|
+
# in an asynchronous manner.
|
|
8
|
+
#
|
|
9
|
+
# This module defines an {AsyncHelpers::ClassMethods.async} method which
|
|
10
|
+
# can be used instead of `it` inside an example group, which marks the
|
|
11
|
+
# example as being async. This makes the runner wait for the example to
|
|
12
|
+
# complete.
|
|
13
|
+
#
|
|
14
|
+
# describe "Some examples" do
|
|
15
|
+
# it "normal example" do
|
|
16
|
+
# # normal test code
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
# async "async example" do
|
|
20
|
+
# # this will wait until completion before moving on
|
|
21
|
+
# end
|
|
22
|
+
# end
|
|
23
|
+
#
|
|
24
|
+
# Marking an example as being async is only half the task. Examples will
|
|
25
|
+
# also have an instance {AsyncHelpers#async} method defined which is then
|
|
26
|
+
# used to complete the example. Any code run inside this block will run
|
|
27
|
+
# inside the context of the example.
|
|
28
|
+
#
|
|
29
|
+
# describe "HTTP requests" do
|
|
30
|
+
# async "might take a while" do
|
|
31
|
+
# HTTP.get("/url/to/get") do |res|
|
|
32
|
+
# async { expect(res).to be_ok }
|
|
33
|
+
# end
|
|
34
|
+
# end
|
|
35
|
+
# end
|
|
36
|
+
#
|
|
37
|
+
# As soon as `async` is run inside the block, the example completes. This
|
|
38
|
+
# means that only 1 `async` call is allowed. However, you can use `async`
|
|
39
|
+
# multiple times aslong as it is only called once:
|
|
40
|
+
#
|
|
41
|
+
# describe "HTTP requests" do
|
|
42
|
+
# async "should work" do
|
|
43
|
+
# HTTP.get("/users/1").then |res|
|
|
44
|
+
# async { expect(res).to be_ok }
|
|
45
|
+
# end.fail do
|
|
46
|
+
# async { raise "this should not be called" }
|
|
47
|
+
# end
|
|
48
|
+
# end
|
|
49
|
+
# end
|
|
50
|
+
#
|
|
51
|
+
# Here, a promise will either be accepted or rejected, so an `async` block
|
|
52
|
+
# can be used in each case as only 1 will be called.
|
|
53
|
+
#
|
|
54
|
+
# Another helper, {AsyncHelpers#delay} can also be used to run a block of
|
|
55
|
+
# code after a given time in seconds. This is useful to wait for animations
|
|
56
|
+
# or time restricted operations to occur.
|
|
57
|
+
module AsyncHelpers
|
|
58
|
+
module ClassMethods
|
|
59
|
+
# Define an async example method. This should be used instead of `it`
|
|
60
|
+
# to inform the spec runner that the example will need to wait for an
|
|
61
|
+
# {AsyncHelpers#async} method to complete the test. Any additional
|
|
62
|
+
# configuration options can be passed to this call, and they just get
|
|
63
|
+
# delegated to the underlying `#it` call.
|
|
64
|
+
#
|
|
65
|
+
# @example
|
|
66
|
+
# describe "Some tests" do
|
|
67
|
+
# async "should be async" do
|
|
68
|
+
# # ... async code
|
|
69
|
+
# end
|
|
70
|
+
#
|
|
71
|
+
# it "should work with normal tests" do
|
|
72
|
+
# expect(1).to eq(1)
|
|
73
|
+
# end
|
|
74
|
+
# end
|
|
75
|
+
#
|
|
76
|
+
# @param desc [String] description
|
|
77
|
+
def async(desc, *args, &block)
|
|
78
|
+
options = ::RSpec::Core::Metadata.build_hash_from(args)
|
|
79
|
+
Opal::RSpec::AsyncExample.register(self, desc, options, block)
|
|
80
|
+
end
|
|
7
81
|
end
|
|
8
|
-
end
|
|
9
82
|
|
|
10
|
-
|
|
83
|
+
def self.included(base)
|
|
84
|
+
base.extend ClassMethods
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Must be used with {ClassMethods#async} to finish the async action. If
|
|
88
|
+
# this is not called inside the body then the spec runner will time out
|
|
89
|
+
# or the error might give a false positive as it is not caught inside
|
|
90
|
+
# the current example.
|
|
91
|
+
#
|
|
92
|
+
# @example Complete expectation after HTTP request
|
|
93
|
+
# describe "HTTP calls" do
|
|
94
|
+
# async "complete eventually" do
|
|
95
|
+
# HTTP.get("/some_url") do |response|
|
|
96
|
+
# async { expect(response).to be_ok }
|
|
97
|
+
# end
|
|
98
|
+
# end
|
|
99
|
+
# end
|
|
100
|
+
#
|
|
11
101
|
def async(&block)
|
|
12
102
|
@example.continue_async(block)
|
|
13
103
|
end
|
|
14
104
|
|
|
15
|
-
|
|
16
|
-
|
|
105
|
+
# Runs the given block after a given duration. You are still required to
|
|
106
|
+
# use a {#async} block inside the delayed callback. This helper can be
|
|
107
|
+
# used to simulate IO delays, or just to wait for animations/other
|
|
108
|
+
# behaviour to finish.
|
|
109
|
+
#
|
|
110
|
+
# The `duaration` should be given in seconds, i.e. `1` means 1 second, or
|
|
111
|
+
# 0.3 means 300ms. The given block is just run after the time delay.
|
|
112
|
+
#
|
|
113
|
+
# @example
|
|
114
|
+
# describe "Some interaction" do
|
|
115
|
+
# async "takes a while to complete" do
|
|
116
|
+
# task = start_long_task!
|
|
117
|
+
#
|
|
118
|
+
# delay(1) do
|
|
119
|
+
# async { expect(task).to be_completed }
|
|
120
|
+
# end
|
|
121
|
+
# end
|
|
122
|
+
# end
|
|
123
|
+
#
|
|
124
|
+
# @param duration [Integer, Float] time in seconds to wait
|
|
17
125
|
def delay(duration, &block)
|
|
18
126
|
`setTimeout(block, duration * 1000)`
|
|
19
127
|
self
|
|
20
128
|
end
|
|
21
129
|
|
|
22
|
-
|
|
130
|
+
# Use {#async} instead.
|
|
131
|
+
#
|
|
132
|
+
# @deprecated
|
|
133
|
+
def run_async(&block)
|
|
134
|
+
async(&block)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Use {#delay} instead.
|
|
138
|
+
#
|
|
139
|
+
# @deprecated
|
|
140
|
+
def set_timeout(*args, &block)
|
|
141
|
+
delay(*args, &block)
|
|
142
|
+
end
|
|
23
143
|
end
|
|
24
144
|
|
|
145
|
+
# Runs all async examples from {AsyncExample.examples}.
|
|
25
146
|
class AsyncRunner
|
|
26
147
|
def initialize(runner, reporter, finish_block)
|
|
27
148
|
@runner = runner
|
|
@@ -65,17 +186,31 @@ module Opal
|
|
|
65
186
|
end
|
|
66
187
|
end
|
|
67
188
|
|
|
189
|
+
# An {AsyncExample} is a subclass of regular example instances which adds
|
|
190
|
+
# support for running an example, and waiting for a non-sync outcome. All
|
|
191
|
+
# async examples in a set of spec files will get registered through
|
|
192
|
+
# {AsyncExample.register}, and added to the {AsyncExample.examples} array
|
|
193
|
+
# ready for the runner to run.
|
|
194
|
+
#
|
|
195
|
+
# You will not need to create new instances of this class directly, and
|
|
196
|
+
# should instead use {AsyncHelpers} to create async examples.
|
|
68
197
|
class AsyncExample < ::RSpec::Core::Example
|
|
198
|
+
include AsyncHelpers
|
|
199
|
+
|
|
200
|
+
# Register new async example.
|
|
201
|
+
#
|
|
202
|
+
# @see AsyncHelpers::ClassMethods.async
|
|
69
203
|
def self.register(*args)
|
|
70
204
|
examples << new(*args)
|
|
71
205
|
end
|
|
72
206
|
|
|
207
|
+
# All async examples in specs.
|
|
208
|
+
#
|
|
209
|
+
# @return [Array<AsyncExample>]
|
|
73
210
|
def self.examples
|
|
74
211
|
@examples ||= []
|
|
75
212
|
end
|
|
76
213
|
|
|
77
|
-
include AsyncHelpers
|
|
78
|
-
|
|
79
214
|
def run(example_group_instance, reporter, &after_run_block)
|
|
80
215
|
@example_group_instance = example_group_instance
|
|
81
216
|
@reporter = reporter
|
data/opal/opal/rspec/fixes.rb
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# IO.closed? missing - BaseFormatter uses it for sync impl
|
|
2
|
+
class IO
|
|
3
|
+
def closed?
|
|
4
|
+
false
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
1
8
|
# Opal defines enumerable#flat_map, but doesnt implement it
|
|
2
9
|
module RSpec::Core::FlatMap
|
|
3
10
|
def flat_map(array)
|
|
@@ -42,14 +49,6 @@ module RSpec
|
|
|
42
49
|
end
|
|
43
50
|
end
|
|
44
51
|
|
|
45
|
-
# Opal does not yet support $1..$9 backrefs
|
|
46
|
-
class RSpec::Matchers::BuiltIn::BePredicate
|
|
47
|
-
def prefix_and_expected(symbol)
|
|
48
|
-
symbol.to_s =~ /^(be_(an?_)?)(.*)/
|
|
49
|
-
return $~[1], $~[3]
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
52
|
module RSpec::ExampleGroups
|
|
54
53
|
# opal cannot use mutable strings AND opal doesnt support `\A` or `\z` anchors
|
|
55
54
|
def self.base_name_for(group)
|
|
@@ -96,3 +95,14 @@ class RSpec::Mocks::MethodDouble
|
|
|
96
95
|
@original_method ||= @method_stasher.original_method
|
|
97
96
|
end
|
|
98
97
|
end
|
|
98
|
+
|
|
99
|
+
# Missing on vendored rspec version
|
|
100
|
+
module RSpec
|
|
101
|
+
module Core
|
|
102
|
+
module MemoizedHelpers
|
|
103
|
+
def is_expected
|
|
104
|
+
expect(subject)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'corelib/dir'
|
|
2
|
+
require 'thread'
|
|
3
|
+
|
|
4
|
+
require 'set'
|
|
5
|
+
require 'time'
|
|
6
|
+
require 'rbconfig'
|
|
7
|
+
require 'pathname'
|
|
8
|
+
|
|
9
|
+
# TODO: still needed? meh..
|
|
10
|
+
require 'rspec/core/version'
|
|
11
|
+
require 'rspec/core/flat_map'
|
|
12
|
+
require 'rspec/core/filter_manager'
|
|
13
|
+
require 'rspec/core/dsl'
|
|
14
|
+
require 'rspec/core/reporter'
|
|
15
|
+
require 'rspec/core/hooks'
|
|
16
|
+
require 'rspec/core/memoized_helpers'
|
|
17
|
+
require 'rspec/core/metadata'
|
|
18
|
+
require 'rspec/core/pending'
|
|
19
|
+
require 'rspec/core/formatters'
|
|
20
|
+
require 'rspec/core/ordering'
|
|
21
|
+
require 'rspec/core/world'
|
|
22
|
+
require 'rspec/core/configuration'
|
|
23
|
+
require 'rspec/core/option_parser'
|
|
24
|
+
require 'rspec/core/configuration_options'
|
|
25
|
+
require 'rspec/core/command_line'
|
|
26
|
+
require 'rspec/core/runner'
|
|
27
|
+
require 'rspec/core/example'
|
|
28
|
+
require 'rspec/core/shared_example_group/collection'
|
|
29
|
+
require 'rspec/core/shared_example_group'
|
|
30
|
+
require 'rspec/core/example_group'
|
|
31
|
+
|
|
32
|
+
require 'rspec/core/mocking/with_rspec'
|
|
33
|
+
|
|
34
|
+
require 'rspec/support'
|
|
35
|
+
require 'rspec/core'
|
|
36
|
+
require 'rspec/expectations'
|
|
37
|
+
require 'rspec/mocks'
|
|
38
|
+
require 'rspec'
|
|
39
|
+
|
|
40
|
+
# FIXME: still needed?
|
|
41
|
+
require 'rspec/core/formatters/base_text_formatter'
|
|
42
|
+
require 'rspec/core/formatters/html_printer'
|
|
43
|
+
require 'rspec/matchers/pretty'
|
|
44
|
+
require 'rspec/matchers/built_in/base_matcher'
|
|
45
|
+
require 'rspec/matchers/built_in/be'
|
data/opal/opal/rspec.rb
CHANGED
|
@@ -4,29 +4,7 @@ end
|
|
|
4
4
|
|
|
5
5
|
Test = MiniTest
|
|
6
6
|
|
|
7
|
-
require '
|
|
8
|
-
require 'corelib/dir'
|
|
9
|
-
require 'thread'
|
|
10
|
-
|
|
11
|
-
require 'set'
|
|
12
|
-
require 'time'
|
|
13
|
-
require 'rbconfig'
|
|
14
|
-
require 'pathname'
|
|
15
|
-
|
|
16
|
-
# vendor a pre-built rspec
|
|
17
|
-
require 'opal/rspec/rspec'
|
|
18
|
-
|
|
19
|
-
# we "fix" these files, so require them now so they are loaded before our
|
|
20
|
-
# fixes file. We can't use Kernel#require() directly as the compiler will
|
|
21
|
-
# complain it can't find these files at compile time, but they are available
|
|
22
|
-
# from rspec.js from the gem.
|
|
23
|
-
%w[rspec
|
|
24
|
-
rspec/core/formatters/base_text_formatter
|
|
25
|
-
rspec/core/formatters/html_printer
|
|
26
|
-
rspec/matchers/pretty
|
|
27
|
-
rspec/matchers/built_in/base_matcher
|
|
28
|
-
rspec/matchers/built_in/be].each { |r| `self.$require(r)` }
|
|
29
|
-
|
|
7
|
+
require 'opal/rspec/requires'
|
|
30
8
|
require 'opal/rspec/fixes'
|
|
31
9
|
require 'opal/rspec/text_formatter'
|
|
32
10
|
require 'opal/rspec/browser_formatter'
|
|
@@ -39,7 +17,6 @@ RSpec.configure do |config|
|
|
|
39
17
|
|
|
40
18
|
# Async helpers for specs
|
|
41
19
|
config.include Opal::RSpec::AsyncHelpers
|
|
42
|
-
config.extend Opal::RSpec::AsyncDefinitions
|
|
43
20
|
|
|
44
21
|
# Always support expect() and .should syntax (we should not do this really..)
|
|
45
22
|
config.expect_with :rspec do |c|
|
data/opal-rspec.gemspec
CHANGED
|
@@ -11,11 +11,11 @@ Gem::Specification.new do |s|
|
|
|
11
11
|
s.description = 'Opal compatible rspec library'
|
|
12
12
|
|
|
13
13
|
s.files = `git ls-files`.split("\n")
|
|
14
|
-
s.files << 'opal/opal/rspec/rspec.js'
|
|
15
14
|
|
|
16
15
|
s.require_paths = ['lib']
|
|
17
16
|
|
|
18
17
|
s.add_dependency 'opal', '~> 0.7.0.beta1'
|
|
19
18
|
s.add_development_dependency 'rake'
|
|
19
|
+
s.add_development_dependency 'yard'
|
|
20
20
|
end
|
|
21
21
|
|
data/spec/async_spec.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
describe "Asynchronous helpers" do
|
|
2
|
-
|
|
3
2
|
let(:foo) { 100 }
|
|
4
3
|
|
|
5
4
|
before do
|
|
@@ -7,13 +6,13 @@ describe "Asynchronous helpers" do
|
|
|
7
6
|
end
|
|
8
7
|
|
|
9
8
|
async "can run examples async" do
|
|
10
|
-
|
|
9
|
+
async do
|
|
11
10
|
1.should == 1
|
|
12
11
|
end
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
async "can access let() helpers and before() helpers" do
|
|
16
|
-
|
|
15
|
+
async do
|
|
17
16
|
foo.should eq(100)
|
|
18
17
|
@model.should be_kind_of(Object)
|
|
19
18
|
end
|
|
@@ -23,7 +22,7 @@ describe "Asynchronous helpers" do
|
|
|
23
22
|
obj = [1, 2, 3, 4]
|
|
24
23
|
|
|
25
24
|
delay(1) do
|
|
26
|
-
|
|
25
|
+
async { obj.should == [1, 2, 3, 4] }
|
|
27
26
|
end
|
|
28
27
|
end
|
|
29
28
|
|
|
@@ -33,7 +32,7 @@ describe "Asynchronous helpers" do
|
|
|
33
32
|
}.to raise_error(Exception)
|
|
34
33
|
|
|
35
34
|
delay(0) do
|
|
36
|
-
|
|
35
|
+
async { expect(42).to eq(42) }
|
|
37
36
|
end
|
|
38
37
|
end
|
|
39
38
|
end
|
data/spec/matchers_spec.rb
CHANGED
|
@@ -179,3 +179,23 @@ describe "operator ==" do
|
|
|
179
179
|
}.to raise_error(Exception)
|
|
180
180
|
end
|
|
181
181
|
end
|
|
182
|
+
|
|
183
|
+
class PredicateTest
|
|
184
|
+
def foo?
|
|
185
|
+
true
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def bar?
|
|
189
|
+
false
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
describe "predicate matchers" do
|
|
194
|
+
it "works with positive expectations" do
|
|
195
|
+
expect(PredicateTest.new).to be_foo
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
it "work with negative expectations" do
|
|
199
|
+
expect(PredicateTest.new).to_not be_bar
|
|
200
|
+
end
|
|
201
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
describe "One-liner should syntax" do
|
|
2
|
+
subject { 42 }
|
|
3
|
+
|
|
4
|
+
describe "should" do
|
|
5
|
+
it { should == 42 }
|
|
6
|
+
it { should_not == 43 }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "is_expected" do
|
|
10
|
+
it { is_expected.to eq(42) }
|
|
11
|
+
it { is_expected.to_not eq(43) }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "expect" do
|
|
15
|
+
it { expect(42).to eq(42) }
|
|
16
|
+
end
|
|
17
|
+
end
|