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

Enable require.js mode. #34

Closed
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
10 participants
@brendanjerwin

brendanjerwin commented May 13, 2011

If the yml file contains a require_js element with the url fragment to require.js, then the server will switch to CommonJS amd module mode.

It will no longer directly load any source files, but will expect that the specs are declared as modules taking dependencies on the appropriate source files.

Anyone interested in playing with this, I have a gem you can try out:

https://github.com/downloads/brendanjerwin/jasmine-gem/jasmine-1.0.3.0pre.gem

Enable require.js mode.
If the yml file contains a `require_js` element with the url fragment to require.js, then the server will switch to CommonJS amd module mode.

It will no longer directly load any source files, but will expect that the specs are declared as modules taking dependencies on the appropriate source files.
@brendanjerwin

This comment has been minimized.

Show comment
Hide comment
@brendanjerwin

brendanjerwin May 13, 2011

I did not add an example section in the yml file. I think I saw more than one and wasn't sure which to modify.

brendanjerwin commented May 13, 2011

I did not add an example section in the yml file. I think I saw more than one and wasn't sure which to modify.

@brendanjerwin

This comment has been minimized.

Show comment
Hide comment
@brendanjerwin

brendanjerwin May 13, 2011

Be sure to add a single item to the yml file, not a list:

require_js: lib/require.js

not

require_js: 
    - lib/require.js

brendanjerwin commented May 13, 2011

Be sure to add a single item to the yml file, not a list:

require_js: lib/require.js

not

require_js: 
    - lib/require.js
@aiwilliams

This comment has been minimized.

Show comment
Hide comment
@aiwilliams

aiwilliams May 13, 2011

Unless I'm mistaken, it looks like this will have the helpers loading before the src files that are required. That's not how it worked before, with the src files before the helpers. Helpers may use code from the src files.

aiwilliams commented May 13, 2011

Unless I'm mistaken, it looks like this will have the helpers loading before the src files that are required. That's not how it worked before, with the src files before the helpers. Helpers may use code from the src files.

@brendanjerwin

This comment has been minimized.

Show comment
Hide comment
@brendanjerwin

brendanjerwin May 14, 2011

True enough. I should remove the loading of helpers all together and let require.js handle the loading. Then any dependencies /load order issues can be taken care of correctly.

brendanjerwin commented May 14, 2011

True enough. I should remove the loading of helpers all together and let require.js handle the loading. Then any dependencies /load order issues can be taken care of correctly.

Ignores helpers if in require.js mode.
Modified the erb to expect that the require.js configuration be an array. Now any require.js configuration can be done prior to using require.js.
@brendanjerwin

This comment has been minimized.

Show comment
Hide comment
@brendanjerwin

brendanjerwin May 14, 2011

There, now it ignores helpers. It works fine to simply require the helpers needed, and if they need access to the code under test, they can just require those modules.

Also, now the require_js configuration option is expected to be an array. If something must load before the specs, it can be put there.

brendanjerwin commented May 14, 2011

There, now it ignores helpers. It works fine to simply require the helpers needed, and if they need access to the code under test, they can just require those modules.

Also, now the require_js configuration option is expected to be an array. If something must load before the specs, it can be put there.

@jgonera

This comment has been minimized.

Show comment
Hide comment
@jgonera

jgonera Aug 7, 2011

Will this get merged to the official gem at some point?

jgonera commented Aug 7, 2011

Will this get merged to the official gem at some point?

@brendanjerwin

This comment has been minimized.

Show comment
Hide comment
@brendanjerwin

brendanjerwin Aug 7, 2011

Probably not as is. This works for us but I think it's best thought of as a proof if concept.

brendanjerwin commented Aug 7, 2011

Probably not as is. This works for us but I think it's best thought of as a proof if concept.

@ragaskar

This comment has been minimized.

Show comment
Hide comment
@ragaskar

ragaskar Aug 27, 2011

Contributor

Yeah, I feel like it's best for us to put off addressing this issue until the next release, where we can take on all the new JS challenges that Rails 3.1 and other frameworks are now presenting. Apologies for making it difficult for those of you that use require_js, but we want to get 1.1 (mostly bugfixes and a minor gem refactor) out within the week. We'll probably have a substantial refactoring of Jasmine coming soon, as it's getting pretty creaky.

Contributor

ragaskar commented Aug 27, 2011

Yeah, I feel like it's best for us to put off addressing this issue until the next release, where we can take on all the new JS challenges that Rails 3.1 and other frameworks are now presenting. Apologies for making it difficult for those of you that use require_js, but we want to get 1.1 (mostly bugfixes and a minor gem refactor) out within the week. We'll probably have a substantial refactoring of Jasmine coming soon, as it's getting pretty creaky.

@ragaskar ragaskar closed this Aug 27, 2011

@brendanjerwin

This comment has been minimized.

Show comment
Hide comment
@brendanjerwin

brendanjerwin Aug 29, 2011

Another thing to keep in mind when enabling require_js support for real: https://github.com/JamesMaroney/requirejs-isolate

This plugin helps to isolate the code under test.

brendanjerwin commented Aug 29, 2011

Another thing to keep in mind when enabling require_js support for real: https://github.com/JamesMaroney/requirejs-isolate

This plugin helps to isolate the code under test.

@andrewdeandrade

This comment has been minimized.

Show comment
Hide comment
@andrewdeandrade

andrewdeandrade Dec 17, 2011

Now that Jasmine is at 1.1, can we get this issue reopened? jwhitley's requirejs-rails gem is now at 0.5.1 and one of the items slated for the 1.0 build is jasmine support. From what I've grokked so far, the only way to get require.js support working in his gem would be to get support for require.js into the jasmine gem.

https://github.com/jwhitley/requirejs-rails/

andrewdeandrade commented Dec 17, 2011

Now that Jasmine is at 1.1, can we get this issue reopened? jwhitley's requirejs-rails gem is now at 0.5.1 and one of the items slated for the 1.0 build is jasmine support. From what I've grokked so far, the only way to get require.js support working in his gem would be to get support for require.js into the jasmine gem.

https://github.com/jwhitley/requirejs-rails/

@nfedyashev

This comment has been minimized.

Show comment
Hide comment
@nfedyashev

nfedyashev Jan 10, 2012

@malandrew
+1 for reopening

Meanwhile:

https://github.com/millermedeiros/amd-utils/tree/master/tests perhaps this may help someone

nfedyashev commented Jan 10, 2012

@malandrew
+1 for reopening

Meanwhile:

https://github.com/millermedeiros/amd-utils/tree/master/tests perhaps this may help someone

@jmaicher

This comment has been minimized.

Show comment
Hide comment
@jmaicher

jmaicher Jan 22, 2012

I'd love to see some official support, too!
Meanwhile this could also help: https://github.com/scottburch/jasmine-require

jmaicher commented Jan 22, 2012

I'd love to see some official support, too!
Meanwhile this could also help: https://github.com/scottburch/jasmine-require

@tatemae

This comment has been minimized.

Show comment
Hide comment
@tatemae

tatemae Mar 10, 2012

+1 for require.js support. We're in the process of trying to hack a solution together, but it would be nice to have official support.

tatemae commented Mar 10, 2012

+1 for require.js support. We're in the process of trying to hack a solution together, but it would be nice to have official support.

@flipkick

This comment has been minimized.

Show comment
Hide comment
@flipkick

flipkick Aug 14, 2012

+1 for reopening

flipkick commented Aug 14, 2012

+1 for reopening

@infews

This comment has been minimized.

Show comment
Hide comment
@infews

infews Aug 14, 2012

Contributor

We still plan on better async loading support in a future release. In the meantime: https://github.com/mattfysh/testr.js is your best bet.

Contributor

infews commented Aug 14, 2012

We still plan on better async loading support in a future release. In the meantime: https://github.com/mattfysh/testr.js is your best bet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment