Calin
Calin

Reputation: 6867

Rails 3.2.3 with spork does not recognize helper methods in cucumber tests

I have a application that is using rails 3.2.3 and spork 1.0.0rc2. When I run my cucumber test I get:

ActionView::Template::Error: undefined local variable or method `page_title'

Where page_title is defined in my application helper. I am not sure what broke them as it was working until the last bundle update.

Anyone having the same issue?

Upvotes: 10

Views: 749

Answers (3)

SSP
SSP

Reputation: 2670

To fix this issue add these below lines in Spork.prefork block

full_names = Dir["#{Rails.root}/app/helpers/*.rb"]

full_names.collect do |full_name|
    include Object.const_get(File.basename(full_name,'.rb').camelize)
end

Upvotes: 5

Andrey Kryachkov
Andrey Kryachkov

Reputation: 901

Take a look at this thread https://github.com/sporkrb/spork-rails/issues/6#issuecomment-11105681 there are two solutions for this problem

Upvotes: 2

chischaschos
chischaschos

Reputation: 557

People has been reporting something alike for rails 3.1 when using spork: https://github.com/sporkrb/spork/issues/109

Basically, they tell you to use this:

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

I use rails 3.1 but that did not solve my problems. I'm still looking for an answer.

Upvotes: 1

Related Questions