Hello all, I'm in the process of migrating from rspec to minitest, using minitest-rails, and am having problems with my helper tests. I solved one "missing html_escape" problem by including include ERB::Util, but this other problem has me stumped.
I narrowed it down to "content_for", and for test purposes tried a simple test case. I added the following into my ApplicationHelper:
def foo
content_for(:foo) do
"Hello world"
end
end
and in my application_helper_test.rb file I have:
require 'test_helper'
describe ApplicationHelper do
it "handles content_for" do
content_for(:foo).must_equal 'Hello world'
end
end
when I run this, I get:
ApplicationHelper
ERROR (0:00:00.011) 0001 handles content for
undefined method `get' for nil:NilClass
@ /home/orava/.rvm/gems/ruby-1.9.3-p392@cornerstone/gems/actionpack-3.2.13/lib/action_view/helpers/capture_helper.rb:142:in `content_for'
test/helpers/application_helper_test.rb:9:in `block (2 levels) in <top (required)>'
/home/orava/.rvm/gems/ruby-1.9.3-p392@cornerstone/gems/activesupport-3.2.13/lib/active_support/testing/setup_and_teardown.rb:36:in `block in run'
/home/orava/.rvm/gems/ruby-1.9.3-p392@cornerstone/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:447:in `_run__3596054173487172977__setup__3586964360801127651__callbacks'
/home/orava/.rvm/gems/ruby-1.9.3-p392@cornerstone/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/orava/.rvm/gems/ruby-1.9.3-p392@cornerstone/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_setup_callbacks'
/home/orava/.rvm/gems/ruby-1.9.3-p392@cornerstone/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/orava/.rvm/gems/ruby-1.9.3-p392@cornerstone/gems/activesupport-3.2.13/lib/active_support/testing/setup_and_teardown.rb:35:in `run'
If I look in action_view/helpers/capture_helper.rb:142, I see that it's blowing up here:
.i.e. @view_flow is nil.
Any ideas of what I should do to fix things? All this worked fine in rspec-rails, though there I needed to append helper. to all helper method calls while here they are apparently being included into the test namespace.
Is there some special secret sauce for running helper tests with minitest-rails, or is it a bug/missing feature in the current implementation?
-Petri