RSpec2 & Rails3, issue with the basics of testing helpers
That's certainly trivial but can't figure out what goes wrong.
Helper : app/helpers/bookings_helper.rb
module BookingsHelper
def booking_price(booking)
"something"
end
end
Helper spec : 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
Error
/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)
Try using it instead of describe for the inside block:
describe BookingsHelper do
it "#booking_price" do
helper.booking_price.should == 'something'
end
end
精彩评论