Giter VIP home page Giter VIP logo

Comments (8)

ryanb avatar ryanb commented on July 29, 2024

I will not be pulling in significant feature changes until we have a better test suite because it is difficult to fully test this plugin manually. High-level capybara tests with a dummy Rails app would be ideal. This can be done similar to the rails plugin new command in the latest Rails 3.1 release.

Jasmine tests would also be nice to fully test the JavaScript API portion. See my private_pub project for an example of testing JavaScript through Jasmine.

from nested_form.

fxposter avatar fxposter commented on July 29, 2024

I had a little spike about using JS tests in nested_form. The result are not very good yet.

First - manually initializing dummy rails app inside specs is not as easy as I thought. If you use rack-test - everything is rather trivial, but if you want selenium or any other js interpreter - you should instantiate another rails server and work with it - so it need configs and other things. I didn't go further, but that will be rather hard, I think.

Another way to do acceptance testing is to use methods, that use guys from thoughtbot - generate new rails app, run specs on it, remove it. I didn't get very deep in that, so I'm not sure if this is the best thing we can do.

The other thing is to write unit tests with something like Jasmine having a pre-generated html form. The main problem here would be the need to test jquery / prototype version separately, but for now I think this will be the easiest way to achieve JS testing.

from nested_form.

ryanb avatar ryanb commented on July 29, 2024

First - manually initializing dummy rails app inside specs is not as easy as I thought. If you use rack-test - everything is rather trivial, but if you want selenium or any other js interpreter - you should instantiate another rails server and work with it - so it need configs and other things. I didn't go further, but that will be rather hard, I think.

Hmm, have you tried using the capybara and the Selenium support there? Maybe try another JS adapter like capybara-webkit?

Another way to do acceptance testing is to use methods, that use guys from thoughtbot - generate new rails app, run specs on it, remove it. I didn't get very deep in that, so I'm not sure if this is the best thing we can do.

This is basically how I test Nifty Generators, but it is quite slow and I don't think necessary here. I would rather stick to the pattern of rails plugin new that Rails 3.1 provides.

The other thing is to write unit tests with something like Jasmine having a pre-generated html form. The main problem here would be the need to test jquery / prototype version separately, but for now I think this will be the easiest way to achieve JS testing.

I would like Jasmine unit tests as well, but I think acceptance-level tests are more critical at this point in time. Thanks for working on this!

from nested_form.

fxposter avatar fxposter commented on July 29, 2024

Hmm, have you tried using the capybara and the Selenium support there? Maybe try another JS adapter like capybara-webkit?

I tried Capybara + Selenium + manually made Rails.application object. Rack-test works cause it uses in-process app, as I understood, but Selenium driver boots another app instance, so the best way to implement acceptance tests - to generate apps on the fly or embed them inside project (as Jose Valim do in his "Crafting Rails Applications"). The other problem in this case - to support Rails 3.0 and 3.1.

from nested_form.

fxposter avatar fxposter commented on July 29, 2024

Looked at rails plugin new. That's exactly what Jose used, but for supporting 3.0/3.1 we should make 2 almost identical apps and make them use different Gemfiles, etc.

from nested_form.

ryanb avatar ryanb commented on July 29, 2024

Looked at rails plugin new. That's exactly what Jose used, but for supporting 3.0/3.1 we should make 2 almost identical apps and make them use different Gemfiles, etc.

I would be happy with just focusing our tests on Rails 3.1 for now. We could probably do a simplified set of 3.0 tests later just to ensure the builder works okay.

Right now my main concern is testing the JavaScript and how it interacts with the Rails form builder. That hasn't changed much across 3.0 to 3.1.

from nested_form.

fxposter avatar fxposter commented on July 29, 2024

Check it out: #58

from nested_form.

lest avatar lest commented on July 29, 2024

#58 was merged so this issue can be closed.

from nested_form.

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.