Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uninitialized constant OPAL_PLATFORM #78

Closed
anharu2394 opened this issue Nov 2, 2018 · 8 comments
Closed

uninitialized constant OPAL_PLATFORM #78

anharu2394 opened this issue Nov 2, 2018 · 8 comments

Comments

@anharu2394
Copy link

anharu2394 commented Nov 2, 2018

opal (~> 0.11.0)
opal-rspec (0.7.0.rc.2)

I try to run specs in browser.
when run bundle exec rackup command,the error occurs.
image

config.ru

require 'bundler'
Bundler.require
require 'opal/rspec'
sprockets_env = Opal::RSpec::SprocketsEnvironment.new(spec_pattern='spec/opal/*_spec.{rb,opal}')
run Opal::Sprockets::Server.new(sprockets: sprockets_env) { |s|
  s.main = 'opal/rspec/sprockets_runner'
	s.append_path 'spec/opal'
  sprockets_env.add_spec_paths_to_sprockets
  s.debug = false
}
@merongivian
Copy link

Can confirm. I have the same issue with version '0.7.0.rc.2'

@elia
Copy link
Member

elia commented Nov 5, 2018

Please try adding a require 'opal/platform' in your spec or spec_helper and see if it works.

@anharu2394
Copy link
Author

anharu2394 commented Nov 6, 2018

tha same error occured again.
image

My spec_helper.rb

require "bundler/setup"
require "rubelm"
require "opal-browser"
require 'opal/platform'

RSpec.configure do |config|
  # Enable flags like --only-failures and --next-failure
  config.example_status_persistence_file_path = ".rspec_status"

  # Disable RSpec exposing methods globally on `Module` and `main`
  config.disable_monkey_patching!

  config.expect_with :rspec do |c|
    c.syntax = :expect
  end
end

@anharu2394
Copy link
Author

How is the problem solved?

@elia
Copy link
Member

elia commented Nov 8, 2018

Ok, found a temporary solution

add spec/opal/custom_sprockets_runner.rb with this content:

require 'opal'
require 'opal/platform'
require 'opal/rspec/sprockets_runner'

then replace the main file in config.ru with opal/custom_sprockets_runner.rb


meanwhile I'll fix it on master, let me know how it goes 👍

@anharu2394
Copy link
Author

I 'll try it.

@anharu2394
Copy link
Author

anharu2394 commented Nov 8, 2018

My config.ru

require 'bundler'
Bundler.require
require 'opal/rspec'
sprockets_env = Opal::RSpec::SprocketsEnvironment.new(spec_pattern='spec/opal/*_spec.{rb,opal}')
run Opal::Sprockets::Server.new(sprockets: sprockets_env) { |s|
  s.main = 'opal/custom_sprockets_runner.rb'
	s.append_path 'spec/opal'
  sprockets_env.add_spec_paths_to_sprockets
  s.debug = false
}

My spec/opal/custom_sprockets_runner.rb

require 'opal'
require 'opal/platform'
require 'opal/rspec/sprockets_runner'

But running bundle exec rackup,the error occured.
RuntimeError: Cannot find asset: opal/custom_sprockets_runner.rb
image

I edit config.ru

require 'bundler'
Bundler.require
require 'opal/rspec'
sprockets_env = Opal::RSpec::SprocketsEnvironment.new(spec_pattern='spec/opal/*_spec.{rb,opal}')
run Opal::Sprockets::Server.new(sprockets: sprockets_env) { |s|
  s.main = 'custom_sprockets_runner'
	s.append_path 'spec/opal'
  sprockets_env.add_spec_paths_to_sprockets
  s.debug = false
}

And, I can successfully run bundle exec rackup
image
image

Thank you very much!!!!!!!!!

@elia
Copy link
Member

elia commented Nov 9, 2018

yeah sorry, I got the path wrong 😄

Anyway I pushed the fix to master, you should be able to use the original code by pointing to the github gem in your Gemfile:

gem 'opal-rspec', git: 'https://github.com/opal/opal-rspec', submodules: true

@elia elia closed this as completed Nov 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants