rspec - how can I get "pendings" to have my text and not just "No reason given"

capybara, rspec, ruby, ruby-on-rails, testing

Solution

`pending` itself is a method, and the normal use case is something like this:

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

That will output

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

So, when you want to use the short form, like

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

Then to mark as pending you have a couple of options:

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

But to get the pending with a message, you should do:

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

That'll give you the output

  Yo yo! 
    # waiting for client
    # ./yo.rb:16

Problem

I have this code: ``` 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 ``` ions error') } It results in a couple of pendings, e.g. ``` 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 ``` How can I get those pendings to have text instead of "no reason given" I've tried putting some text after the word pending and before the block but that didn't help - it appeared at the end of the line - but I still have all the "No reason given"s.

Original source