【发布时间】:2014-08-26 21:07:47
【问题描述】:
我正在尝试将辅助方法从控制器测试移动到 test_helper.rb:
# example_controller_test.rb
require 'test_helper'
class ExampleControllerTest < ActionController::TestCase
should 'get index' do
turn_off_authorization
get :show
assert_response :success
end
end
# test_helper.rb
class ActionController::TestCase
def turn_off_authorization
ApplicationController.any_instance
.expects(:authorize_action!)
.returns(true)
end
end
但是,我收到一个错误:
NameError: undefined local variable or method `turn_off_authorization' for #<ExampleControllerTest:0x000000067d6080>
我做错了什么?
【问题讨论】:
标签: ruby-on-rails testing minitest