acceptance tests not loading helpers in 9.0.0.rc5 #109

ludicast opened this Issue May 6, 2011 · 32 comments


None yet

In using both Steak and my own tool Saki, I get missing method errors whenever the views are loading in helper methods. This problem is also mentioned by folk on the Steak group:
and seems to be, a reincarnation of this issue:

I backed out to 0.8.4 which seems to be doing the trick.

sporkrb member

That's odd.. the integration tests are specifically testing for this (rails_delayed_loading_workarounds.feature).

0.8.4 is not compatible with rails 3, which version of rails are you using?


It gets odder then, Rails 3.0.5, Rspec 2.5.0, Ruby 1.9.2. Maybe I'm not exercising parts of Rails that 1.8.4 is incompatible with.

To try to be a more productive citizen I tried to run your test suite for the latest commit and am getting a slew of failures.

loading cucumber the way listed gives me: "can't convert Pathname into String"

And the RSpec tests give me:
1) Spork::Diagnoser installs it's hook and tells you when files have been loaded
Failure/Error: require filename
no such file to load -- my_awesome_library_include.rb
# ./lib/spork/diagnoser.rb:31:in require'
# ./lib/spork/diagnoser.rb:31:in
# ./spec/spork/diagnoser_spec.rb:16:in block in run_simulation'
# ./spec/spork/diagnoser_spec.rb:12:in
# ./spec/spork/diagnoser_spec.rb:12:in run_simulation'
# ./spec/spork/diagnoser_spec.rb:23:in
block (2 levels) in '

2) Spork::Diagnoser excludes files outside of Dir.pwd
Failure/Error: Unable to find matching line from backtrace
stack level too deep
# ./lib/spork/diagnoser.rb:93

3) Spork::Diagnoser excludes files outside of Dir.pwd but in ruby's include path
Failure/Error: Unable to find matching line from backtrace
stack level too deep
# ./lib/spork/diagnoser.rb:93

4) Spork::Diagnoser expands files to their fully their fully qualified path
Failure/Error: Unable to find matching line from backtrace
stack level too deep
# ./lib/spork/diagnoser.rb:93

5) Spork::Diagnoser can tell the difference between a folder in the project path and a file in an external path
Failure/Error: Unable to find matching line from backtrace
stack level too deep
# ./lib/spork/diagnoser.rb:93

6) Spork::Diagnoser filters backtrace beyond the last line matching the entry point
Failure/Error: Unable to find matching line from backtrace
stack level too deep
# ./lib/spork/diagnoser.rb:93

7) Spork::Diagnoser.output_results outputs the results relative to the current directory
Failure/Error: Spork::Diagnoser.output_results(out)
undefined method map' for "/project_path/lib/parent_file.rb:35":String
# ./lib/spork/diagnoser.rb:77:in
block in output_results'
# ./lib/spork/diagnoser.rb:75:in each'
# ./lib/spork/diagnoser.rb:75:in
# ./spec/spork/diagnoser_spec.rb:99:in `block (3 levels) in '

8) Spork::RunStrategy::Forking returns the result of the run_tests method from the forked child
Failure/Error:"test", STDOUT, STDIN).should == "tests were ran"
expected: "tests were ran"
got: nil (using ==)
# ./spec/spork/run_strategy/forking_spec.rb:13:in `block (2 levels) in '

9) Spork::RunStrategy::Forking aborts the current running thread when another run is started
Failure/Error:"test", STDOUT, STDIN).should == true
expected: true
got: nil (using ==)
# ./spec/spork/run_strategy/forking_spec.rb:21:in `block (2 levels) in '

sporkrb member

Do you have an instance of spork running while running the test suite? That has caused problems for me... it would help if spork would refuse to run specs outside of it's working directory.

What command are you running to run the test suite? Which version of ruby? Rubygems? I usually run them with "bundle exec rspec spec/".

I've run it with ruby 1.8.7, rubygems 1.5.0 and everything passes... features and specs. :S

I've run the features with ruby 1.9.2, but not the specs... I'll give that a run

sporkrb member

I reproduced the failures with Ruby 1.9.2, thank you for raising those. (For some reason, they just fail when running specs, but not features… And Spork works for me in Ruby 1.9.2). Weird

sporkrb member

Hmm.. I was pretty sure that I just ran the features with Ruby 1.9.2… I also get an error there. Looks like I've got some work to do. Thanks, I'll get it fixed.


Yeah, I'm using rubygems 1.3.7 and ruby 1.9.2, and I've been launching it the same way (bundle exec rspec spec). Maybe some part of my environment isn't sane but everything's pretty vanilla I believe.

sporkrb member

Ok... specs and features all passing with latest master. Ruby 1.9.2 / rubygems 1.8.1. They were compatibility issues with the test code and not the actual application itself :S

sporkrb member

Spork 0.9.0.rc6 is out with the test updates, although no application code was specifically written to address this. However, some other fixes were made and may resolve? May be worth trying.

The tests I added to confirms that this is working, so it appears to be an interaction with webrat or steak.

Maybe we'll need to add a test that tests interaction with webrat / steak. Hmm...


Under RubyGems 1.7.2 & 1.8.1 all tests are passing except for two cucumber tests which both seem to be failing at file lookups

1) cucumber features/diagnostic_mode.feature:6 # Scenario: Running spork --diagnose
And the output should contain "lib/awesome.rb" # features/steps/sandbox_steps.rb:93
expected "" to include "lib/awesome.rb" (RSpec::Expectations::ExpectationNotMetError)
./features/steps/sandbox_steps.rb:94:in /^the (error output|output) should contain "(.+)"$/'
And the output should contain "lib/awesome.rb"'

2) cucumber features/rails_delayed_loading_workarounds.feature:70 # Scenario: respecting custom autoload paths
Then the output should contain "BOOGIE!!!" # features/steps/sandbox_steps.rb:93
expected "Exception encountered: #\nbacktrace:\n/usr/l

Also for 1.8.2 I'm failing at
3) cucumber features/spork_debugger.feature:6 # Scenario: Invoking the debugger via 'debugger'
Then the spork window should output a line containing "count = 0" # features/steps/sandbox_steps.rb:61
expected "\n\n\n\n - Debug Session Terminated - \n\n\n" to include "count = 0"

I'd like to start writing tests for Spork & RSpec integration tests (webrat / capybara / steak etc.) but to do that I'd obviously want to first get to green with cucumber, especially where file lookups are concerned.

below is my Gemfile.lock

archive-tar-minitar (0.5.2)
builder (3.0.0)
columnize (0.3.2)
cucumber (0.10.2)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
gherkin (>= 2.3.5)
json (>= 1.4.6)
term-ansicolor (>= 1.0.5)
diff-lcs (1.1.2)
gherkin (2.3.7)
json (>= 1.4.6)
json (1.5.1)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
rake (0.8.7)
rspec (2.5.0)
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
rspec-mocks (~> 2.5.0)
rspec-core (2.5.2)
rspec-expectations (2.5.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.5.0)
ruby-debug-base19 (0.11.25)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
ruby-debug19 (0.11.6)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
term-ansicolor (1.0.5)


cucumber (= 0.10.2)
rspec (= 2.5.0)

As a note I'm running 1.9.2p0. I'll upgrade that and see if the cucumber tests start passing.

sporkrb member

Ok... this is wild. That failure DOES show that spork isn't working. Sure enough... it (Scenario: respecting custom autoload paths # features/rails_delayed_loading_workarounds.feature:70) passes on ruby 1.8.7, but fails on 1.9.2. Ugh, how weird. At least I'm able to replicate it on my side.


Anyone have a workaround for this?


also interested in what's happening here - super weird


This still happens for me on ruby 1.9.2p136, spork 0.9.0rc9 and webrat 0.7.3


Still happens on Ruby 1.9.2p180, Capybara 1.1.1, Rails 3.0.4, Sprok 0.9.0rc9 ;-(

@jackkinsella jackkinsella pushed a commit that referenced this issue Sep 12, 2011
Jack Kinsella Fix for issue #109. Helpers now available to request specs. f8351ae

This doesn't seem to fix it for me. Still getting errors of unitialized constant WhateverHelper.


However adding ActiveSupport::Dependencies.clear at the end of the prefork block did.


I'm having this issue as well. Any luck?

@k41n k41n added a commit to k41n/spork that referenced this issue Nov 28, 2011
@k41n k41n Merged pull request 140 for issue #109 838a4c9

I'm also seeing this in my app. Interestingly, it only started happening when I installed activeadmin (0.3.4), which in turn installed fastercsv (1.5.4), formtastic (1.2.4), has_scope (0.5.1), inherited_resources (1.2.2), kaminari (0.13.0), meta_search (1.1.1), polyamorous (0.5.0), and responders (0.6.4).

Just wondering if it is something in one of these gems that's causing the issue somehow?


Had this problem as well after installing devise and so far none of the suggestions or commits above have helped.


can confirm the problem here also, I have both installed (devise and activeadmin) so not sure which one is causing the error... anyone has a workaround?

sporkrb member

What needs to be done here, is someone needs to write an integration test to create the failure independent of any 3rd-party gems (other than rails).

Spork-rails has an integration test that specifically tests for this, and it now passes using ruby 1.9.2. The above "Fix for issue #109. Helpers now available to request specs." may fix this specific issue, but breaks other known tested use cases, so I can't merge it.

So, here's my challenge: Somebody go clone Look at the cucumber features. Copy one and modify it to manifest this specific bug. Submit it as a pull request and I will create a fix.


Pretty sure this is related to ActiveAdmin and not one if it's dependencies. Will try and produce an independent test case though.


I've tracked this down a bit further but not enough to work out what is going on. Hopefully these notes might help someone else

If you are using ActiveAdmin then you add the following in routes.rb

devise_for :admin_users, ActiveAdmin::Devise.config

To break it you can even simply add

puts ActiveAdmin::Devise.config

In ActiveAdmin::Devise the lines that cause the issue are

class SessionsController < ::Devise::SessionsController
include ::ActiveAdmin::Devise::Controller

But including anything here will break it. For example

module Foo
class SessionsController < ::Devise::SessionsController
include Foo

Also causes the problem

Makes no sense to me!


I had this same issue with ActiveAdmin/Spork. This resolved it for me:


I've had a problem where methods in application_helper.rb were not being loaded when running Cucumber scenarios against Spork. I also use ActiveAdmin. The above made things work. I only needed to add

Spork.trap_method(Rails::Application::RoutesReloader, :reload!) # Rails 3.1

to the env.rb prefork block.


I have had the fix in place for a while and it doesn't fix the helpers loading problem.


I also have tried the fix without success using guard-spork, devise, rails 3.1.6, ruby 1.9.3.


Same problem exists on Rails 3.2.7 with Ruby 1.9.3, Spork 0.9.2. Helpers don't get loaded, there is also a ticket in spork-rails about this.


same issue here when trying to use Turnip (spork 0.9.2, ruby 1.9.3, rails 3.2.8)


same problem to load helpers here...

if I include each helper, it works, but I would know some clean way to do this

Spork.prefork do
  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'shoulda/matchers/integrations/rspec'
  include ApplicationHelper
  include GraphicsHelper
AbstractController::Helpers::ClassMethods.module_eval do def helper(*args, &block); modules_for_helpers(args).each {|mod| add_template_helper(mod)}; _helpers.module_eval(&block) if block_given?; end end if Spork.using_spork?

from #140 fixed the issue for me.


@gravis thanks, but this not worked for me :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment