Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 833
Michael Durrant Avatar asked Jul 23 '12 14:07

Michael Durrant


1 Answers

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
like image 144
Jesse Wolgamott Avatar answered Sep 23 '22 05:09

Jesse Wolgamott