opal-rspec 0.5.0 → 0.6.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +6 -0
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/.travis.yml +36 -26
- data/Appraisals +7 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -4
- data/README.md +38 -16
- data/Rakefile +19 -7
- data/config.ru +3 -1
- data/gemfiles/opal_0.10_stable.gemfile +15 -0
- data/gemfiles/opal_master.gemfile +12 -15
- data/lib/opal/rspec/rake_task.rb +21 -8
- data/lib/opal/rspec/version.rb +1 -1
- data/lib/opal/rspec.rb +2 -2
- data/opal/opal/rspec/async/async_example.rb +5 -5
- data/opal/opal/rspec/async/example_group.rb +4 -4
- data/opal/opal/rspec/async/hooks.rb +2 -2
- data/opal/opal/rspec/async/legacy.rb +8 -9
- data/opal/opal/rspec/fixes/opal/compatibility.rb +3 -181
- data/opal/opal/rspec/fixes/opal.rb +0 -4
- data/opal/opal/rspec/fixes/rspec/core/metadata.rb +7 -26
- data/opal/opal/rspec/fixes/rspec/core.rb +0 -2
- data/opal/opal/rspec/fixes/rspec/example_groups.rb +0 -11
- data/opal/opal/rspec/fixes/rspec/expectations.rb +0 -1
- data/opal/opal/rspec/fixes/rspec/matchers/built_in/start_and_end_with.rb +0 -21
- data/opal/opal/rspec/fixes/rspec/mocks/error_generator.rb +0 -26
- data/opal/opal/rspec/fixes/rspec/support/spec/stderr_splitter.rb +13 -0
- data/opal/opal/rspec/fixes/rspec/support/spec.rb +1 -0
- data/opal/opal/rspec/fixes/rspec/support.rb +1 -1
- data/opal/opal/rspec/formatter/html_printer.rb +1 -1
- data/opal/opal/rspec/pre_require_fixes.rb +0 -5
- data/opal/opal/rspec/runner.rb +1 -1
- data/opal-rspec.gemspec +2 -3
- data/spec/mri/integration/browser_spec.rb +0 -3
- data/spec/mri/integration/spec_opts_spec.rb +1 -1
- data/spec/mri/unit/opal/rspec/browser_formatter_spec.rb +0 -3
- data/spec/mri/unit/opal/rspec/rack/config.ru +1 -1
- data/spec/mri/unit/opal/rspec/rake_task_spec.rb +60 -6
- data/spec/opal/after_hooks_spec.rb +26 -24
- data/spec/opal/around_hooks_spec.rb +2 -0
- data/spec/opal/async_spec.rb +22 -20
- data/spec/opal/before_hooks_spec.rb +20 -18
- data/spec/opal/example_spec.rb +4 -2
- data/spec/opal/matchers_spec.rb +3 -1
- data/spec/opal/mock_spec.rb +2 -0
- data/spec/opal/should_syntax_spec.rb +2 -0
- data/spec/opal/skip_pending_spec.rb +7 -5
- data/spec/opal/spec_helper.rb +4 -0
- data/spec/opal/subject_spec.rb +2 -0
- data/spec/rspec/core/filter/core/async/hooks.rb +0 -1
- data/spec/rspec/core/filter/core/async/metadata.rb +4 -0
- data/spec/rspec/core/filter/core/bugs/memoized_helpers.rb +0 -6
- data/spec/rspec/core/require_specs.rb +0 -1
- data/spec/rspec/expectations/config.rb +6 -1
- data/spec/rspec/expectations/filter/bugs/configuration.txt +0 -3
- data/spec/rspec/expectations/filter/bugs/contain_exactly.rb +0 -5
- data/spec/rspec/expectations/filter/bugs/define_negated_matcher.rb +0 -1
- data/spec/rspec/expectations/filter/bugs/dsl.rb +15 -0
- data/spec/rspec/expectations/filter/bugs/expectation_target.rb +4 -0
- data/spec/rspec/expectations/filter/bugs/expectations.rb +4 -0
- data/spec/rspec/expectations/filter/bugs/respond_to.rb +5 -11
- data/spec/rspec/expectations/filter/unsupported/dsl.rb +10 -0
- data/spec/rspec/expectations/fixes/example_patches.rb +0 -17
- data/spec/rspec/expectations/opal_alternates/dsl_spec.rb +2 -2
- data/spec/rspec/expectations/require_specs.rb +0 -1
- data/spec/rspec/filter_processor.rb +21 -5
- data/spec/rspec/mocks/filter/bugs/and_call_original.rb +11 -0
- data/spec/rspec/mocks/filter/bugs/and_yield.rb +4 -0
- data/spec/rspec/mocks/filter/bugs/any_instance.rb +1 -7
- data/spec/rspec/mocks/filter/bugs/partial_double.rb +5 -6
- data/spec/rspec/mocks/filter/bugs/stub_implementation.rb +0 -4
- data/spec/rspec/mocks/filter/unsupported/and_call_original.rb +7 -0
- data/spec/rspec/mocks/filter/unsupported/and_return.rb +4 -0
- data/spec/rspec/mocks/filter/unsupported/argument_matchers.rb +0 -3
- data/spec/rspec/mocks/filter/unsupported/combining_implementation_instructions.rb +0 -5
- data/spec/rspec/mocks/filter/unsupported/double.rb +0 -3
- data/spec/rspec/mocks/filter/unsupported/instance_double_with_class_loaded.rb +10 -0
- data/spec/rspec/mocks/filter/unsupported/nil_expectation_warning.rb +0 -4
- data/spec/rspec/mocks/filter/unsupported/partial_double.rb +0 -2
- data/spec/rspec/mocks/mocks_spec_loader.rb +1 -1
- data/spec/rspec/mocks/require_specs.rb +0 -1
- data/spec/rspec/mocks/spec_helper_opal.rb +2 -0
- data/spec/rspec/opal_rspec_spec_loader.rb +19 -4
- data/spec/rspec/support/filter/unsupported/fuzzy_matcher.rb +4 -0
- data/spec/rspec/support/filter/unsupported/support.rb +0 -3
- data/spec/rspec/support/require_specs.rb +0 -1
- metadata +27 -51
- data/opal/opal/rspec/fixes/opal/class.rb +0 -8
- data/opal/opal/rspec/fixes/opal/corelib/error.rb +0 -61
- data/opal/opal/rspec/fixes/opal/corelib/regexp.rb +0 -92
- data/opal/opal/rspec/fixes/opal/corelib/struct.rb +0 -260
- data/opal/opal/rspec/fixes/opal/corelib.rb +0 -3
- data/opal/opal/rspec/fixes/opal/kernel.rb +0 -80
- data/opal/opal/rspec/fixes/opal/stdlib/pp.rb +0 -23
- data/opal/opal/rspec/fixes/opal/stdlib/set.rb +0 -36
- data/opal/opal/rspec/fixes/opal/stdlib.rb +0 -2
- data/opal/opal/rspec/fixes/rspec/core/example_group.rb +0 -9
- data/opal/opal/rspec/fixes/rspec/core/reporter.rb +0 -14
- data/opal/opal/rspec/fixes/rspec/expectations/syntax.rb +0 -25
- data/opal/opal/rspec/fixes/rspec/support/fuzzy_matcher.rb +0 -23
- data/opal/opal/rspec/fixes/rspec/support/ruby_features.rb +0 -8
- data/spec/rspec/core/filter/core/async/metadata.txt +0 -2
- data/spec/rspec/core/filter/core/unsupported/metadata_filter.txt +0 -2
- data/spec/rspec/core/fixes/opal_itself.rb +0 -38
- data/spec/rspec/expectations/filter/bugs/aliases.rb +0 -13
- data/spec/rspec/expectations/filter/bugs/be.rb +0 -4
- data/spec/rspec/expectations/filter/bugs/be_instance_of.rb +0 -7
- data/spec/rspec/expectations/filter/bugs/description_generation.rb +0 -4
- data/spec/rspec/expectations/filter/bugs/dsl.txt +0 -14
- data/spec/rspec/expectations/filter/bugs/expectation_target.txt +0 -2
- data/spec/rspec/expectations/filter/bugs/expectations.txt +0 -2
- data/spec/rspec/expectations/filter/bugs/have_attributes.rb +0 -8
- data/spec/rspec/expectations/filter/bugs/include.rb +0 -4
- data/spec/rspec/expectations/filter/unsupported/dsl.txt +0 -8
- data/spec/rspec/expectations/filter/unsupported/respond_to.rb +0 -5
- data/spec/rspec/expectations/fixes/opal_itself.rb +0 -140
- data/spec/rspec/mocks/filter/bugs/and_call_original.txt +0 -9
- data/spec/rspec/mocks/filter/bugs/argument_matchers.rb +0 -3
- data/spec/rspec/mocks/filter/bugs/double.txt +0 -3
- data/spec/rspec/mocks/filter/bugs/methods.rb +0 -5
- data/spec/rspec/mocks/filter/unsupported/and_call_original.txt +0 -5
- data/spec/rspec/mocks/filter/unsupported/and_return.txt +0 -2
- data/spec/rspec/mocks/filter/unsupported/expected_arg_verification.txt +0 -2
- data/spec/rspec/mocks/filter/unsupported/instance_double_with_class_loaded.txt +0 -8
- data/spec/rspec/mocks/filter/unsupported/receive_message_chain.rb +0 -4
- data/spec/rspec/mocks/filter/unsupported/stub.rb +0 -7
- data/spec/rspec/mocks/fixes/opal_itself.rb +0 -59
- data/spec/rspec/support/filter/unsupported/fuzzy_matcher.txt +0 -2
- data/spec/rspec/support/fixes/opal_itself.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 882a14ef615ce8c04e42e0251c20689eab6d0cb9
|
4
|
+
data.tar.gz: 7ace5634304dc7cd953aa5de1af4ad1c31140586
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c18a02f4f4fd2221c5a1baf9976a7ce0298c3511694cf41c622ba07d19ffb3f02c80f596ad1fef813588422454e0b3ae35623d3a3daf81d796c249e4b74cccd5
|
7
|
+
data.tar.gz: c49795363ee60fd59e6308767e5c97605a697e6ad9d1adcf0a82ae6492363db2e7f28ac4a795dc8674baeb9a70e63498be3713cf0d8773722922323a78a8d975
|
data/.codeclimate.yml
ADDED
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
CHANGED
@@ -3,42 +3,52 @@ sudo: false
|
|
3
3
|
|
4
4
|
cache:
|
5
5
|
bundler: true
|
6
|
+
directories:
|
7
|
+
- node_modules
|
8
|
+
- phantom20
|
6
9
|
|
7
10
|
matrix:
|
8
11
|
fast_finish: true
|
9
12
|
|
10
13
|
include:
|
11
|
-
|
12
|
-
|
13
|
-
- rvm: 2.
|
14
|
-
env: RUN=
|
15
|
-
- rvm: 2.
|
16
|
-
env: RUN=
|
17
|
-
- rvm: 2.
|
18
|
-
env: RUN=default
|
19
|
-
- rvm: 2.2.3
|
14
|
+
- rvm: 2.2.4
|
15
|
+
env: RUN=mri_sanity_check
|
16
|
+
- rvm: 2.3.0
|
17
|
+
env: RUN=mri_sanity_check
|
18
|
+
- rvm: 2.3.0
|
19
|
+
env: RUN=rake_only
|
20
|
+
- rvm: 2.3.0
|
20
21
|
# PHANTOMJS env variable is not used but it makes it easier to differentiate this build in Travis
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
-
|
25
|
-
- "export PATH=`pwd`/
|
22
|
+
env: PHANTOMJS=2.1 RUN=rake_only
|
23
|
+
before_install:
|
24
|
+
# Attempt to work around Travis issues and Ruby 2.3 - https://github.com/vcr/vcr/issues/582
|
25
|
+
- gem update --system
|
26
|
+
- "export PATH=`pwd`/node_modules/phantomjs-prebuilt/bin:$PATH"
|
26
27
|
- "echo $PATH"
|
27
|
-
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
- "export DISPLAY=:99.0"
|
33
|
-
- "sh -e /etc/init.d/xvfb start"
|
34
|
-
- rvm: 2.2.3
|
35
|
-
env: RUN=default RUNNER=node
|
36
|
-
- rvm: 2.2.3
|
37
|
-
env: RUN=default
|
28
|
+
- phantomjs -v | grep 2.1 || npm install phantomjs-prebuilt # get rate limits from bitbucket download source, so get from NPM if we don't have it already
|
29
|
+
- rvm: 2.3.0
|
30
|
+
env: RUNNER=node RUN=rake_only
|
31
|
+
- rvm: 2.3.0
|
32
|
+
env: RUN=rake_only
|
38
33
|
gemfile: gemfiles/opal_master.gemfile
|
34
|
+
- rvm: 2.3.0
|
35
|
+
env: RUN=rake_only
|
36
|
+
gemfile: gemfiles/opal_0.10_stable.gemfile
|
37
|
+
|
38
|
+
allow_failures:
|
39
|
+
- gemfile: gemfiles/opal_master.gemfile
|
39
40
|
|
40
41
|
before_install:
|
41
|
-
|
42
|
+
# Attempt to work around Travis issues and Ruby 2.3 - https://github.com/vcr/vcr/issues/582
|
43
|
+
- gem update --system
|
44
|
+
- "mkdir -p phantom20"
|
45
|
+
- "export PATH=`pwd`/phantom20:$PATH"
|
46
|
+
- "echo $PATH"
|
47
|
+
- "pushd phantom20"
|
48
|
+
- "ls phantomjs || curl -L -O https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2"
|
49
|
+
- "ls phantomjs || tar xjvf phantomjs-2.0.0-ubuntu-12.04.tar.bz2"
|
50
|
+
- "rm -rf phantomjs-2.0.0-ubuntu-12.04.tar.bz2"
|
51
|
+
- "popd"
|
42
52
|
|
43
53
|
before_script:
|
44
54
|
- "export DISPLAY=:99.0"
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 0.6.0 - Under development
|
2
|
+
|
3
|
+
* Support for Opal 0.8/0.9 removed
|
4
|
+
* Opal 0.10 support
|
5
|
+
* Arity checking enabled by default
|
6
|
+
* Dropped support for PhantomJS < 2.0
|
7
|
+
* Removed `Kernel#caller` monkey patch so test file/line metadata is only available if supplied via test metadata or for failures. Should improve performance since an exception isn't thrown for every test to gather the data
|
8
|
+
|
1
9
|
## 0.5.0 (2015-12-08)
|
2
10
|
|
3
11
|
* By default, any subject, it example block, before(:each), after(:each), and around that returns a promise will be executed asynchronously. Async is NOT yet supported for context level hooks. Async approach from < 0.4.3 will still work.
|
data/Gemfile
CHANGED
@@ -5,9 +5,7 @@ unless Dir['rspec{,-{core,expectations,mocks,support}}'].any?
|
|
5
5
|
warn 'Run: "git submodule update --init" to get RSpec sources'
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
# gem 'opal', git: 'https://github.com/opal/opal.git'
|
10
|
-
gem 'capybara-webkit', require: false
|
8
|
+
gem 'capybara'
|
11
9
|
gem 'selenium-webdriver', require: false
|
12
10
|
|
13
11
|
# These need to come from our local path in order for create_requires.rb to work properly
|
@@ -16,4 +14,4 @@ gem 'rspec-support', path: 'rspec-support'
|
|
16
14
|
gem 'rspec-core', path: 'rspec-core'
|
17
15
|
gem 'rspec-mocks', path: 'rspec-mocks'
|
18
16
|
gem 'rspec-expectations', path: 'rspec-expectations'
|
19
|
-
|
17
|
+
gem 'appraisal'
|
data/README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# opal-rspec
|
2
2
|
|
3
3
|
[![Build Status](http://img.shields.io/travis/opal/opal-rspec/master.svg?style=flat)](http://travis-ci.org/opal/opal-rspec)
|
4
|
+
[![Quality](http://img.shields.io/codeclimate/github/opal/opal-rspec.svg?style=flat-square)](https://codeclimate.com/github/opal/opal-rspec)
|
5
|
+
[![Version](http://img.shields.io/gem/v/opal-rspec.svg?style=flat-square)](https://rubygems.org/gems/opal-rspec)
|
4
6
|
|
5
|
-
An attempt at a compatibility layer of
|
7
|
+
An attempt at a compatibility layer of RSpec for Opal.
|
6
8
|
|
7
|
-
|
9
|
+
#### For the README for the latest release, click [here](https://github.com/opal/opal-rspec/blob/releases/0-5-stable/README.md).
|
8
10
|
|
9
11
|
## Usage
|
10
12
|
|
@@ -17,7 +19,7 @@ gem 'opal-rspec'
|
|
17
19
|
## Requirements
|
18
20
|
|
19
21
|
Besides what's already reflected in the GEM dependencies:
|
20
|
-
* PhantomJS
|
22
|
+
* PhantomJS 2.0 or 2.1 for Rake task testing
|
21
23
|
* Browser if you want to run and debug tests that way
|
22
24
|
|
23
25
|
### Run specs in phantomjs
|
@@ -95,6 +97,14 @@ Opal::RSpec::RakeTask.new(:default) do |server, task|
|
|
95
97
|
end
|
96
98
|
```
|
97
99
|
|
100
|
+
Arity checking is enabled by default. Opal allows you to disable arity checking (faster in production this way) but for unit testing, you probably want information on arity mismatch. If you wish to disable it, configure your Rake task like this:
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
Opal::RSpec::RakeTask.new(:default) do |server, task|
|
104
|
+
task.arity_checking = :disabled
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
98
108
|
### Run specs in nodejs
|
99
109
|
|
100
110
|
Same options as above, you can use the `RUNNER=node` environment variable or use the Rake task like so:
|
@@ -126,7 +136,7 @@ run Opal::Server.new(sprockets: sprockets_env) { |s|
|
|
126
136
|
Then run the rack server `bundle exec rackup` and visit `http://localhost:9292`
|
127
137
|
in any web browser.
|
128
138
|
|
129
|
-
A new feature of opal-rspec 0.5 allows you to click a 'Console' button in the browser's test results and get a
|
139
|
+
A new feature as of opal-rspec 0.5 allows you to click a 'Console' button in the browser's test results and get a
|
130
140
|
clickable stack trace in the browser console. This should ease debugging with long, concatenated script files and trying
|
131
141
|
to navigate to where an exception occurred.
|
132
142
|
|
@@ -233,10 +243,26 @@ Disadvantages:
|
|
233
243
|
|
234
244
|
## Opal load path
|
235
245
|
|
236
|
-
NOTE: Only the 'spec' directory will be added to the Opal load path by default. Use the Rake task's
|
246
|
+
NOTE: Only the 'spec' directory will be added to the Opal load path by default. Use the Rake task's `default_path` setting to change that. Here's an example of that.
|
247
|
+
|
248
|
+
```ruby
|
249
|
+
Opal::RSpec::RakeTask.new do |server, task|
|
250
|
+
task.default_path = 'spec/javascripts'
|
251
|
+
end
|
252
|
+
```
|
253
|
+
|
254
|
+
If you need to add additional load paths to run your specs, then use the `append_path` method like this:
|
255
|
+
|
256
|
+
```ruby
|
257
|
+
Opal::RSpec::RakeTask.new do |server, task|
|
258
|
+
server.append_path 'some_path'
|
259
|
+
end
|
260
|
+
```
|
237
261
|
|
238
262
|
## Other Limitations/Known Issues
|
239
263
|
|
264
|
+
80%+ of the RSpec test suites pass so most items work but there are a few things that do not yet work.
|
265
|
+
|
240
266
|
* Core Examples
|
241
267
|
* Example groups included like this are currently not working:
|
242
268
|
```ruby
|
@@ -254,37 +280,33 @@ RSpec.configure do |c|
|
|
254
280
|
c.include TestMod
|
255
281
|
end
|
256
282
|
```
|
257
|
-
* Formatting
|
258
|
-
*
|
283
|
+
* Formatting/Reporting
|
284
|
+
* Specs will not have file path/line number information on them unless they are supplied from user metadata or they fail, see [this issue](https://github.com/opal/opal-rspec/issues/36)
|
285
|
+
* In Firefox w/ the browser runner, no backtraces show up with failed specs
|
259
286
|
* Diffs are not yet available when objects do not meet expectations (diff-lcs gem dependency has not been dealt with yet in Opal)
|
260
287
|
* Configuration
|
261
288
|
* Not all RSpec runner options are supported yet
|
262
289
|
* At some point, using node + Phantom's ability to read environment variables could be combined with a opal friendly optparse implementation to allow full options to be supplied/parsed
|
263
|
-
* Expect and should syntax are both enabled. They cannot be disabled due to bugs with the `undef` keyword in Opal
|
290
|
+
* Expect and should syntax are both enabled. They cannot be disabled due to past bugs with the `undef` keyword in Opal. Status of changing this via config has not been retested.
|
264
291
|
* Random order does not work yet due to lack of [srand/Random support](https://github.com/opal/opal/issues/639) and RSpec's bundled Random implementation, `RSpec::Core::Backports::Random`, locks the browser/Phantom. If you specify random order, it will be ignored.
|
265
|
-
* With Opal < 0.9, you can't access the example from named subject blocks (e.g. ```subject {|e| puts "example is #{e}" }```)
|
266
292
|
* Nodejs runner
|
267
293
|
* debug mode + source map support not there yet (see source map support - https://github.com/evanw/node-source-map-support)
|
268
294
|
* currently running a lot slower than phantomjs, might need optimization
|
269
295
|
* Matchers
|
270
296
|
* predicate matchers (be_some_method_on_your_subject) do not currently work with delegate objects (Opal `DelegateClass` is incomplete)
|
271
|
-
* operator based comparison, except for `==`, won't work on Opal 0.8 due to lack of method_missing support for operators. This works correctly in Opal 0.9.
|
272
|
-
* descriptions on aliased/negated matchers won't be like normal RSpec due to several bugs: method owner not being correct (not fixed yet), blocks passed after arguments and hash (fixed in Opal 0.9)
|
273
297
|
* equal and eq matchers function largely the same right now since `==` and `equal?` in Opal are largely the same
|
274
298
|
* time based matching is not yet tested
|
275
|
-
*
|
276
|
-
* splat methods and expect(...).to respond_to will be inconsistent in Opal 0.8 since several splat bugs were fixed with Opal 0.9
|
299
|
+
* Due to some issues with splats and arity in Opal, respond_to matchers may not work properly on methods with splats
|
277
300
|
* Mocks
|
278
301
|
* `allow_any_instance/any_instance_of/any_instance` are unstable and may cause runner to crash due to issues with redefining the `===` operator, which breaks a case statement inside `Hooks#find_hook`
|
279
302
|
* using expect/allow on `String`, `Number`, or any immutable bridged/native class, does not work since rspec-mocks uses singleton classes and those cannot be defined on immutable objects
|
280
303
|
* mocking class methods (including `::new`) is currently broken
|
281
304
|
* `class_double/class_spy` are not supported (it depends on `ClassVerifyingDouble` inheriting from `Module` to support transferring nested constants, but that doesn't work on Opal)
|
282
305
|
* `object_spy` is not supported (depends on proper initializer behavior in `ObjectVerifyingDoubleMethods`)
|
283
|
-
* verifying partial doubles do not fully work yet
|
306
|
+
* verifying partial doubles do not fully work yet (arity issues with Opal)
|
284
307
|
* chaining and_return after do...end does not work
|
285
308
|
* duck_type argument matching is still buggy
|
286
|
-
*
|
287
|
-
* A lot of backports/monkey patches to Opal classes/methods are done to make this work on Opal 0.8. That means some things might work in your tests that do not work without opal-rspec. You can explore the opal/opal/rspec/fixes/opal directory to see what is being changed. All of the monkey patches check to see if the feature is "broken" before they apply themselves.
|
309
|
+
* RSpec's marshal support does not yet work with Opal's marshaller (so patch_marshal_to_support_partial_doubles config setting is not supported)
|
288
310
|
|
289
311
|
## Contributing
|
290
312
|
|
data/Rakefile
CHANGED
@@ -9,12 +9,23 @@ require_relative 'spec/rspec/expectations/expectation_spec_loader'
|
|
9
9
|
require_relative 'spec/rspec/support/support_spec_loader'
|
10
10
|
require_relative 'spec/rspec/mocks/mocks_spec_loader'
|
11
11
|
|
12
|
+
desc 'Run the full suite, this can time out on Travis'
|
12
13
|
task :default => [:phantom_node_ver,
|
13
14
|
:unit_specs,
|
14
15
|
:verify_opal_specs,
|
15
16
|
:integration_specs,
|
16
17
|
:verify_rspec_specs]
|
17
18
|
|
19
|
+
desc 'Run only tests that use the opal-rspec Rake task'
|
20
|
+
task :rake_only => [:phantom_node_ver,
|
21
|
+
:verify_opal_specs,
|
22
|
+
:verify_rspec_specs]
|
23
|
+
|
24
|
+
desc 'Sanity checks a given version of MRI and run a basic check'
|
25
|
+
task :mri_sanity_check => [:phantom_node_ver,
|
26
|
+
:unit_specs,
|
27
|
+
:integration_specs]
|
28
|
+
|
18
29
|
task :phantom_node_ver do
|
19
30
|
sh 'phantomjs -v'
|
20
31
|
sh 'node -v'
|
@@ -63,11 +74,11 @@ Opal::RSpec::MocksSpecLoader.rake_tasks_for(:rspec_mocks_specs)
|
|
63
74
|
# These are done
|
64
75
|
desc 'Verifies all RSpec specs'
|
65
76
|
task :verify_rspec_specs => [
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
77
|
+
:verify_rspec_support_specs,
|
78
|
+
:verify_rspec_core_specs,
|
79
|
+
:verify_rspec_expectation_specs,
|
80
|
+
:verify_rspec_mocks_specs
|
81
|
+
]
|
71
82
|
|
72
83
|
desc 'Verifies other_spec_dir task ran correctly'
|
73
84
|
task :verify_other_specs do
|
@@ -81,6 +92,7 @@ end
|
|
81
92
|
desc 'Will run a spec suite (rake opal_specs) and check for expected combination of failures and successes'
|
82
93
|
task :verify_opal_specs do
|
83
94
|
test_output = `rake opal_specs`
|
95
|
+
test_output.force_encoding 'UTF-8'
|
84
96
|
raise "Expected test runner to fail due to failed tests, but got return code of #{$?.exitstatus}" if $?.success?
|
85
97
|
count_match = /(\d+) examples, (\d+) failures, (\d+) pending/.match(test_output)
|
86
98
|
raise 'Expected a finished count of test failures/success/etc. but did not see it' unless count_match
|
@@ -130,8 +142,8 @@ task :dist do
|
|
130
142
|
require 'fileutils'
|
131
143
|
FileUtils.mkdir_p 'build'
|
132
144
|
|
133
|
-
builder = Opal::Builder.new(stubs: Opal::
|
134
|
-
compiler_options: {dynamic_require_severity: :ignore}) # RSpec is full of dynamic requires
|
145
|
+
builder = Opal::Builder.new(stubs: Opal::Config.stubbed_files, # stubs already specified in lib/opal/rspec.rb
|
146
|
+
compiler_options: { dynamic_require_severity: :ignore }) # RSpec is full of dynamic requires
|
135
147
|
src = builder.build('opal-rspec')
|
136
148
|
|
137
149
|
min = uglify src
|
data/config.ru
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'opal/rspec'
|
2
2
|
|
3
|
-
Opal::
|
3
|
+
Opal::Config.source_map_enabled = false
|
4
|
+
Opal::Config.arity_check_enabled = true
|
4
5
|
|
5
6
|
sprockets_env = Opal::RSpec::SprocketsEnvironment.new(spec_pattern='spec/opal/**/*_spec.{rb,opal}',
|
6
7
|
spec_exclude_pattern=nil,
|
7
8
|
spec_files=nil,
|
8
9
|
default_path='spec/opal')
|
10
|
+
sprockets_env.cache = ::Sprockets::Cache::FileStore.new(File.join('tmp', 'cache', 'opal_specs'))
|
9
11
|
run Opal::Server.new(sprockets: sprockets_env) { |s|
|
10
12
|
s.main = 'sprockets_runner_js_errors'
|
11
13
|
# sprockets_runner_js_errors will not be in the opal load path by default
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "capybara"
|
6
|
+
gem "selenium-webdriver", :require => false
|
7
|
+
gem "rspec", :path => "../rspec"
|
8
|
+
gem "rspec-support", :path => "../rspec-support"
|
9
|
+
gem "rspec-core", :path => "../rspec-core"
|
10
|
+
gem "rspec-mocks", :path => "../rspec-mocks"
|
11
|
+
gem "rspec-expectations", :path => "../rspec-expectations"
|
12
|
+
gem "appraisal"
|
13
|
+
gem "opal", :git => "https://github.com/opal/opal.git", :branch => "0-10-stable"
|
14
|
+
|
15
|
+
gemspec :path => "../"
|
@@ -1,18 +1,15 @@
|
|
1
|
-
|
2
|
-
gemspec path: '../'
|
1
|
+
# This file was generated by Appraisal
|
3
2
|
|
4
|
-
|
5
|
-
warn 'Run: "git submodule update --init" to get RSpec sources'
|
6
|
-
end
|
3
|
+
source "https://rubygems.org"
|
7
4
|
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
gem
|
11
|
-
|
12
|
-
|
13
|
-
gem
|
14
|
-
gem
|
15
|
-
gem
|
16
|
-
gem
|
17
|
-
gem 'rspec-expectations', path: '../rspec-expectations'
|
5
|
+
gem "capybara"
|
6
|
+
gem "selenium-webdriver", :require => false
|
7
|
+
gem "rspec", :path => "../rspec"
|
8
|
+
gem "rspec-support", :path => "../rspec-support"
|
9
|
+
gem "rspec-core", :path => "../rspec-core"
|
10
|
+
gem "rspec-mocks", :path => "../rspec-mocks"
|
11
|
+
gem "rspec-expectations", :path => "../rspec-expectations"
|
12
|
+
gem "appraisal"
|
13
|
+
gem "opal", :git => "https://github.com/opal/opal.git"
|
18
14
|
|
15
|
+
gemspec :path => "../"
|
data/lib/opal/rspec/rake_task.rb
CHANGED
@@ -11,7 +11,12 @@ module Opal
|
|
11
11
|
PORT = 9999
|
12
12
|
URL = "http://localhost:#{PORT}/"
|
13
13
|
|
14
|
-
attr_accessor :pattern, :exclude_pattern, :files, :default_path, :runner, :timeout
|
14
|
+
attr_accessor :pattern, :exclude_pattern, :files, :default_path, :runner, :timeout, :arity_checking
|
15
|
+
|
16
|
+
def arity_checking?
|
17
|
+
setting = @arity_checking || :enabled
|
18
|
+
setting == :enabled
|
19
|
+
end
|
15
20
|
|
16
21
|
def launch_phantom(timeout_value)
|
17
22
|
command_line = %Q{phantomjs #{RUNNER} "#{URL}"#{timeout_value ? " #{timeout_value}" : ''}}
|
@@ -31,7 +36,7 @@ module Opal
|
|
31
36
|
name = server.main
|
32
37
|
asset = sprockets[name]
|
33
38
|
raise "Cannot find asset: #{name}" if asset.nil?
|
34
|
-
Opal::
|
39
|
+
Opal::Sprockets.load_asset name, sprockets
|
35
40
|
end
|
36
41
|
|
37
42
|
# TODO: Avoid the Rack server and compile directly
|
@@ -98,23 +103,31 @@ module Opal
|
|
98
103
|
sprockets_env.add_spec_paths_to_sprockets
|
99
104
|
}
|
100
105
|
|
106
|
+
Opal::Config.arity_check_enabled = arity_checking?
|
107
|
+
|
101
108
|
# TODO: Once Opal 0.9 compatibility is established, if we're running node, add in the node stdlib requires in so RSpec can use them, also add NODE_PATH to the runner command above
|
102
109
|
|
103
110
|
server = Thread.new do
|
104
111
|
Thread.current.abort_on_exception = true
|
105
112
|
Rack::Server.start(
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
113
|
+
:app => app,
|
114
|
+
:Port => PORT,
|
115
|
+
:AccessLog => [],
|
116
|
+
:Logger => WEBrick::Log.new("/dev/null"),
|
110
117
|
)
|
111
118
|
end
|
112
119
|
|
113
120
|
wait_for_server
|
114
121
|
is_phantom = runner == :phantom
|
115
122
|
if is_phantom
|
116
|
-
|
117
|
-
|
123
|
+
version_output = begin
|
124
|
+
`phantomjs -v`.strip
|
125
|
+
rescue
|
126
|
+
warn 'Could not find phantomjs command on path!'
|
127
|
+
exit 1
|
128
|
+
end
|
129
|
+
if version_output.to_f < 2
|
130
|
+
warn "PhantomJS >= 2.0 is required but version #{version_output} is installed!"
|
118
131
|
exit 1
|
119
132
|
end
|
120
133
|
end
|
data/lib/opal/rspec/version.rb
CHANGED
data/lib/opal/rspec.rb
CHANGED
@@ -11,7 +11,7 @@ Opal.append_path File.expand_path('../../../opal', __FILE__)
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# Since we have better specs than before (and a script to deal with this), ignoring
|
14
|
-
Opal::
|
14
|
+
Opal::Config.dynamic_require_severity = :ignore
|
15
15
|
|
16
16
|
stubs = [
|
17
17
|
'mutex_m', # Used with some threading operations but seems to run OK without this
|
@@ -36,4 +36,4 @@ stubs = [
|
|
36
36
|
'minitest/assertions'
|
37
37
|
]
|
38
38
|
|
39
|
-
|
39
|
+
::Opal::Config.stubbed_files.merge(stubs)
|
@@ -21,11 +21,11 @@ class ::RSpec::Core::Example
|
|
21
21
|
example_group_instance.__memoized[:subject] = resolved_subject
|
22
22
|
end
|
23
23
|
end
|
24
|
-
rescue
|
24
|
+
rescue Exception => _ # Can't use empty rescue in Opal 0.10 because it won't catch native JS exceptions (which aren't StandardError instances)
|
25
25
|
# Exception occurred while checking the subject, might be that the example group had a described class, was not intending on using it as the subject,
|
26
26
|
# and the initializer for that described class failed
|
27
27
|
end
|
28
|
-
Promise.value
|
28
|
+
Promise.value(true)
|
29
29
|
end
|
30
30
|
|
31
31
|
def run_after_example
|
@@ -46,13 +46,13 @@ class ::RSpec::Core::Example
|
|
46
46
|
start(reporter)
|
47
47
|
Pending.mark_pending!(self, pending) if pending?
|
48
48
|
|
49
|
-
Promise.value.then do
|
50
|
-
Promise.value.then do
|
49
|
+
Promise.value(true).then do
|
50
|
+
Promise.value(true).then do
|
51
51
|
if skipped?
|
52
52
|
Pending.mark_pending! self, skip
|
53
53
|
elsif !RSpec.configuration.dry_run?
|
54
54
|
with_around_example_hooks do
|
55
|
-
Promise.value.then do
|
55
|
+
Promise.value(true).then do
|
56
56
|
run_before_example.then do
|
57
57
|
resolve_subject
|
58
58
|
end.then do
|
@@ -15,7 +15,7 @@ class ::RSpec::Core::ExampleGroup
|
|
15
15
|
|
16
16
|
def self.process_descendants(our_examples_result, reporter)
|
17
17
|
descendants = ordering_strategy.order(children)
|
18
|
-
return Promise.value
|
18
|
+
return Promise.value(our_examples_result) if descendants.empty?
|
19
19
|
|
20
20
|
results_for_descendants = []
|
21
21
|
# Can use true for this because we're AND'ing everything anyways
|
@@ -40,7 +40,7 @@ class ::RSpec::Core::ExampleGroup
|
|
40
40
|
end
|
41
41
|
|
42
42
|
reporter.example_group_started(self)
|
43
|
-
Promise.value.then do
|
43
|
+
Promise.value(true).then do
|
44
44
|
run_before_context_hooks(new)
|
45
45
|
end.then do
|
46
46
|
run_examples(reporter)
|
@@ -66,7 +66,7 @@ class ::RSpec::Core::ExampleGroup
|
|
66
66
|
# Promise oriented version
|
67
67
|
def self.run_examples(reporter)
|
68
68
|
examples = ordering_strategy.order(filtered_examples)
|
69
|
-
return Promise.value
|
69
|
+
return Promise.value(true) if examples.empty?
|
70
70
|
|
71
71
|
example_promise = lambda do |example|
|
72
72
|
next Promise.value(nil) if RSpec.world.wants_to_quit
|
@@ -78,7 +78,7 @@ class ::RSpec::Core::ExampleGroup
|
|
78
78
|
|
79
79
|
results = []
|
80
80
|
# Can use true for this because we're AND'ing everything anyways
|
81
|
-
seed = Promise.value
|
81
|
+
seed = Promise.value(true)
|
82
82
|
latest_promise = examples.inject(seed) do |previous_promise, next_example|
|
83
83
|
previous_promise.then do |succeeded|
|
84
84
|
RSpec.world.wants_to_quit = true if fail_fast? && !succeeded
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class RSpec::Core::Hooks::HookCollection
|
2
2
|
def run
|
3
|
-
hooks.inject(Promise.value) do |previous_hook_promise, next_hook|
|
3
|
+
hooks.inject(Promise.value(true)) do |previous_hook_promise, next_hook|
|
4
4
|
previous_hook_promise.then do
|
5
5
|
result = next_hook.run @example
|
6
|
-
Promise.value
|
6
|
+
Promise.value(result)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -1,29 +1,29 @@
|
|
1
1
|
module Opal
|
2
2
|
module RSpec
|
3
3
|
module AsyncHelpers
|
4
|
-
module ClassMethods
|
4
|
+
module ClassMethods
|
5
5
|
def async(desc, *args, &block)
|
6
6
|
options = ::RSpec::Core::Metadata.build_hash_from(args)
|
7
7
|
options.update(:skip => ::RSpec::Core::Pending::NOT_YET_IMPLEMENTED) unless block
|
8
8
|
|
9
9
|
examples << Opal::RSpec::LegacyAsyncExample.new(self, desc, options, block)
|
10
|
-
examples.last
|
10
|
+
examples.last
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
attr_accessor :legacy_promise
|
15
|
-
|
15
|
+
|
16
16
|
def self.included(base)
|
17
17
|
base.extend ClassMethods
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
# Use {#async} instead.
|
21
21
|
#
|
22
22
|
# @deprecated
|
23
23
|
def run_async(&block)
|
24
24
|
async(&block)
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def async(&block)
|
28
28
|
begin
|
29
29
|
instance_eval &block
|
@@ -38,13 +38,12 @@ end
|
|
38
38
|
|
39
39
|
class Opal::RSpec::LegacyAsyncExample < ::RSpec::Core::Example
|
40
40
|
def initialize(example_group_class, description, user_metadata, example_block=nil)
|
41
|
-
|
42
|
-
legacy_promise_ex_block = lambda do
|
41
|
+
legacy_promise_ex_block = lambda do |example|
|
43
42
|
self.legacy_promise = Promise.new
|
44
43
|
instance_exec(example, &example_block)
|
45
44
|
self.legacy_promise
|
46
45
|
end
|
47
|
-
|
46
|
+
|
48
47
|
super example_group_class, description, user_metadata, legacy_promise_ex_block
|
49
48
|
end
|
50
49
|
end
|