我有一个助手可以执行以下操作:
def send_to_block(value, &block)
capture(value, &block)
end
编写测试时:
value_received = nil
send_to_block('test') do |value|
value_received = value
end
value_received.should == 'test'
我遇到以下异常:
NameError: uninitialized constant Kernel::DISABLED
有什么想法吗?
最佳答案
您需要使用辅助对象,如下所述:https://www.relishapp.com/rspec/rspec-rails/v/2-11/docs/helper-specs/helper-spec
沿着这些思路的东西应该是你所追求的:
require "spec_helper"
describe MyHelper do
describe "#send_to_block" do
it "should do something" do
helper.send_to_block('test').should == 'I have no idea what this should be'
end
end
end
关于ruby-on-rails - 如何测试使用捕获的辅助方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11587229/