Code Monkey home page Code Monkey logo

Comments (22)

jmaicher avatar jmaicher commented on August 10, 2024

+1
Do you have any ideas so far?

from requirejs-rails.

jwhitley avatar jwhitley commented on August 10, 2024

@jmaicher After I get #13 nailed down (almost done), I'll be working on a Rails demo app (see #8). I plan on getting some simple Jasmine tests in there by way of example, and to explore what, if any, additional support is needed by this gem. Current ETA is early next week.

Thanks!

from requirejs-rails.

andrewdeandrade avatar andrewdeandrade commented on August 10, 2024

@jwhitley Got any ideas that I can explore in the meantime? I'm trying to get my tests working again. Here's a pull request in the jasmine-gem that seems like it might address this issue, but it was closed back in August and it doesn't look like it was ever pulled in.

jasmine/jasmine-gem#34

Here are some other relevant links I'm working through to try and figure this out that you may find useful:

http://japhr.blogspot.com/2011/12/jasmine-server-and-backbonejs-requirejs.html
http://japhr.blogspot.com/2011/12/jasmine-testing-of-requirejs-powered.html
http://groups.google.com/group/jasmine-js/browse_thread/thread/d10f59cba4d97792

from requirejs-rails.

andrewdeandrade avatar andrewdeandrade commented on August 10, 2024

Upon further investigation, the most generic solution that would not require explicit require.js support in jasmine would be to allow something more an array of hashes instead of an array of strings in :src_files in jasmine.yml. However I doubt this would ever be pulled in since it would break backward compatibility.

The only other approach I can think of would be similar to the approach suggested by brendanjerwin, which is to add a require_js: helper method to the jasmine gem.

from requirejs-rails.

jwhitley avatar jwhitley commented on August 10, 2024

No ideas right norm sorry. I've not been tracking Jasmine stuff too closely; been busy with the gem and other work. I should have more next week as I put the demo app together.

from requirejs-rails.

andrewdeandrade avatar andrewdeandrade commented on August 10, 2024

FYI: http://groups.google.com/group/jasmine-js/browse_thread/thread/6ba740ff058d35ea

from requirejs-rails.

jwhitley avatar jwhitley commented on August 10, 2024

Thanks for the heads-up. So monkey-patching it is...

from requirejs-rails.

jwhitley avatar jwhitley commented on August 10, 2024

Chris Strom did a nice writeup of integration between require.js and the jasmine gem for a Backbone app. See also Chris' demo repo that uses this approach.

This is all a bit unbaked right now, so I'm going to get some experience working with it in an app before implementing/recommending any particular approach just yet.

from requirejs-rails.

andrewdeandrade avatar andrewdeandrade commented on August 10, 2024

I'm actually thinking of abandoning Jasmine for Buster.JS, which isn't 1.0 yet, but really really nice. It's also being designed for proper AMD testing. It's from the same guy responsible for Sinon.js

features:
-- client side testing
----- headless via PhantomJS
----- browser or command line via a JsTestDriver approach that can be integrated with a CI server like Jenkins or Hudson)
-- server-side testing in node

Check it out: http://busterjs.org/

from requirejs-rails.

jwhitley avatar jwhitley commented on August 10, 2024

Thanks for the tip. The buzz on Buster seems very positive. I'll dive in shortly and see what's what. Hopefully this issue can be resolved with some quick docs on Buster.js setup.

from requirejs-rails.

andrewdeandrade avatar andrewdeandrade commented on August 10, 2024

BTW, I hacked together a quick gem that permits buster.js in a rails project:

https://github.com/malandrew/busterjs_on_rails

My gem is still really raw, but it has the minimum functionality needed to be able to run rake busterjs

I have yet to submit it to rubygems.org, so for the time being you'll have to point your Gemfile at my Github repo. This weekend, I'm going to try to get all the tests working and set up on travis and then I'll submit to rubygems.org

I'm working on a Guard gem for it as well, but I haven't gotten it to work just yet.

from requirejs-rails.

jwhitley avatar jwhitley commented on August 10, 2024

@malandrew Thanks. I'll have a look over the gem in the next day or two. For now, I'm tinkering around with adding Buster.js tests to an existing project to get a feel for it. The buzz on the requirejs list has been very positive.

from requirejs-rails.

jmaicher avatar jmaicher commented on August 10, 2024

Rajan Agaskar posted a simple guide in the jasmine-js google group [1] about how to set up jasmine-gem (edge) with the asset pipeline. In another post [2] Scott Burch introduced his jasmine-require helpers [3]. In combination this is pretty straightforward and works for me.

Buster.js sounds really promising but is currently under heavy development (internals rewrite).
From what the devs told me it's better to wait a few weeks until the "real" beta starts.

[1] http://groups.google.com/group/jasmine-js/browse_thread/thread/1919f00753d7b8df
[2] http://groups.google.com/group/jasmine-js/browse_thread/thread/6ba740ff058d35ea
[3] https://github.com/scottburch/jasmine-require

from requirejs-rails.

jwhitley avatar jwhitley commented on August 10, 2024

For the record, I'm unhappy with every existing solution for JS testing with RequireJS. I've got a working prototype that I'm going to publish shortly that addresses these concerns. Initially, it will be in the form of a demo Rails app that uses requirejs-rails, for early adopters and to back up a forthcoming issue on jasmine-gem. My goal will be to negotiate how changes can either be adapted into a pull request that Pivotal will be happy with, or else spun out as a separate plugin gem with appropriate config/API support integrated into jasmine-gem (I have to monkey patch jasmine-gem right now :-P )

from requirejs-rails.

jwhitley avatar jwhitley commented on August 10, 2024

I've published my take on this as documentation plus a new-Rails 3.2 app at requirejs-rails-jasmine-template. This really is about the integration of jasmine-gem and requirejs-rails, as opposed to the specific testing methodology. Various Jasmine helpers, tools like testr.js, etc. should all work fine in this environment.

from requirejs-rails.

smith avatar smith commented on August 10, 2024

This all looks like great stuff, thanks for looking at it.

I've been using https://github.com/jfirebaugh/konacha, and have got it barely working with some ugly hacks, but only in the browser, not with the selenium/capybara runner. It's not the greatest, but I have really become fond of http://visionmedia.github.com/mocha/ and http://chaijs.com/. Just wanted to throw those into the mix to see if anybody else is using these.

I really just need something that scans a directory of _spec.js files and turns them into a list of module dependencies that can be run with any runner. If I come up with any code or ideas I'll put them here.

from requirejs-rails.

smith avatar smith commented on August 10, 2024

Here's a fork of Konacha that integrates requirejs-rails: https://github.com/cramerdev/konacha/tree/requirejs

It works for me, but I don't think it should be part of Konacha, and I'm not sure I want to maintain a separate project, so any thought, comments, or ideas would be appreciated.

from requirejs-rails.

billmag avatar billmag commented on August 10, 2024

Quick update for anyone still watching this thread: I've created a new fork of this that is up to date with konacha as of 2.0.0.beta2 and my own fork of requirejs-rails which is using require.js 2.0.6 and the most recent r.js.

https://github.com/billmag/konacha
https://github.com/billmag/requirejs-rails

The error handling for failed module loads isn't as great as I'd like. I posted to the requirejs mailing list, we'll see what comes of that:
https://groups.google.com/forum/?fromgroups=#!topic/requirejs/SZgONWezt4s

from requirejs-rails.

billmag avatar billmag commented on August 10, 2024

Hey all -- I've updated my konacha fork to track the latest release of the konacha gem. I haven't updated with respect to requirejs-rails in a while, though.

from requirejs-rails.

Pickachu avatar Pickachu commented on August 10, 2024

👍

from requirejs-rails.

alxndr avatar alxndr commented on August 10, 2024

I've got some Jasmine 2 tests running in Rails 4 via requirejs-rails v0.9.5, taking cues from this post by Cina at Spiceworks:

  • monkeypatching Jasmine via jasmine_helper.rb (instead of jasmine_config.rb)
    • test runner file is specified by Jasmine.runner_template
  • customize jasmine's boot JS to pull the list of specs to run from content in the runner file, and pass it to require as dependencies for starting the test run (instead of starting the run on window.onload)

from requirejs-rails.

carsomyr avatar carsomyr commented on August 10, 2024

@alxndr Thanks for looking into this! I'm going to be investigating further.

from requirejs-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.