Every repository with this icon (
Every repository with this icon (
| Description: | A DRb server for testing frameworks (RSpec / Cucumber currently) that forks before each run to ensure a clean testing state. edit |
-
Vote for this if you'd like to see Spork run on windows
Comments
-
3 comments Created 6 months ago by timcharperfeature_requestxSupport for Micronauttest_frameworkxVote if you'd like Spork to support Micronaut (and Micronaut to support running tests over drb)
Comments
+1
Should be pretty easy, as micronaut config and running is very similiar to RSpec.
timcharper
Wed Nov 04 08:38:38 -0800 2009
| link
it seems that github needs to make the little voting box bigger. See that up arrow, with '0 votes'. That is how you vote for things in github issues :) That causes them to float to the top.
-
1 comment Created 6 months ago by timcharperfeature_requestxSupport for Merbtest_frameworkxSpork will work with Merb already, but doesn't quite have the "out of the box" experience that rails does (Spork automatically hooks in to Rails to make a lot of things just work by default, like preventing your ApplicationController, views, and models from being cached).
Comments
-
It would be very helpful if you could programmatically tell spork to reload. My use case is within autotest. When certain files change the entire environment needs to be reloaded. I'd like to be able to tell spork to reload from within my autotest mapping hooks. This could be done by sending a signal to the spork process or maybe connecting to the DRB server.
Comments
Actually.. in addition to having all of spork reload what would be very cool is if we could send arbitrary code (via DRb) to the parent spork process that would be evaluated. That way, we could tell it only to reload certain parts that we know need to be reloaded. Just an idea.. reloading all of it is probably easier to do at this point.
timcharper
Mon Aug 10 12:09:29 -0700 2009
| link
This sounds very cool. In order to achieve the "reload specific portions of the app part" we would have to create a few layers of forked processes, similar to how passenger does it. I think having a full restart occur would be a great start and may suffice.
I just sent a pull request to both of you with a rough initial reload implementation to take a look at.
This gist: http://gist.github.com/216680 shows how to use the kicker gem to send Drb spec_sever.reload requests when code files change in rails.
Hmm ... I just found a much simpler work-around for at least one part of this problem.
Here's a simple description of what I'd like to do:
- Have a rails model and the spec test for that model open in textmate
- command-R in the spec test to see the results
- change code in the model
- command-R again in the spec test to see new results
We are using Factory girl and normally when we run this command to see what is loaded in prefork:
spork -d | grep -A25 modelsI see FactoryGirl load all the model classes we are using factories for -- of course by doing that in prefork it means that any model changes I make after spork startup don't appear after the fork.
We added this file: config/initializers/spork.rb
if defined?(Spork) Spork.trap_class_method(Factory, :find_definitions) endreference, Tim's suggestion in this thread: http://groups.google.com/group/sporkgem/browse_thread/thread/24e6342e6629d371#
This delays FactoryGirls loading of the model classes it needs to introspect until after the fork.
My simple test above now works.
My test environment is setup to cache classes (config/environments./test.rb)
config.cache_classes = trueMy vendored rails is 2.3.4.
I had thought the model classes would be eagerly loaded in this case but appears not to be the case.
Thinking about how to get the most performance using spork in testing -- obviously the first step is to use more mocks and less factories/fixtures ... but after that a useful generalization is:
- load as many app classes and generate app/state in prefork as possible AND is necessary for your tests
- don't load classes in prefork that you are working on (or app state that might be affected by the change in these classes)
It might be helpful if after Spork started I could add or subtract classes from prefork app state. My method above which reloads the whole prefork is just brute force. If I had kicker watching for fsevents and in the case above removed just the model class I was working on from the prefork -- that might help. I don't know how unloading the class would affect the app state if it already had instances using the earlier versions of the model ...?
-
It would be great to able to launch spork as deamon :-)
Comments
-
ApplicationController is preloaded by spork by this file:
Unfortunately, my ApplicationController doesn't descend directly from ActionController::Base
http://gist.github.com/165273
http://gist.github.com/165274This is causing a superclass mismatch when I load spork + try to run specs:
http://gist.github.com/39871732f9a02cf84bcc.
>I'm not sure what the idea fix here is - Do we remove the stub (and cause ApplicationController to be loaded automatically in the prefork block), or do we parse application.rb, and load up any other descendent classes?
A middle ground might be this: if your application descends directly from ActionController::Base, preload the stub, otherwise, load the real file.
Comments
timcharper
Mon Aug 10 12:00:13 -0700 2009
| link
Would it be out of the question to rework your inheritance scheme so that ApplicationController does inherit straight from "ActionController::Base" ?
IE:
class ApplicationController < ApplicationController::Base
endclass BaseApplicationController < ApplicationController
endclass UsersController < BaseApplicationController
endIn other words, what is specific motivation for ApplicationController not inheriting from ApplicationController::Base?
Loading the real file is problematic because it will start to grab and preload all sorts of dependencies from your app, causing you to have to restart Spork more often in order for it to see your changes. (additionally, it's not feasible to NOT preload ApplicationController, because rspec-rails WILL, along with all of your ApplicationController's dependencies).
timcharper
Mon Aug 10 12:05:04 -0700 2009
| link
If the above isn't feasible, one possible option would be to create an over-ridable configuration parameter on Spork specifying where the preloadable-bare-bones ApplicationController lies, causing Spork to direct any attempt to load ApplicatonController there rather than it's own stubbish ApplicationController.
smtlaissezfaire
Mon Aug 10 12:20:14 -0700 2009
| link
Maybe I'm the only one in the world doing this, but I consider this a bug in spork.
Certainly, though, the inheritance scheme could use a module instead of a class.
timcharper
Mon Aug 10 12:26:43 -0700 2009
| link
Taking the premise that this is a bug with Spork, how would you propose to fix it?
smtlaissezfaire
Mon Aug 10 13:02:44 -0700 2009
| link
Not sure - this is why I was asking your advice ;)
As far as I'm concerned, if it isn't a bug in Spork, it's (one of many) gross aspects of rails.
I'm up for moving my code into a module.
timcharper
Mon Aug 10 13:08:09 -0700 2009
| link
I was trying to understand how you arrived at the conclusion that this is a bug in sport.
I would lean towards this being that rails wasn't intended to be used the way spork is using it, so spork has to do some forceful operations to get it to behave. As such, a case could be made that rails has an underlying design flaw.
smtlaissezfaire
Mon Aug 10 15:00:19 -0700 2009
| link
I originally called it a bug in spork because an older version of spork worked fine (that one was preloading ApplicationController, which I consider a nuisance more than anything else).
This version of spork won't work at all unless I first factor my code.
smtlaissezfaire
Mon Aug 10 15:01:14 -0700 2009
| link
BTW: What are you imagining for the parameter idea? Something like this:
http://gist.github.com/799ff78d064b48d2cf30
?
smtlaissezfaire
Mon Aug 10 15:41:37 -0700 2009
| link
timcharper
Mon Aug 10 16:26:19 -0700 2009
| link
I believe that won't work because some parts of the rails code base (and rspec-rails too, I believe) explicitly call "require 'application_controller.rb'". The way spork blocks this is by sticking the path with the blank application_controllers to the front of the lib path, satisfying all attempts to "require 'application_controller.rb'", and then later deliberately requiring the application's ApplicationController before the specs are run.
Tim
smtlaissezfaire
Mon Aug 10 16:39:50 -0700 2009
| link
Yes - I realized that - which is why I didn't remove the application_helper.rb files, etc.
Sorry if that wasn't obvious from the specs
-
Waiting 8-10 seconds after spec_helper has finished
8 comments Created 3 months ago by grosserBack in Rails 2.1 days spork was blazing fast, but now at 2.3 after the initial spec_helper.rb load there is a waiting period of around 8-10 seconds, (environent.rb is not loaded again, I checked with some puts here and there).
The current loading looks something like this(found out with puts-ing everywhere...):
spec_helper:start -- prefork -- spec_helper:end -- 8-10seconds wait -- each_run -- each_run -- spec_helper:start -- spec_helper:endDo you have any idea how I could find out where this time is spent ?
Comments
timcharper
Sat Sep 12 00:44:48 -0700 2009
| link
Have you tried using ruby-prof ? You can tell it to profile a specified block, then write the results for that block to a file.
The problem was that views loading + application loading just took longer in rails 2.3 (view loading because of the eager loading)
My current solution is to disable views reloading, but keep the application loading(since spork does not make much sense without...) -> see hacks belowthe only real solution to this "your app is just too large"-problem cold be partially reloading e.g. reloading a file when it changes, but for this to work the e.g. odel must be unloaded, which i dont know how to do.....but maybe you got any further idea ;)
cheers mg
#insert before Spork.prefork begin require 'spork/app_framework/rails' module Spork::AppFramework::Rails::NinjaPatcher #views are preloaded <-> spork must be restarted for view changes def delay_eager_view_loading puts "removed because i am too slow..." end # no application files reload <-> ultra-fast + any app/xxx change needs spork restart def delay_app_preload puts "removed because i am too slow..." end def delay_application_controller_loading puts "removed because i am too slow..." end end rescue endYeah i found a solution: disable Rails app/ eager-loading, now im back to 1 second startup :D
begin require 'spork/app_framework/rails' module Spork::AppFramework::Rails::NinjaPatcher # views are preloaded <-> spork must be restarted for view changes def delay_eager_view_loading puts "removed because i am too slow..." end # do not preload application files <-> fast test start def delay_app_preload ::Rails::Initializer.send(:define_method, :load_application_classes) do end end end rescue endcould you add something like Sporl.rails.eager_load_classes = false and Spork.rails.preload_views=false ?
timcharper
Mon Sep 28 15:39:25 -0700 2009
| link
I think that should be the default. Though I'm wondering, have you tried just turning off cache_classes? What would be the consequence of that?
Yep, this would work too. cache_classes is the default for test environment, dunno why...
timcharper
Mon Nov 02 21:45:39 -0800 2009
| link
ok, so I am thinking of having spork display a warning if cache_classes is true. Do you guys think that will be an appropriate solution?
Setting cache_classes to false is a neat trick, actually. Just running a single, simple spec (with
time rake spec SPEC=(the spec file)) I've reduced the time from 10.1s to 4.5s (my app is bloated so I think that's probably why it's not like 1.0s). I think displaying a message of some kind would be good. -
It seems at_exit does not work with Cucumber+Spork (see discussion at http://groups.google.com/group/cukes/browse_thread/thread/8801396bc3a888e7?hl=en).
Instead if spork had a between_run hook, I could run teardown stuff there instead of at_exit.
Comments
-
Custom helper aren't found when running spork
2 comments Created 19 days ago by JerryWhoIf I use a custom helper method in a view spork generates an error because this helper method is unknown. If the method is in a controller helper (app/helpers/items_helper.rb in my example) everything is okay.
I put an example on github: http://github.com/JerryWho/test
If rake spec is run without spork all tests pass. But with spork an error occurs:ActionView::TemplateError in '/items/index.html.erb renders a list of items'
undefined method `simpleFunction' for #<ActionView::Base:0x243ca54>In tmp/rails-debug.log I write the loaded files. app/helpers/simple_helper.rb appears. app/helpers/items_helper.rb also appears.
Comments
timcharper
Thu Dec 03 12:39:29 -0800 2009
| link
Just to help me, this is an issue from this thread:
http://groups.google.com/group/sporkgem/browse_thread/thread/631f143d2c10277d
-
warning: already initialized constant SUPPORTED_FRAMEWORKS
1 comment Created 13 days ago by cswilliamsafter upgrading from 0.7.3 to 0.7.4, I now get the following warning when I start up the spork server:
/Library/Ruby/Gems/1.8/gems/spork-0.7.4/bin/../lib/spork/app_framework.rb:8: warning: already initialized constant SUPPORTED_FRAMEWORKSDoesn't seem to affect anything though.
Comments
-
One of the things I've found very confusing as I've begun to use Spork is knowing where to put my Spec::Runner code. It'd be nice if the feature file for RSpec showed a more complete example file. As it stands things are pretty skimpy.
Comments












+1
Yes please :<
+1
This really a needed thing to me, since I need to test my features (Cucumber) with Watir/IE :-(
+1 I can help :)
+1 - we need this too for a project. I can help (hopefully) with the coding
+1 The kicker really is that with windows I think you'll need to forward all your stdin/stderr output across TCP sockets back to the host. But it should work :)
This is actually already done (stdin / sterr output over tcp sockets). DRb does some magic to let you do this. (referring to Roger's comment)
I'm really excited to get started on this. I've been very swamped with my preparations for #LSRC though (you have no idea how much work it is to prepare a measly 6 hours worth of training). So... excited to get back to this when I get back.
Oh nice. I suppose for now windows users can use cygwin--that doesn't help me too much since I use normal Test::Unit tests, but hey, it's one step closer to coding bliss :)
-r
+1 working in windows would be awesome, feature runs are slooow - might have to resort to spec_server for now
+1
Getting much closer. The RunStrategy extraction has been completed, so now one would just need to implement the Magazine RunStrategy and it'll be done!
I'll be back at the project next week (although we have switched to JRuby completely) -- and I'll take a look if I can work on this
ok - jruby is on the radar as well. Can be supported via forking strategy using FFI on POSIX systems, and windows sytem via magazine strategy.
Just a sidenote: If anyone has experience with forking for windows/jruby, the parallel and with it the parallel_specs projects are in need of windows/jruby forking too...
plz
@grosser - as far as I know, ruby on windows doesn't support Kernel.fork. You will need to fire up separate processes, and communicate with them.
It'd be a huge plus for me and my team as well.
Is it correct to assume that because Kernel.fork is implemented in Ruby, that running Cygwin won't help if Cygwin is pointing to a Win32 Ruby interpreter?
Let me know if/how I can help.
Another vote to get this working.
Please see the wiki page: http://wiki.github.com/timcharper/spork/windowssupport
I've outlined what's needed to do, and I've architected spork so this will be possible.
If you're interested in implementing it, I'm happy to offer assistance.
Tim
+1