-
Notifications
You must be signed in to change notification settings - Fork 507
Improve tests #22
Comments
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 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. |
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. |
Hmm, have you tried using the capybara and the Selenium support there? Maybe try another JS adapter like capybara-webkit?
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
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! |
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. |
Looked at |
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. |
Check it out: #58 |
#58 was merged so this issue can be closed. |
The tests need a lot of work. They should be changed to use RSpec request specs with Capybara and a sample Rails app. This way I can mimic the functionality and test JavaScript too.
The text was updated successfully, but these errors were encountered: