-
Website
http://roman.flucti.com -
Original page
http://roman.flucti.com/a-test-server-for-rails-applications -
Subscribe
All Comments -
Community
-
Top Commenters
-
sandal
1 comment · 2 points
-
chendo
4 comments · 1 points
-
August Lilleaas
1 comment · 1 points
-
drnic
6 comments · 6 points
-
Andión
2 comments · 1 points
-
-
Popular Threads
- only compatible with Rails 2.2.0,
- assumes that the "test" directory is present in the load path,
- assumes that RubyGems is loaded by the time test_heper.rb is evaluated, which is very unlikely on most systems.
I apologize for these issues. Thanks to Justin Ko for reporting them! Version 0.1.1 will fix them, and I'll announce its release in a new article.
Can't wait for 0.1.1!
Too...lazy... to... make ...patch :)
* Cmd+R from TextMate when viewing the test file
* ruby units/user_test.rb -> from the test folder itself - that is, if we're not in the root folder it fails.
We tried manually hacking the ENV['RUBYLIB'] at the top of the test_helper.rb to explicitly add the full path to the test folder, but it doesn't seem to help.
Thoughts?
http://github.com/chendo/rails-test-serving/com...
Hacking ENV['RUBYLIB'] at the top of test/test_helper.rb can't work since it's only used by the intepreter before trying to load the file.
Also ran into issues with clean_up_app nuking machinist blueprints, but should have a solution soon.
http://roman.flucti.com/textmate-fix-for-relati...
This article has been updated once again to include that fix. Only step 3 was modified.
Thank you for the feedback so far! Hang in there, it's worth it.
This commit (http://github.com/chendo/rails-test-serving/com...) works and also fixes the machinist problem we were having, where the first test would run, but any after that would error saying 'no blueprint for Foo'.
This fork solves it by adding a TEST_SERVER_OPTIONS constant that you define before you require 'rails-test-serving'.
Example:
TEST_SERVER_OPTIONS = {
:reload => [/blueprint/]
} unless defined? TEST_SERVER_OPTIONS
The 'unless defined' part is there to stop the warnings.
This forces any required files that match /blueprint/ to be reloaded.
Also my fork allows you to run tests when not in RAILS_ROOT, since the SERVICE_URI in Roman2K's branch is relative to the current directory. Our fork currently looks up three directories (three because the test folder shouldn't be any deeper than that) to find config/boot.rb, then adds tmp/sockets/test_server.socket to that path.
This is awesome and hopefully our fork has made it even more awesome.
P.S. Shouldn't it be called 'rails-test-server'?
How about $test_server_options instead? That would avoid warnings and allow for ||= {} in Server#initialize.
I like the lookup for the root directory. However, I will make it more generic (infinite depth) because in my code, each namespace has a corresponding directory in both app/models and test/units.
About the name "RailsTestServing", I agree it's not ideal. "RailsTestServer" came to mind, but since it's a container for a Client and a Server class, Server would end up having a full name of RailsTestServer::Server which I don't like.
Off to merging your fork :-)
** Test server started (#38293)
>> test/unit/patient_test.rb (5366 ms)
>> test/unit/patient_test.rbNOTICE: there is no transaction in progress
Like Jeff, I can't get my tests to run more than the first time. I get an exception about a class not being defined:
LoadError: Expected /Users/kmenard/dev/workspaces/sml/lib/maui/bad_words.rb to define Maui::BadWords
That file does indeed define the class BadWords in the Maui module. I'm not really sure what's going on there. Please let me know if you need any additional info.
Is "Maui" the exact letter case of the module? I ask because with ActiveSupport::Dependencies, if FOO::Bar is evaluated before FOO, FOO will be looked for in foo.rb and loaded, but then FOO::Bar won't be found since it will expect foo/bar.rb to define Foo::Bar instead.
Could you please give me the output the following chunk of code, put at the top of maui/bad_words.rb
p ActiveSupport::Dependencies.autoloaded_constants.grep(/maui/i)
p ActiveSupport::Dependencies.loaded.grep(/word/)
Or better, let's solve this together on IRC if you want. I'm in Freenode #rubyonrails, as Roman2K.
# lib/maui.rb
module Maui
end
Then, AS::Dependencies was able to load and reload Maui::BadWords as expected between each test run.
Thanks, Kevin!
The error you get about ApplicationController might be related. Could you try the latest version from GitHub (see the commands at the bottom of the article) in combination with RailsDevelopmentBoost (http://github.com/Roman2K/rails-dev-boost/tree/... -- see the note in the "Usage" section) as it would make less constants be reloaded between consecutive runs, perhaps avoiding the error about ApplicationController.
If that doesn't work, try cd'ing into app/controllers and creating a symlink from application_controller.rb to application.rb.
With the server running, `rake test:units` just produces:
Started
Finished in 0.000236 seconds.
0 tests, 0 assertions, 0 failures, 0 errors
I'd much prefer to run the whole test suite at once.
Thanks in advance for any help! <3
(At least for now,) only test files specified as an argument can be run by the server (like: ruby test/unit/foo_test.rb). To run more than one file, the server would have to be modified to load several files given their paths, a Dir.glob pattern, or a special argument. See RailsTestServing::Server#capture_test_result, inside the innermost block.
Or do you want the `rake test:units` to run tests on the client side instead? In that case, it's RailsTestServing::Client#run_tests! that should be altered, maybe checking the nature of $0 and the contents of ARGV before trying to connect to the server.
Anyway, I opened an issue on your Github repo :). Essentially, my tests run fine the first time (though not very quickly) but the second time trying to run them, they fail completely; every single one of them. Have you seen this behavior before?
Edit: I just tried the test server on a smaller project and it's running just fine (with some faster test time). So I'm guessing it's something in my environment for the other project (which is a very large project). Hmmm, time to hack away I suppose!
I appreciate that you took the time to post a comment here *and* to open an issue on GitHub. I hadn't seen such a problem before.
I replied to your issue on GitHub: I think a full stack trace will bring enough information for me to fix this bug or help you make it work with your bigger project.