Michael Cordell's Blog

Rspec Notes

14 Sep 2013

Referencing a bug report in an example via pending

describe "functionality" do
  it "should do something" do
    pending("bug report #78") do
        xyz.function()
    end
  end
end

What is nice here is that when the bug is fixed it will actually raise an error showing that you can remove the pending block and tests can run as normal. The pending block is executed here and checked for errors, this reduces code commenting.

Yield Helper method

describe Thing do
  def given_thing_with(options)
    yield Thing.new do |thing|
      thing.set_status(options[:status])
    end
  end
end