rspec - 我怎样才能得到"pendings"来获取我的文字,而不仅仅是"没有给出理由"

Mic*_*ant 5 ruby testing rspec ruby-on-rails capybara

我有这个代码:

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
Run Code Online (Sandbox Code Playgroud)

离子错误')}

它导致一些挂起,例如

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
Run Code Online (Sandbox Code Playgroud)

我怎样才能让这些挂件有文字而不是"没有给出理由"

我已经尝试在单词pending之后和块之前添加一些文本,但这没有帮助 - 它出现在行尾 - 但我仍然拥有所有"没有理由".

Jes*_*ott 10

pending 本身是一种方法,正常的用例是这样的:

  it "should say yo" do
    pending "that's right, yo"
    subject.yo!.should eq("yo!")
  end 
Run Code Online (Sandbox Code Playgroud)

这将输出

Pending:
  Yo should say yo
    # that's right, yo
    # ./yo.rb:8
Run Code Online (Sandbox Code Playgroud)

所以,当你想使用简短形式时,比如

its(:yo!) {should eq("yo!") }
Run Code Online (Sandbox Code Playgroud)

然后标记为待处理您有几个选项:

xits(:you!) {should eq("yo!") }
pending(:you!) {should eq("yo!")}
Run Code Online (Sandbox Code Playgroud)

但要通过消息获取待处理,您应该:

its(:yo!) {pending "waiting on client"; should eq("yo!") }
Run Code Online (Sandbox Code Playgroud)

那会给你输出

  Yo yo! 
    # waiting for client
    # ./yo.rb:16
Run Code Online (Sandbox Code Playgroud)