标签:des style blog color io 使用 sp div on
subject { build(:user,firstname:‘john‘,lastname:‘doe‘)} it { should be_named ‘john doe‘}
it{}和subject{}互为别名
Gem扩展代码库 shoulda-matchers
直接使用
subject { Contact.new }
sperify { should validate_presence_of :firstname }
自定义匹配器
Rspec::Matchers.define :be_named do |expected| match do |actual| actual.name eq expected end description do "return a full name as a string" end end #use the defined matchers it { should be_named ‘John Doe‘}
标签:des style blog color io 使用 sp div on
原文地址:http://www.cnblogs.com/xueyuwyz/p/4040224.html