【发布时间】:2015-01-06 03:36:15
【问题描述】:
我正在尝试为助手编写测试。目前我的代码如下所示:
application_helper_test.rb
require File.dirname(__FILE__) + '/../test_helper'
class ApplicationHelper < ActiveSupport::TestCase
def test_title
assert_equal "Test", title
end
end
application_helper.rb
module ApplicationHelper
def title
controller_name.humanize
end
end
但是我的终端出现这个错误,有什么帮助吗?
Run options: --seed 4320
# Running:
E
Finished in 0.022048s, 45.3556 runs/s, 0.0000 assertions/s.
1) Error:
ApplicationHelper#test_title:
NameError: undefined local variable or method `title' for #<ApplicationHelper:0x007fd4eef00760>
application_helper_test.rb:7:in `test_title'
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
【问题讨论】:
标签: ruby-on-rails ruby testing ruby-on-rails-4 helpers