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.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +6 -0
  3. data/.gitignore +1 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +36 -26
  6. data/Appraisals +7 -0
  7. data/CHANGELOG.md +8 -0
  8. data/Gemfile +2 -4
  9. data/README.md +38 -16
  10. data/Rakefile +19 -7
  11. data/config.ru +3 -1
  12. data/gemfiles/opal_0.10_stable.gemfile +15 -0
  13. data/gemfiles/opal_master.gemfile +12 -15
  14. data/lib/opal/rspec/rake_task.rb +21 -8
  15. data/lib/opal/rspec/version.rb +1 -1
  16. data/lib/opal/rspec.rb +2 -2
  17. data/opal/opal/rspec/async/async_example.rb +5 -5
  18. data/opal/opal/rspec/async/example_group.rb +4 -4
  19. data/opal/opal/rspec/async/hooks.rb +2 -2
  20. data/opal/opal/rspec/async/legacy.rb +8 -9
  21. data/opal/opal/rspec/fixes/opal/compatibility.rb +3 -181
  22. data/opal/opal/rspec/fixes/opal.rb +0 -4
  23. data/opal/opal/rspec/fixes/rspec/core/metadata.rb +7 -26
  24. data/opal/opal/rspec/fixes/rspec/core.rb +0 -2
  25. data/opal/opal/rspec/fixes/rspec/example_groups.rb +0 -11
  26. data/opal/opal/rspec/fixes/rspec/expectations.rb +0 -1
  27. data/opal/opal/rspec/fixes/rspec/matchers/built_in/start_and_end_with.rb +0 -21
  28. data/opal/opal/rspec/fixes/rspec/mocks/error_generator.rb +0 -26
  29. data/opal/opal/rspec/fixes/rspec/support/spec/stderr_splitter.rb +13 -0
  30. data/opal/opal/rspec/fixes/rspec/support/spec.rb +1 -0
  31. data/opal/opal/rspec/fixes/rspec/support.rb +1 -1
  32. data/opal/opal/rspec/formatter/html_printer.rb +1 -1
  33. data/opal/opal/rspec/pre_require_fixes.rb +0 -5
  34. data/opal/opal/rspec/runner.rb +1 -1
  35. data/opal-rspec.gemspec +2 -3
  36. data/spec/mri/integration/browser_spec.rb +0 -3
  37. data/spec/mri/integration/spec_opts_spec.rb +1 -1
  38. data/spec/mri/unit/opal/rspec/browser_formatter_spec.rb +0 -3
  39. data/spec/mri/unit/opal/rspec/rack/config.ru +1 -1
  40. data/spec/mri/unit/opal/rspec/rake_task_spec.rb +60 -6
  41. data/spec/opal/after_hooks_spec.rb +26 -24
  42. data/spec/opal/around_hooks_spec.rb +2 -0
  43. data/spec/opal/async_spec.rb +22 -20
  44. data/spec/opal/before_hooks_spec.rb +20 -18
  45. data/spec/opal/example_spec.rb +4 -2
  46. data/spec/opal/matchers_spec.rb +3 -1
  47. data/spec/opal/mock_spec.rb +2 -0
  48. data/spec/opal/should_syntax_spec.rb +2 -0
  49. data/spec/opal/skip_pending_spec.rb +7 -5
  50. data/spec/opal/spec_helper.rb +4 -0
  51. data/spec/opal/subject_spec.rb +2 -0
  52. data/spec/rspec/core/filter/core/async/hooks.rb +0 -1
  53. data/spec/rspec/core/filter/core/async/metadata.rb +4 -0
  54. data/spec/rspec/core/filter/core/bugs/memoized_helpers.rb +0 -6
  55. data/spec/rspec/core/require_specs.rb +0 -1
  56. data/spec/rspec/expectations/config.rb +6 -1
  57. data/spec/rspec/expectations/filter/bugs/configuration.txt +0 -3
  58. data/spec/rspec/expectations/filter/bugs/contain_exactly.rb +0 -5
  59. data/spec/rspec/expectations/filter/bugs/define_negated_matcher.rb +0 -1
  60. data/spec/rspec/expectations/filter/bugs/dsl.rb +15 -0
  61. data/spec/rspec/expectations/filter/bugs/expectation_target.rb +4 -0
  62. data/spec/rspec/expectations/filter/bugs/expectations.rb +4 -0
  63. data/spec/rspec/expectations/filter/bugs/respond_to.rb +5 -11
  64. data/spec/rspec/expectations/filter/unsupported/dsl.rb +10 -0
  65. data/spec/rspec/expectations/fixes/example_patches.rb +0 -17
  66. data/spec/rspec/expectations/opal_alternates/dsl_spec.rb +2 -2
  67. data/spec/rspec/expectations/require_specs.rb +0 -1
  68. data/spec/rspec/filter_processor.rb +21 -5
  69. data/spec/rspec/mocks/filter/bugs/and_call_original.rb +11 -0
  70. data/spec/rspec/mocks/filter/bugs/and_yield.rb +4 -0
  71. data/spec/rspec/mocks/filter/bugs/any_instance.rb +1 -7
  72. data/spec/rspec/mocks/filter/bugs/partial_double.rb +5 -6
  73. data/spec/rspec/mocks/filter/bugs/stub_implementation.rb +0 -4
  74. data/spec/rspec/mocks/filter/unsupported/and_call_original.rb +7 -0
  75. data/spec/rspec/mocks/filter/unsupported/and_return.rb +4 -0
  76. data/spec/rspec/mocks/filter/unsupported/argument_matchers.rb +0 -3
  77. data/spec/rspec/mocks/filter/unsupported/combining_implementation_instructions.rb +0 -5
  78. data/spec/rspec/mocks/filter/unsupported/double.rb +0 -3
  79. data/spec/rspec/mocks/filter/unsupported/instance_double_with_class_loaded.rb +10 -0
  80. data/spec/rspec/mocks/filter/unsupported/nil_expectation_warning.rb +0 -4
  81. data/spec/rspec/mocks/filter/unsupported/partial_double.rb +0 -2
  82. data/spec/rspec/mocks/mocks_spec_loader.rb +1 -1
  83. data/spec/rspec/mocks/require_specs.rb +0 -1
  84. data/spec/rspec/mocks/spec_helper_opal.rb +2 -0
  85. data/spec/rspec/opal_rspec_spec_loader.rb +19 -4
  86. data/spec/rspec/support/filter/unsupported/fuzzy_matcher.rb +4 -0
  87. data/spec/rspec/support/filter/unsupported/support.rb +0 -3
  88. data/spec/rspec/support/require_specs.rb +0 -1
  89. metadata +27 -51
  90. data/opal/opal/rspec/fixes/opal/class.rb +0 -8
  91. data/opal/opal/rspec/fixes/opal/corelib/error.rb +0 -61
  92. data/opal/opal/rspec/fixes/opal/corelib/regexp.rb +0 -92
  93. data/opal/opal/rspec/fixes/opal/corelib/struct.rb +0 -260
  94. data/opal/opal/rspec/fixes/opal/corelib.rb +0 -3
  95. data/opal/opal/rspec/fixes/opal/kernel.rb +0 -80
  96. data/opal/opal/rspec/fixes/opal/stdlib/pp.rb +0 -23
  97. data/opal/opal/rspec/fixes/opal/stdlib/set.rb +0 -36
  98. data/opal/opal/rspec/fixes/opal/stdlib.rb +0 -2
  99. data/opal/opal/rspec/fixes/rspec/core/example_group.rb +0 -9
  100. data/opal/opal/rspec/fixes/rspec/core/reporter.rb +0 -14
  101. data/opal/opal/rspec/fixes/rspec/expectations/syntax.rb +0 -25
  102. data/opal/opal/rspec/fixes/rspec/support/fuzzy_matcher.rb +0 -23
  103. data/opal/opal/rspec/fixes/rspec/support/ruby_features.rb +0 -8
  104. data/spec/rspec/core/filter/core/async/metadata.txt +0 -2
  105. data/spec/rspec/core/filter/core/unsupported/metadata_filter.txt +0 -2
  106. data/spec/rspec/core/fixes/opal_itself.rb +0 -38
  107. data/spec/rspec/expectations/filter/bugs/aliases.rb +0 -13
  108. data/spec/rspec/expectations/filter/bugs/be.rb +0 -4
  109. data/spec/rspec/expectations/filter/bugs/be_instance_of.rb +0 -7
  110. data/spec/rspec/expectations/filter/bugs/description_generation.rb +0 -4
  111. data/spec/rspec/expectations/filter/bugs/dsl.txt +0 -14
  112. data/spec/rspec/expectations/filter/bugs/expectation_target.txt +0 -2
  113. data/spec/rspec/expectations/filter/bugs/expectations.txt +0 -2
  114. data/spec/rspec/expectations/filter/bugs/have_attributes.rb +0 -8
  115. data/spec/rspec/expectations/filter/bugs/include.rb +0 -4
  116. data/spec/rspec/expectations/filter/unsupported/dsl.txt +0 -8
  117. data/spec/rspec/expectations/filter/unsupported/respond_to.rb +0 -5
  118. data/spec/rspec/expectations/fixes/opal_itself.rb +0 -140
  119. data/spec/rspec/mocks/filter/bugs/and_call_original.txt +0 -9
  120. data/spec/rspec/mocks/filter/bugs/argument_matchers.rb +0 -3
  121. data/spec/rspec/mocks/filter/bugs/double.txt +0 -3
  122. data/spec/rspec/mocks/filter/bugs/methods.rb +0 -5
  123. data/spec/rspec/mocks/filter/unsupported/and_call_original.txt +0 -5
  124. data/spec/rspec/mocks/filter/unsupported/and_return.txt +0 -2
  125. data/spec/rspec/mocks/filter/unsupported/expected_arg_verification.txt +0 -2
  126. data/spec/rspec/mocks/filter/unsupported/instance_double_with_class_loaded.txt +0 -8
  127. data/spec/rspec/mocks/filter/unsupported/receive_message_chain.rb +0 -4
  128. data/spec/rspec/mocks/filter/unsupported/stub.rb +0 -7
  129. data/spec/rspec/mocks/fixes/opal_itself.rb +0 -59
  130. data/spec/rspec/support/filter/unsupported/fuzzy_matcher.txt +0 -2
  131. 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: 1da9042a8eae6f23afb1f989cd88ac73bb16bf2b
4
- data.tar.gz: 199ade21ce80c64e09f5123ecadd37d156c7cde9
3
+ metadata.gz: 882a14ef615ce8c04e42e0251c20689eab6d0cb9
4
+ data.tar.gz: 7ace5634304dc7cd953aa5de1af4ad1c31140586
5
5
  SHA512:
6
- metadata.gz: 07fd2261509f2ac82c45866d6acbce58db865a75e08fb04ae48ab8047589781b70b940f1f00b419b07ae35118a692ddb0af27e3ea9a5089a01cb06dc514359a9
7
- data.tar.gz: fa16038e70c8daa6cd27ac081a295fdba6c9bb3f96e353e72446173cce572eca39945d3a0782cd23c04f852807fd2b435f8f6d33b09fdf3ba9334308b03d0283
6
+ metadata.gz: c18a02f4f4fd2221c5a1baf9976a7ce0298c3511694cf41c622ba07d19ffb3f02c80f596ad1fef813588422454e0b3ae35623d3a3daf81d796c249e4b74cccd5
7
+ data.tar.gz: c49795363ee60fd59e6308767e5c97605a697e6ad9d1adcf0a82ae6492363db2e7f28ac4a795dc8674baeb9a70e63498be3713cf0d8773722922323a78a8d975
data/.codeclimate.yml ADDED
@@ -0,0 +1,6 @@
1
+ exclude_paths:
2
+ - rspec/**/*
3
+ - rspec-core/**/*
4
+ - rspec-expectations/**/*
5
+ - rspec-mocks/**/*
6
+ - rspec-support/**/*
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ Gemfile.lock
3
3
  *.gem
4
4
  Gemfile.lock
5
5
  gemfiles/*.lock
6
+ /tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ -c
2
+ -f d
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
- # - rvm: 1.9.3
12
- # env: RUN=default
13
- - rvm: 2.0.0
14
- env: RUN=default
15
- - rvm: 2.1.0
16
- env: RUN=default
17
- - rvm: 2.2.3
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
- # https://github.com/travis-ci/travis-ci/issues/3225 - Easiest way to use 2.0 on Travis
22
- env: RUN=default PHANTOMJS=2.0
23
- before_script:
24
- - "mkdir phantom20"
25
- - "export PATH=`pwd`/phantom20:$PATH"
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
- - "pushd ."
28
- - "cd phantom20"
29
- - "curl -L -O https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2"
30
- - "tar xjvf phantomjs-2.0.0-ubuntu-12.04.tar.bz2"
31
- - "popd"
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
- - git submodule update --init
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
@@ -0,0 +1,7 @@
1
+ appraise 'opal-0.10-stable' do
2
+ gem 'opal', git: 'https://github.com/opal/opal.git', branch: '0-10-stable'
3
+ end
4
+
5
+ appraise 'opal-master' do
6
+ gem 'opal', git: 'https://github.com/opal/opal.git'
7
+ end
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
- # Opal 0.9 still in development
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 rspec for opal.
7
+ An attempt at a compatibility layer of RSpec for Opal.
6
8
 
7
- [See the website for documentation](http://opalrb.org/docs/rspec/).
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 1.9.8 or 2.0 for Rake task testing
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 'default_path' setting to change that
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
- * Backtrace info on specs is buggy ([no Kernel::caller method in Opal](https://github.com/opal/opal/issues/894)), in Firefox w/ the browser runner, no backtraces show up with failed specs
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 0.8. Status of changing this via config has not been tested in Opal 0.9.
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
- * arity checking is not enabled by default in Opal but it can be. It's not currently enabled because it broke a lot of Opal specs. As a result, any matcher use (particularly respond_to) that depends on arity checking will not work
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
- * `and_throw` does not work on Opal 0.8 since throw/catch was not implemented until Opal 0.9
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
- :verify_rspec_support_specs,
67
- :verify_rspec_core_specs,
68
- :verify_rspec_expectation_specs,
69
- :verify_rspec_mocks_specs
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::Processor.stubbed_files, # stubs already specified in lib/opal/rspec.rb
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::Processor.source_map_enabled = false
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
- source 'https://rubygems.org'
2
- gemspec path: '../'
1
+ # This file was generated by Appraisal
3
2
 
4
- unless Dir['rspec{,-{core,expectations,mocks,support}}'].any?
5
- warn 'Run: "git submodule update --init" to get RSpec sources'
6
- end
3
+ source "https://rubygems.org"
7
4
 
8
- gem 'opal', git: 'https://github.com/opal/opal.git'
9
- gem 'capybara-webkit', require: false
10
- gem 'selenium-webdriver', require: false
11
-
12
- # These need to come from our local path in order for create_requires.rb to work properly
13
- gem 'rspec', path: '../rspec'
14
- gem 'rspec-support', path: '../rspec-support'
15
- gem 'rspec-core', path: '../rspec-core'
16
- gem 'rspec-mocks', path: '../rspec-mocks'
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 => "../"
@@ -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::Processor.load_asset_code(sprockets, name)
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
- :app => app,
107
- :Port => PORT,
108
- :AccessLog => [],
109
- :Logger => WEBrick::Log.new("/dev/null"),
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
- if `phantomjs -v`.nil?
117
- warn "Could not find phantomjs command"
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
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  module RSpec
3
- VERSION = '0.5.0'
3
+ VERSION = '0.6.0.beta1'
4
4
  end
5
5
  end
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::Processor.dynamic_require_severity = :ignore
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
- stubs.each {|mod| Opal::Processor.stub_file mod }
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 our_examples_result if descendants.empty?
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 true if examples.empty?
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 true
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 result
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
- example = self
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