【发布时间】:2011-09-09 11:35:04
【问题描述】:
我有以下内容可以删除特定属性上的空格。
#before_validation :strip_whitespace
protected
def strip_whitespace
self.title = self.title.strip
end
我想测试一下。目前,我已经尝试过:
it "shouldn't create a new part with title beggining with space" do
@part = Part.new(@attr.merge(:title => " Test"))
@part.title.should.eql?("Test")
end
我错过了什么?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 unit-testing rspec rspec2