rspec / rspec.github.io

source for rspec.info
http://rspec.info/
Other
15 stars 41 forks source link

Reminder: Should have a /try section powered by opal-rspec #66

Open elia opened 9 years ago

elia commented 9 years ago

@dchelimsky @elia @adambeynon @opalrb Amazing. Would be cool to include something like that on the new rspec site /cc @mootpointer

@myronmarston

Demo:

http://opal.github.io/opal-playground/rspec/

Code:

https://github.com/opal/opal-playground/blob/master/source/rspec.html.haml https://github.com/opal/opal-playground/blob/master/source/javascripts/playground-rspec.js.rb

myronmarston commented 9 years ago

I had forgotten about that discussion and the opal site! I'd definitely still like to see something like this on our site. Thoughts, @JonRowe?

myronmarston commented 9 years ago

I noticed that the opal-rspec Repo is vendoring RSpec and is pinned to 3.0.0.beta1 (which is 15 months old!). Why is it necessary to vendor RSpec? And can it be updated to RSpec 3.2?

elia commented 9 years ago

The only issue I know about was with the custom require system from rspec-support.

It's vendored to let people use a different version in CRuby world.

That said probably @adambeynon knows better

myronmarston commented 9 years ago

The only issue I know about was with the custom require system from rspec-support.

Ah, I didn't realize that caused you problems. It's done in order to use require-relative on ruby versions that support that, since that is always O(1) regardless of how many entries you have on your load path, compared to O(N) for require. Maybe we can find a way to solve the problems for you so you don't have to vendor anymore?

elia commented 9 years ago

Would be great!

The other usual pain point with gems is the use of mutable strings, currently some monkey patching is in place for them:

https://github.com/opal/opal-rspec/blob/master/opal/opal/rspec/fixes.rb

myronmarston commented 9 years ago

What specifically is the problem with the custom require in rspec-support? Assume I know nothing about opal (since I practically do).

elia commented 9 years ago

All files in opal must be precompiled to js before they're required. Currently the compiler catches method calls to require and require_relative and tries to get the path (eg a static string is easy). With the list of requires from a given file we can go and precompiled them too so they're available at runtime.

The problem is with dynamic requires (eg passing a local var or method call to require) wich can't be inferred automatically. That is the case with rspec requires.

Just for the record all precompiled files go in a js object literal (Opal.modules) with the "logical path" as the key and the compiled file wrapped in an anonymous function as the value.

Hope the explanation was clear :)

Btw I did an experiment with 3.2 and requiring everything manually seems to work, the tricky part being getting the require order right. I still see some issues with autoload tho.

JonRowe commented 9 years ago

I'm onboard with having this provided we can embed it into our site and it works reliably! Would be nicer to have console looking output rather than the html output, maybe we can feed it into ascii cinema somehow to have that faux "it's doing something" look :)

elia commented 9 years ago

Status update: @wied03 is in the process of running rspec specs in opal-rspec and the upgrade to the latest version https://github.com/opal/opal-rspec/issues/30

Bringing this to attention in case he needs any help or has questions specific to rspec

wied03 commented 9 years ago

Hi guys.

Just in case it wasn't clear before, it's vendored (now using git submodules at RSpec 3.1) for the reason @ella mentioned (versioning) and also to avoid monkey patching someone who is using RSpec with MRI. I suppose if we can get current and be more robust with how we do things, we could eventually get rid of that and just work w/ whatever version of RSpec GEM the user has (and only monkey patch it when they use it inside Opal).

As to more recent work, I'm slowly but surely going through the rspec-core specs and making fixes or filtering specs that I don't expect to pass.

Anyways, the idea is to get through the specs for core, expectations, and mocks. Then hopefully we have a better baseline and it will be easier to stay more current.

In the meantime, I've also broken out the monkey patch fixes, mirroring the original directory structure, so that it's easier to see what's being patched: https://github.com/wied03/opal-rspec/tree/features/rspec_specs/opal/opal/rspec/fixes

wied03 commented 9 years ago

An update, we got through the expectations, core, support, and mock specs and the code at the master branch of https://github.com/opal/opal-rspec has been updated. A new beta will be coming soon. There are a decent amount of filters in place for what's not working with more documentation in the README about that.

Most of the failed specs/features are due to the following:

benoittgt commented 4 years ago

Do we still want to make this @JonRowe ?

pirj commented 4 years ago

That would be insanely cool, but I doubt very often used :D

JonRowe commented 4 years ago

If someone where to make it work I'd be happy to see it on the website, but equally I'm not stressed about it.