这当然是微不足道的,但无法弄清楚出了什么问题。
助手:app / helpers / bookings_helper.rb
module BookingsHelper
def booking_price(booking)
"something"
end
end
帮助规范:spec / helpers / bookings_helper_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe BookingsHelper do
describe "#booking_price" do
helper.booking_price.should == 'something'
end
end
错误
/Library/Ruby/Gems/1.8/gems/activesupport-3.0.4/lib/active_support/whiny_nil.rb:48:in `method_missing': undefined method `booking_price' for nil:NilClass (NoMethodError)
答案 0 :(得分:2)
尝试使用它代替内部块的描述:
describe BookingsHelper do
it "#booking_price" do
helper.booking_price.should == 'something'
end
end