Skip to content

Instantly share code, notes, and snippets.

@dchelimsky
Created December 11, 2011 15:24
Show Gist options
  • Save dchelimsky/1461106 to your computer and use it in GitHub Desktop.
Save dchelimsky/1461106 to your computer and use it in GitHub Desktop.
Interaction between pending and before hooks in RSpec
describe Something do
before(:each) do
do_something_before
end
it "does one thing" do
# before will run for this example because rspec doesn't know it is pending
# until the example is eval'd
pending
end
it "does something else", :pending => true do
# before will _not_ run for this example
end
pending "does yet another thing" do
# before will _not_ run for this example
end
end
@jbrains
Copy link

jbrains commented Dec 11, 2011

Can I give :pending a message instead of true/false? I guess any non-nil string would be true.

@zspencer
Copy link

pending "does yet another thing", message: "waiting on card 353" do

end

it "does one thing", :pending=>'waiting on card 353; do

end

@dchelimsky
Copy link
Author

@jbrains - you can do what @zspencer suggests, but it the message doesn't get stored as the pending message (and is therefore not part of the output). Seems like it should :)

@zspencer
Copy link

If only we had the source code available so we could add the feature!

@dchelimsky
Copy link
Author

@jbrains - rspec/rspec-core#540 - please feel free to add commentary and/or enable notifications on that issue.

@dchelimsky
Copy link
Author

@zspencer - ha!

@dchelimsky
Copy link
Author

@zspencer, @jbrains - I've got this implemented and will push shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment