opal / opal-rspec

Opal + RSpec = ♥️
https://opalrb.com/docs/guides/master/rspec.html
61 stars 15 forks source link

spec not worked with opal 0.11. (chrome headless) #72

Closed zw963 closed 6 years ago

zw963 commented 6 years ago

Following spec is worked with 0.10.5 on phantomjs, but when swtich to 0.11.0,

when run rake command in command line, got following error message:

DEPRECATION WARNING: `require 'opal/server` and `Opal::Server` are deprecated in favor of `require 'opal/sprockets/server'` and `Opal::Sprockets::Server` (now part of the opal-sprockets gem).
Running phantomjs /home/zw963/.rvm/gems/ruby-2.3.4@opal_rspec_example/gems/opal-rspec-0.6.1/vendor/spec_runner.js "http://localhost:9999/"
opal/rspec/async/example_group:13:17: warning: `&' interpreted as argument prefix
opal/rspec/async/example_group:13:     result.then &block
opal/rspec/async/example_group:13:                 ^     
opal/rspec/async/legacy:29:25: warning: `&' interpreted as argument prefix
opal/rspec/async/legacy:29:           instance_eval &block
opal/rspec/async/legacy:29:                         ^     
Object freezing is not supported by Opal

support_warn_with: undefined method `support_warn_with' for RSpec

  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:5148 in raise
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:3820 in method_missing
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:1197 in method_missing_stub
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:57969 in warn_with
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:38130 in warning
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:27937 in global_options_file
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:27877 in global_options
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:27830 in file_options
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:27718 in organize_options
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:27684 in initialize
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:1605 in send
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:3532 in new
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:59583 in run
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:59549 in autorun
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:63093
  http://localhost:9999/assets/opal/rspec/sprockets_runner.js:2192 in load

After change runner to headless chrome. (headless chrome is worked with hello world),

require 'bundler'
Bundler.require
require 'opal/rspec/rake_task'

Opal::RSpec::RakeTask.new(:default) do |server, task|
  # 如果需要完全改写 load paths, 使用 task.default_path = 'spec/javascripts', 奇怪, 这里是 task, 而不是 server!
  task.runner = :chrome
  server.append_path 'lib'
  server.append_path 'node_modules'
  # task.timeout = 5000          # 修改 phantomjs timeout 时间, 有时候运行失败, 需要等很久才能退出.
end

Still got following error:

DEPRECATION WARNING: `require 'opal/server` and `Opal::Server` are deprecated in favor of `require 'opal/sprockets/server'` and `Opal::Sprockets::Server` (now part of the opal-sprockets gem).
opal/rspec/async/example_group:13:17: warning: `&' interpreted as argument prefix
opal/rspec/async/example_group:13:     result.then &block
opal/rspec/async/example_group:13:                 ^     
opal/rspec/async/legacy:29:25: warning: `&' interpreted as argument prefix
opal/rspec/async/legacy:29:           instance_eval &block
opal/rspec/async/legacy:29:                         ^     
Passing a sprockets environment to Opal::Sprockets.load_asset no more needed.
  /home/zw963/.rvm/gems/ruby-2.3.4@opal_rspec_example/gems/opal-rspec-0.6.1/lib/opal/rspec/rake_task.rb:39:in `get_load_asset_code'
  /home/zw963/.rvm/gems/ruby-2.3.4@opal_rspec_example/gems/opal-rspec-0.6.1/lib/opal/rspec/rake_task.rb:51:in `block in launch_node'
  /home/zw963/.rvm/rubies/ruby-2.3.4/lib/ruby/2.3.0/net/http.rb:853:in `start'
Running node /tmp/opal_rspec.js20171231-10388-q1olpf 2>&1
Object freezing is not supported by Opal

/tmp/opal_rspec.js20171231-10388-q1olpf:5148
      throw exception;
      ^
support_warn_with: undefined method `support_warn_with' for RSpec
zw963 commented 6 years ago

this is my spec example project url: https://github.com/zw963/opal_rspec_example

elthariel commented 6 years ago

Same problem here with phantomjs runner or directly in browser

fazibear commented 6 years ago

Same problem also with phantomjs: https://travis-ci.org/inesita-rb/inesita

elia commented 6 years ago

It's still WIP and very unstable, but some work has been done on the elia/master branch (see https://github.com/opal/opal-rspec/pull/74).

fazibear commented 6 years ago

Tried to use 0.7.0rc2 but with no luck:


/tmp/opal-nodejs-runner-20180818-5161-1il32su:292
    if (value.$$is_a_module) {
              ^
TypeError: Cannot read property '$$is_a_module' of undefined
    at Object.Opal.const_set (/tmp/opal-nodejs-runner-20180818-5161-1il32su:292:15)
    at /tmp/opal-nodejs-runner-20180818-5161-1il32su:64190:12
    at /tmp/opal-nodejs-runner-20180818-5161-1il32su:64249:7
    at Opal.modules.inesita/browser (/tmp/opal-nodejs-runner-20180818-5161-1il32su:64250:5)
    at Object.Opal.load (/tmp/opal-nodejs-runner-20180818-5161-1il32su:2192:7)
    at Object_alloc.Opal.require [as $require] (/tmp/opal-nodejs-runner-20180818-5161-1il32su:2216:17)
    at Opal.modules.inesita (/tmp/opal-nodejs-runner-20180818-5161-1il32su:64699:8)
    at Object.Opal.load (/tmp/opal-nodejs-runner-20180818-5161-1il32su:2192:7)
    at Object_alloc.Opal.require [as $require] (/tmp/opal-nodejs-runner-20180818-5161-1il32su:2216:17)
    at Opal.modules.spec_helper (/tmp/opal-nodejs-runner-20180818-5161-1il32su:64716:15)```
gfowley commented 6 years ago

FWIW this is no longer a problem for me with opal 0.11.3 and opal-rspec 0.7.0.rc.2.

elia commented 6 years ago

I'll close this, @fazibear ping me if you have repro instructions and I'll reopen.

zw963 commented 6 years ago

awesome, i will try it recent days, and will report here.

Thanks @elia !

zw963 commented 6 years ago

Hi, It seem like still not worked for me (maybe some low level error happen here ..., i leave opal almost one year ...)

 ╭─ 14:05  zw963 ⮀ ~/Project/opal/update_to_0.11_not_success/opal_rspec_example ⮀ ⭠ (d40b1f2) master *+  ➦ ruby-2.3.3@opal_rspec_example 
 ╰─ $ bundle exec rake
Connecting to localhost:9222...
/usr/lib64/chromium/chromium --headless --disable-gpu --remote-debugging-port=9222 
Connecting to localhost:9222...
Connecting to localhost:9222...
[1111/140629.286066:ERROR:gpu_process_transport_factory.cc(980)] Lost UI shared context.

DevTools listening on ws://127.0.0.1:9222/devtools/browser/109eac29-fdda-4923-a624-df66bf838c9b
Connecting to localhost:9222...
Object freezing is not supported by Opal
WARNING: Unable to find ~/.rspec because the HOME environment variable is not set. Called from .
undefined : object.$respond_to? is not a function
    at coerce_to (file:///tmp/chrome-opal.js:2330:40)
    at exit (file:///tmp/chrome-opal.js:4104:59)
    at call (file:///tmp/chrome-opal.js:18126:25)

 ╭─ 14:06  zw963 ⮀ ~/Project/opal/update_to_0.11_not_success/opal_rspec_example ⮀ ⭠ (d40b1f2) master *+  ➦ ruby-2.3.3@opal_rspec_example 
 ╰─ $ /usr/lib64/chromium/chromium --version
Chromium 70.0.3538.77 
anharu2394 commented 5 years ago

I have the same problem using headless chrome.

anharu2394 commented 5 years ago

Probably, to update Opal-Rspec to 0.7.1, object.$respond_to? is not a function error doesn't occur.