2013-05-01 66 views
1

只是出于好奇,有没有一种方法,使rspec的打印从上下文块文本出从失败消息“它”块文本之前?例如:请RSpec的打印“语境”中的“它”块的描述之前描述

describe Array do 
    context "when created with new" do 
    it "is empty" do 
     array = Array.new 
     array << 1 # trigger a failure to demonstrate the message 
     array.should be_empty 
    end 
    end 
end 

眼下“创建时新空阵”在失败的消息,这将打印。 这听起来有点别扭给我。有没有办法让rspec说“用新的数组创建时,数组是空的”呢?在我看来,这听起来更自然。只是好奇...

回答

0

我不知道的办法有RSpec的反转描述字符串的顺序,但如果您使用您的the documentation formatter输出将会使一些更有意义 - 这样的:

Array 
    when created with new 
    is empty 

至少这样,压痕清晰地界定描述中的重要短语。