2

我有一个助手执行:

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

有任何想法吗?

4

1 回答 1

2

您需要使用如下所述的辅助对象: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
于 2012-07-21T00:35:22.297 回答