2012-07-23 52 views
5

我有这样的代码“未给出原因”:rspec的 - 我怎样才能得到“pendings”有我的文字而不是仅仅

context "Visiting the users #index page." do 
    before(:each) { visit users_path } 
    subject { page } 
    pending('iii') { should have_no_css('table#users') }  
    pending { should have content('You have reached this page due to a permiss 

离子错误')}

它导致一对夫妇例如,

Managing Users Given a practitioner logged in. Visiting the users #index page. 
# No reason given 
# ./spec/requests/role_users_spec.rb:78 
Managing Users Given a practitioner logged in. Visiting the users #index page. 
# No reason given 
# ./spec/requests/role_users_spec.rb:79 

我怎样才能得到这些pendings有文本,而不是

我试图把一些文字,以待字之后和块之前,但没有帮助“未给出原因” - 它出现在行末 - 但我仍然拥有“没有理由”的全部内容。

回答

10

pending本身就是一种方法,并正常使用情况下是这样的:

it "should say yo" do 
    pending "that's right, yo" 
    subject.yo!.should eq("yo!") 
    end 

将输出

Pending: 
    Yo should say yo 
    # that's right, yo 
    # ./yo.rb:8 

所以,当你想使用缩写形式,如

its(:yo!) {should eq("yo!") } 

然后要标记为待定,您有几个选项:

xits(:you!) {should eq("yo!") } 
pending(:you!) {should eq("yo!")} 

但是为了得到一个消息之前,你应该做的:

its(:yo!) {pending "waiting on client"; should eq("yo!") } 

这会给你的输出

Yo yo! 
    # waiting for client 
    # ./yo.rb:16 
相关问题