We have had a really great integrated javascripting testing in our very
large, very javascripty Sinatra application. Our testing setup uses a
custom version of harmony (http://github.com/baccigalupi/harmony), that
reduces the out of control memory we were seeing in the original gem.
The trade off has been performance, but it has been worth it since
harmony without these modifications get above 2G of memory consumption.
That was bringing our development box to its knees. The custom version
of harmony creates individual window objects with each request which can
then be garbage collected at the end of usage. It worked great in rspec
1.x. Here was our setup:

describe 'some javascript class' do
  before :all do
    @dom = Harmony::Page.new(my_ruby_view)
    @dom.load(some_js_files)
  end

  it 'should do something' do
    @dom.execute_js('javascript here').should == what_we_expect
  end
end

We are upgrading to RSpec 2, which has been a lot more involved and
undocumented than we had hoped.

Our biggest issue though is that the memory reduction measures that we
added to the harmony gem are no longer working. Presumably this is
because RSpec 2 is hanging on to the variables somewhere that we cannot
find. Setting our harmony Page objects to nil is not working:

  # in the spec_helper Rspec.configure block:
  config.after(:all) do
    puts 'about to cleanup'
    @dom = nil
    GC.start # trying to cleanup via Ruby
    puts Johnson.evaluate <<-JS
      Johnson.runtime.gc(); // trying to cleanup via JS
    JS
  end

We have tried a lot of ordering combinations in our garbage collection
to see if anything will work, but instead the memory is climbing out of
control with each suite. In version RSpec 1.x we didn't have to do any
manual garbage collection.

Does anyone have an idea of where the variable might be referenced in
RSpec 2 and how we can demand cleanup? For now we are going to have to
make a rake task that runs each spec separately, which will lead to a
not very useful testing task. Better than nothing, but it will cost us a
lot in developer time, going through all the output to find the
failures.

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to