Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Improve tests #22

Closed
ryanb opened this issue Mar 26, 2011 · 8 comments
Closed

Improve tests #22

ryanb opened this issue Mar 26, 2011 · 8 comments
Labels

Comments

@ryanb
Copy link
Owner

ryanb commented Mar 26, 2011

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.

@ryanb
Copy link
Owner Author

ryanb commented Jun 29, 2011

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.

@fxposter
Copy link
Contributor

fxposter commented Jul 3, 2011

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.

@ryanb
Copy link
Owner Author

ryanb commented Jul 4, 2011

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!

@fxposter
Copy link
Contributor

fxposter commented Jul 5, 2011

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.

@fxposter
Copy link
Contributor

fxposter commented Jul 5, 2011

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.

@ryanb
Copy link
Owner Author

ryanb commented Jul 5, 2011

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.

@fxposter
Copy link
Contributor

Check it out: #58

@lest
Copy link
Collaborator

lest commented Jun 4, 2012

#58 was merged so this issue can be closed.

@lest lest closed this as completed Jun 4, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants